io.qameta.allure.timeline.TimelinePlugin Maven / Gradle / Ivy
package io.qameta.allure.timeline;
import io.qameta.allure.CommonJsonAggregator;
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 CommonJsonAggregator {
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::getResults)
.flatMap(Collection::stream)
.forEach(timeline::add);
return timeline;
}
}