All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.masterthought.cucumber.json.deserializers.OutputsDeserializer Maven / Gradle / Ivy

Go to download

Provides pretty html reports for Cucumber. It works by generating html from the cucumber json file.

There is a newer version: 5.8.2
Show newest version
package net.masterthought.cucumber.json.deserializers;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.databind.JsonNode;

import net.masterthought.cucumber.Configuration;
import net.masterthought.cucumber.json.Output;

public class OutputsDeserializer extends CucumberJsonDeserializer {

    @Override
    protected Output[] deserialize(JsonNode rootNode, Configuration configuration) throws IOException {
        List outputs = new ArrayList<>();
        if (rootNode.get(0).isArray()) {
            for (JsonNode outputNode : rootNode) {
                outputs.add(getOutput(outputNode));
            }
        } else {
            outputs.add(getOutput(rootNode));
        }

        return outputs.toArray(new Output[outputs.size()]);
    }

    private Output getOutput(JsonNode outputNode) {
        List messages = new ArrayList<>();
        for (JsonNode messageNode : outputNode) {
            messages.add(messageNode.asText());
        }
        return new Output(messages.toArray(new String[messages.size()]));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy