Java Code Examples for io.qameta.allure.core.Configuration#requireContext()

The following examples show how to use io.qameta.allure.core.Configuration#requireContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Allure1Plugin.java    From allure2 with Apache License 2.0 6 votes vote down vote up
@Override
public void readResults(final Configuration configuration,
                        final ResultsVisitor visitor,
                        final Path resultsDirectory) {
    final Properties allureProperties = loadAllureProperties(resultsDirectory);
    final RandomUidContext context = configuration.requireContext(RandomUidContext.class);

    final Map<String, String> environment = processEnvironment(resultsDirectory);
    getStreamOfAllure1Results(resultsDirectory).forEach(testSuite -> testSuite.getTestCases()
            .forEach(testCase -> {
                convert(context.getValue(), resultsDirectory, visitor, testSuite, testCase, allureProperties);
                getEnvironmentParameters(testCase).forEach(param ->
                        environment.put(param.getName(), param.getValue())
                );
            })
    );

    visitor.visitExtra(ENVIRONMENT_BLOCK_NAME, environment);
}
 
Example 2
Source File: CommonJsonAggregator.java    From allure2 with Apache License 2.0 5 votes vote down vote up
@Override
public void aggregate(final Configuration configuration,
                      final List<LaunchResults> launchesResults,
                      final Path outputDirectory) throws IOException {
    final JacksonContext jacksonContext = configuration.requireContext(JacksonContext.class);
    final Path dataFolder = Files.createDirectories(outputDirectory.resolve(this.location));
    final Path dataFile = dataFolder.resolve(this.fileName);
    try (OutputStream os = Files.newOutputStream(dataFile)) {
        jacksonContext.getValue().writeValue(os, getData(launchesResults));
    }
}
 
Example 3
Source File: LaunchPlugin.java    From allure2 with Apache License 2.0 5 votes vote down vote up
@Override
public void readResults(final Configuration configuration,
                        final ResultsVisitor visitor,
                        final Path directory) {
    final JacksonContext context = configuration.requireContext(JacksonContext.class);
    final Path executorFile = directory.resolve(JSON_FILE_NAME);
    if (Files.exists(executorFile)) {
        try (InputStream is = Files.newInputStream(executorFile)) {
            final LaunchInfo info = context.getValue().readValue(is, LaunchInfo.class);
            visitor.visitExtra(LAUNCH_BLOCK_NAME, info);
        } catch (IOException e) {
            visitor.error("Could not read launch file " + executorFile, e);
        }
    }
}
 
Example 4
Source File: Allure2Plugin.java    From allure2 with Apache License 2.0 5 votes vote down vote up
@Override
public void readResults(final Configuration configuration,
                        final ResultsVisitor visitor,
                        final Path resultsDirectory) {
    final RandomUidContext context = configuration.requireContext(RandomUidContext.class);
    final List<TestResultContainer> groups = readTestResultsContainers(resultsDirectory)
            .collect(Collectors.toList());

    readTestResults(resultsDirectory)
            .forEach(result -> convert(context.getValue(), resultsDirectory, visitor, groups, result));
}
 
Example 5
Source File: AbstractTrendPlugin.java    From allure2 with Apache License 2.0 5 votes vote down vote up
@Override
public void readResults(final Configuration configuration,
                        final ResultsVisitor visitor,
                        final Path directory) {
    final JacksonContext context = configuration.requireContext(JacksonContext.class);
    final Path historyFile = directory.resolve(Constants.HISTORY_DIR).resolve(jsonFileName);

    if (Files.exists(historyFile)) {
        try (InputStream is = Files.newInputStream(historyFile)) {
            final ObjectMapper mapper = context.getValue();
            final JsonNode jsonNode = mapper.readTree(is);
            final List<T> history;
            if (jsonNode != null) {
                history = getStream(jsonNode)
                        .map(child -> parseItem(historyFile, mapper, child))
                        .filter(Optional::isPresent)
                        .map(Optional::get)
                        .collect(Collectors.toList());
            } else {
                history = Collections.emptyList();
            }

            visitor.visitExtra(trendBlockName, history);
        } catch (IOException e) {
            visitor.error("Could not read " + trendBlockName + " file " + historyFile, e);
        }
    }
}
 
Example 6
Source File: MailPlugin.java    From allure2 with Apache License 2.0 5 votes vote down vote up
@Override
public void aggregate(final Configuration configuration,
                      final List<LaunchResults> launchesResults,
                      final Path outputDirectory) throws IOException {
    final FreemarkerContext context = configuration.requireContext(FreemarkerContext.class);
    final Path exportFolder = Files.createDirectories(outputDirectory.resolve(Constants.EXPORT_DIR));
    final Path mailFile = exportFolder.resolve("mail.html");
    try (BufferedWriter writer = Files.newBufferedWriter(mailFile)) {
        final Template template = context.getValue().getTemplate("mail.html.ftl");
        template.process(new HashMap<>(), writer);
    } catch (TemplateException e) {
        LOGGER.error("Could't write mail file", e);
    }
}
 
Example 7
Source File: CategoriesPlugin.java    From allure2 with Apache License 2.0 5 votes vote down vote up
@Override
public void readResults(final Configuration configuration,
                        final ResultsVisitor visitor,
                        final Path directory) {
    final JacksonContext context = configuration.requireContext(JacksonContext.class);
    final Path categoriesFile = directory.resolve(JSON_FILE_NAME);
    if (Files.exists(categoriesFile)) {
        try (InputStream is = Files.newInputStream(categoriesFile)) {
            final List<Category> categories = context.getValue().readValue(is, CATEGORIES_TYPE);
            visitor.visitExtra(CATEGORIES, categories);
        } catch (IOException e) {
            visitor.error("Could not read categories file " + categoriesFile, e);
        }
    }
}
 
Example 8
Source File: ExecutorPlugin.java    From allure2 with Apache License 2.0 5 votes vote down vote up
@Override
public void readResults(final Configuration configuration,
                        final ResultsVisitor visitor,
                        final Path directory) {
    final JacksonContext context = configuration.requireContext(JacksonContext.class);
    final Path executorFile = directory.resolve(JSON_FILE_NAME);
    if (Files.exists(executorFile)) {
        try (InputStream is = Files.newInputStream(executorFile)) {
            final ExecutorInfo info = context.getValue().readValue(is, ExecutorInfo.class);
            visitor.visitExtra(EXECUTORS_BLOCK_NAME, info);
        } catch (IOException e) {
            visitor.error("Could not read executor file " + executorFile, e);
        }
    }
}
 
Example 9
Source File: HistoryPlugin.java    From allure2 with Apache License 2.0 5 votes vote down vote up
@Override
public void readResults(final Configuration configuration,
                        final ResultsVisitor visitor,
                        final Path directory) {
    final JacksonContext context = configuration.requireContext(JacksonContext.class);
    final Path historyFile = directory.resolve(HISTORY_BLOCK_NAME).resolve(HISTORY_FILE_NAME);
    if (Files.exists(historyFile)) {
        try (InputStream is = Files.newInputStream(historyFile)) {
            final Map<String, HistoryData> history = context.getValue().readValue(is, HISTORY_TYPE);
            visitor.visitExtra(HISTORY_BLOCK_NAME, history);
        } catch (IOException e) {
            visitor.error("Could not read history file " + historyFile, e);
        }
    }
}
 
Example 10
Source File: HistoryPlugin.java    From allure2 with Apache License 2.0 5 votes vote down vote up
@Override
public void aggregate(final Configuration configuration,
                      final List<LaunchResults> launchesResults,
                      final Path outputDirectory) throws IOException {
    final JacksonContext context = configuration.requireContext(JacksonContext.class);
    final Path historyFolder = Files.createDirectories(outputDirectory.resolve(HISTORY_BLOCK_NAME));
    final Path historyFile = historyFolder.resolve(HISTORY_FILE_NAME);
    try (OutputStream os = Files.newOutputStream(historyFile)) {
        context.getValue().writeValue(os, getData(launchesResults));
    }
}
 
Example 11
Source File: XunitXmlPlugin.java    From allure2 with Apache License 2.0 5 votes vote down vote up
@Override
public void readResults(final Configuration configuration,
                        final ResultsVisitor visitor,
                        final Path directory) {
    final RandomUidContext context = configuration.requireContext(RandomUidContext.class);
    listResults(directory).forEach(result -> parseAssemblies(result, context, visitor));
}
 
Example 12
Source File: TrxPlugin.java    From allure2 with Apache License 2.0 5 votes vote down vote up
@Override
public void readResults(final Configuration configuration,
                        final ResultsVisitor visitor,
                        final Path directory) {
    final RandomUidContext context = configuration.requireContext(RandomUidContext.class);
    listResults(directory).forEach(result -> parseTestRun(result, context, visitor));
}
 
Example 13
Source File: PackagesPlugin.java    From allure2 with Apache License 2.0 5 votes vote down vote up
@Override
public void aggregate(final Configuration configuration,
                      final List<LaunchResults> launchesResults,
                      final Path outputDirectory) throws IOException {
    final JacksonContext jacksonContext = configuration.requireContext(JacksonContext.class);
    final Path dataFolder = Files.createDirectories(outputDirectory.resolve("data"));
    final Path dataFile = dataFolder.resolve("packages.json");
    try (OutputStream os = Files.newOutputStream(dataFile)) {
        jacksonContext.getValue().writeValue(os, getData(launchesResults));
    }
}
 
Example 14
Source File: JunitXmlPlugin.java    From allure2 with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
@Override
public void readResults(final Configuration configuration, final ResultsVisitor visitor, final Path directory) {
    final RandomUidContext context = configuration.requireContext(RandomUidContext.class);
    listResults(directory).forEach(result -> parseRootElement(directory, result, context, visitor));
}