io.qameta.allure.graph.GraphPlugin 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.
package io.qameta.allure.graph;
import io.qameta.allure.Aggregator;
import io.qameta.allure.context.JacksonContext;
import io.qameta.allure.core.Configuration;
import io.qameta.allure.core.LaunchResults;
import io.qameta.allure.entity.TestResult;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Collectors;
/**
* Plugin that generates data for Graph tab.
*
* @since 2.0
*/
public class GraphPlugin implements Aggregator {
@Override
public void aggregate(final Configuration configuration,
final List launchesResults,
final Path outputDirectory) throws IOException {
final JacksonContext context = configuration.requireContext(JacksonContext.class);
final Path dataFolder = Files.createDirectories(outputDirectory.resolve("data"));
final Path graphFile = dataFolder.resolve("graph.json");
final List data = launchesResults.stream()
.flatMap(launch -> launch.getResults().stream())
.map(this::createData)
.collect(Collectors.toList());
try (OutputStream os = Files.newOutputStream(graphFile)) {
context.getValue().writeValue(os, data);
}
}
private GraphData createData(final TestResult result) {
return new GraphData()
.withUid(result.getUid())
.withName(result.getName())
.withStatus(result.getStatus())
.withTime(result.getTime())
.withSeverity(result.getExtraBlock("severity"));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy