/**
 * 
 */
package com.tibco.emea.ems.scenario;

import java.util.List;

import org.jbehave.core.annotations.Configure;
import org.jbehave.core.annotations.UsingEmbedder;
import org.jbehave.core.annotations.UsingSteps;
import org.jbehave.core.annotations.spring.UsingSpring;
import org.jbehave.core.configuration.Configuration;
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.embedder.Embedder;
import org.jbehave.core.io.CodeLocations;
import org.jbehave.core.io.LoadFromClasspath;
import org.jbehave.core.io.StoryFinder;
import org.jbehave.core.junit.JUnitStories;
import org.jbehave.core.junit.spring.SpringAnnotatedEmbedderRunner;
import org.jbehave.core.reporters.StoryReporterBuilder;
import org.jbehave.core.steps.CandidateSteps;
import org.jbehave.core.steps.InstanceStepsFactory;
import org.junit.runner.RunWith;

import com.tibco.emea.ems.steps.CalculatorSteps;

/**
 * @author mrzedzic
 * 
 */
@RunWith(SpringAnnotatedEmbedderRunner.class)
@Configure
@UsingEmbedder(embedder = Embedder.class, generateViewAfterStories = true, ignoreFailureInStories = false, ignoreFailureInView = false, stepsFactory = true)
@UsingSpring(resources = "classpath:applicationContext-jbehave.xml")
@UsingSteps
public class CalculatorScenario extends JUnitStories {
	
	protected List<String> storyPaths() {

		return new StoryFinder().findPaths(
				CodeLocations.codeLocationFromPath("./target/test-classes/"),
				"*.story", "");
	}

	@Override
	public List<CandidateSteps> candidateSteps() {
		// varargs, can have more that one steps classes
		return new InstanceStepsFactory(configuration(), new CalculatorSteps()).createCandidateSteps();
	}

	@Override
	public Configuration configuration() {
		return new MostUsefulConfiguration()
				// where to find the stories
				.useStoryLoader(new LoadFromClasspath(this.getClass()))
				.useStoryReporterBuilder(
						new StoryReporterBuilder().withDefaultFormats()
								.withFormats(
										StoryReporterBuilder.Format.CONSOLE,
										StoryReporterBuilder.Format.XML));
	}

}

@@ -1,19 +1,4 @@
-/**%0D%0A * %0D%0A */%0D%0A
 pack
@@ -55,24 +55,61 @@
 il.List;%0D%0A%0D%0A
+import javax.annotation.Resource;%0D%0A%0D%0A
 import org.j
@@ -412,32 +412,106 @@
 Configuration;%0D%0A
+import org.jbehave.core.configuration.spring.SpringStoryReporterBuilder;%0D%0A
 import org.jbeha
@@ -787,65 +787,8 @@
 r;%0D%0A
-import org.jbehave.core.reporters.StoryReporterBuilder;%0D%0A
 impo
@@ -916,16 +916,148 @@
 unWith;%0D
+%0Aimport org.springframework.context.ApplicationContext;%0D%0Aimport org.springframework.context.support.ClassPathXmlApplicationContext;%0D
 %0A%0D%0Aimpor
@@ -1498,16 +1498,363 @@
 s %7B%0D%0A%09%0D%0A
+%09@Resource(name = %22storyReportBulder%22)%0D%0A%09private SpringStoryReporterBuilder storyReportBulder;%0D%0A%09%0D%0A%09public CalculatorScenario() %7B%0D%0A%09%09ApplicationContext context = new ClassPathXmlApplicationContext(%22classpath:applicationContext-jbehave.xml%22);%0D%0A%09%09storyReportBulder = context.getBean(%22storyReportBulder%22, SpringStoryReporterBuilder.class);%0D%0A%09%7D%0D%0A%09%0D%0A%0D%0A
 %09protect
@@ -1885,18 +1885,16 @@
 hs() %7B%0D%0A
-%0D%0A
 %09%09return
@@ -2010,32 +2010,35 @@
 y%22, %22%22);%0D%0A%09%7D%0D%0A%0D%0A
+%09%0D%0A
 %09@Override%0D%0A%09pub
@@ -2239,16 +2239,51 @@
 %0D%0A%09%7D%0D%0A%0D%0A
+%09@SuppressWarnings(%22deprecation%22)%0D%0A
 %09@Overri
@@ -2495,147 +2495,34 @@
 der(
-%0D%0A%09%09%09%09%09%09new StoryReporterBuilder().withDefaultFormats()%0D%0A%09%09%09%09%09%09%09%09.withFormats(%0D%0A%09%09%09%09%09%09%09%09%09%09StoryReporterBuilder.Format.CONSOLE,%0D%0A%09%09%09%09%09%09%09%09%09%09S
+new CalculatorScenario().s
 tory
@@ -2531,29 +2531,14 @@
 port
-er
 Bu
-i
 lder
-.Format.XML)
 );%0D%0A

update class to use spring bean