io.qameta.allure.timeline.TimelinePlugin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of allure-generator Show documentation
Show all versions of allure-generator Show documentation
Module allure-generator of Allure Framework.
/*
* Copyright 2016-2024 Qameta Software Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.qameta.allure.timeline;
import io.qameta.allure.CommonJsonAggregator2;
import io.qameta.allure.core.LaunchResults;
import io.qameta.allure.entity.LabelName;
import io.qameta.allure.entity.TestResult;
import io.qameta.allure.tree.TestResultTree;
import io.qameta.allure.tree.Tree;
import java.util.Collection;
import java.util.List;
import static io.qameta.allure.tree.TreeUtils.groupByLabels;
/**
* Plugin that generates data for Timeline tab.
*
* @since 2.0
*/
public class TimelinePlugin extends CommonJsonAggregator2 {
public TimelinePlugin() {
super("timeline.json");
}
@Override
protected Tree getData(final List launchResults) {
// @formatter:off
final Tree timeline = new TestResultTree(
"timeline",
testResult -> groupByLabels(testResult, LabelName.HOST, LabelName.THREAD)
);
// @formatter:on
launchResults.stream()
.map(LaunchResults::getAllResults)
.flatMap(Collection::stream)
.forEach(timeline::add);
return timeline;
}
}