package au.com.nsqa.story.etl;

import au.com.nsqa.step.etl.SystemIntegrationSteps;
import org.jbehave.scenario.JUnitScenario;
import org.jbehave.scenario.MostUsefulConfiguration;
import org.jbehave.scenario.parser.*;
import org.jbehave.scenario.reporters.FilePrintStreamFactory;
import org.jbehave.scenario.reporters.ScenarioReporter;
import org.jbehave.scenario.reporters.ScenarioReporterBuilder;
import org.jbehave.scenario.steps.CandidateSteps;
import org.jbehave.scenario.steps.StepsFactory;

import static org.jbehave.scenario.reporters.ScenarioReporterBuilder.Format.*;

public class SystemIntegration extends JUnitScenario {

    private static ScenarioNameResolver resolver = new UnderscoredCamelCaseResolver(".story");

    public SystemIntegration() {
        super(new MostUsefulConfiguration() {
            @Override
            public ScenarioDefiner forDefiningScenarios() {
                return new ClasspathScenarioDefiner(resolver, new PatternScenarioParser(keywords()));
            }

            @Override
            public ScenarioReporter forReportingScenarios() {
                return new ScenarioReporterBuilder(new FilePrintStreamFactory(SystemIntegration.class, resolver))
//                        .outputTo("/Users/bensullivan/tmp/jbehave-reports")
                        .outputTo("gen/jbehave-reports")
                        .outputAsAbsolute(true)
                        .with(CONSOLE) // report to System.out
                        .with(HTML)    // report to .html file in HTML format
                        .with(STATS)   
                        .build();
            }
        });
        addSteps(createSteps());
    }

    protected CandidateSteps[] createSteps() {
        return new StepsFactory().createCandidateSteps(new SystemIntegrationSteps());
    }
}