use of org.jbehave.core.model.StoryMaps in project jbehave-core by jbehave.
the class EmbedderMonitorBehaviour method shouldAllowDecorationOfDelegate.
@Test
public void shouldAllowDecorationOfDelegate() throws Throwable {
// Given
EmbedderMonitor delegate = mock(EmbedderMonitor.class);
EmbedderMonitor monitor = new EmbedderMonitorDecorator(delegate);
// When
Object annotatedInstance = new Object();
monitor.annotatedInstanceNotOfType(annotatedInstance, annotatedInstance.getClass());
BatchFailures failures = new BatchFailures();
monitor.batchFailed(failures);
monitor.beforeOrAfterStoriesFailed();
String name = "name";
Throwable cause = new Throwable();
monitor.embeddableFailed(name, cause);
monitor.embeddableNotConfigurable(name);
List<String> names = asList("name1");
monitor.embeddablesSkipped(names);
File outputDirectory = new File("target");
StoryMaps storyMaps = mock(StoryMaps.class);
Properties viewProperties = mock(Properties.class);
monitor.generatingMapsView(outputDirectory, storyMaps, viewProperties);
Properties viewResources = mock(Properties.class);
monitor.generatingNavigatorView(outputDirectory, viewResources);
List<String> formats = asList("TXT");
monitor.generatingReportsView(outputDirectory, formats, viewProperties);
String storyPath = "path";
List<String> metaFilters = asList("- skip");
monitor.mappingStory(storyPath, metaFilters);
monitor.mapsViewGenerationFailed(outputDirectory, storyMaps, viewProperties, cause);
Meta meta = mock(Meta.class);
MetaFilter filter = mock(MetaFilter.class);
monitor.metaNotAllowed(meta, filter);
monitor.navigatorViewGenerationFailed(outputDirectory, viewResources, cause);
monitor.navigatorViewNotGenerated();
Properties properties = mock(Properties.class);
monitor.processingSystemProperties(properties);
ReportsCount count = mock(ReportsCount.class);
monitor.reportsViewGenerated(count);
monitor.reportsViewGenerationFailed(outputDirectory, formats, viewProperties, cause);
monitor.reportsViewNotGenerated();
monitor.runningEmbeddable(name);
monitor.runningStory(storyPath);
monitor.runningWithAnnotatedEmbedderRunner(name);
List<String> storyPaths = asList("path1");
monitor.storiesSkipped(storyPaths);
monitor.storyFailed(storyPath, cause);
Story story = mock(Story.class);
long durationInSecs = 1L;
long timeoutInSecs = 2L;
StoryDuration storyDuration = new StoryDuration(timeoutInSecs);
monitor.storyTimeout(story, storyDuration);
String value = "value";
monitor.systemPropertySet(name, value);
int threads = 2;
monitor.usingThreads(threads);
// Then
verify(delegate).annotatedInstanceNotOfType(annotatedInstance, annotatedInstance.getClass());
verify(delegate).batchFailed(failures);
verify(delegate).beforeOrAfterStoriesFailed();
verify(delegate).embeddableFailed(name, cause);
verify(delegate).embeddableNotConfigurable(name);
verify(delegate).embeddablesSkipped(names);
verify(delegate).generatingMapsView(outputDirectory, storyMaps, viewProperties);
verify(delegate).generatingNavigatorView(outputDirectory, viewResources);
verify(delegate).generatingReportsView(outputDirectory, formats, viewProperties);
verify(delegate).mappingStory(storyPath, metaFilters);
verify(delegate).mapsViewGenerationFailed(outputDirectory, storyMaps, viewProperties, cause);
verify(delegate).metaNotAllowed(meta, filter);
verify(delegate).navigatorViewGenerationFailed(outputDirectory, viewResources, cause);
verify(delegate).navigatorViewNotGenerated();
verify(delegate).processingSystemProperties(properties);
verify(delegate).reportsViewGenerated(count);
verify(delegate).reportsViewGenerationFailed(outputDirectory, formats, viewProperties, cause);
verify(delegate).reportsViewNotGenerated();
verify(delegate).storiesSkipped(storyPaths);
verify(delegate).storyFailed(storyPath, cause);
verify(delegate).storyTimeout(story, storyDuration);
verify(delegate).systemPropertySet(name, value);
verify(delegate).usingThreads(threads);
}
use of org.jbehave.core.model.StoryMaps in project jbehave-core by jbehave.
the class EmbedderBehaviour method shouldMapStoriesAsPaths.
@SuppressWarnings("unchecked")
@Test
public void shouldMapStoriesAsPaths() throws Throwable {
// Given
StoryMapper mapper = mock(StoryMapper.class);
PerformableTree performableTree = mock(PerformableTree.class);
EmbedderControls embedderControls = new EmbedderControls();
OutputStream out = new ByteArrayOutputStream();
EmbedderMonitor monitor = new PrintStreamEmbedderMonitor(new PrintStream(out));
Embedder embedder = embedderWith(mapper, performableTree, embedderControls, monitor);
Configuration configuration = embedder.configuration();
List<? extends Class<? extends Embeddable>> embeddables = asList(MyStory.class, MyOtherEmbeddable.class);
StoryPathResolver resolver = configuration.storyPathResolver();
List<String> storyPaths = new ArrayList<>();
Map<String, Story> stories = new HashMap<>();
for (Class<? extends Embeddable> embeddable : embeddables) {
String storyPath = resolver.resolve(embeddable);
storyPaths.add(storyPath);
Story story = new Story(storyPath);
stories.put(storyPath, story);
when(performableTree.storyOfPath(configuration, storyPath)).thenReturn(story);
}
// When
List<StoryMap> maps = asList(new StoryMap("filter", new HashSet<>(stories.values())));
StoryMaps storyMaps = new StoryMaps(maps);
when(mapper.getStoryMaps()).thenReturn(storyMaps);
embedder.mapStoriesAsPaths(storyPaths);
// Then
for (String storyPath : storyPaths) {
verify(mapper).map(Matchers.eq(stories.get(storyPath)), Matchers.any(MetaFilter.class));
assertThat(out.toString(), containsString("Mapping story " + storyPath));
}
assertThatMapsViewGenerated(out);
}
use of org.jbehave.core.model.StoryMaps in project jbehave-core by jbehave.
the class StoryMapperBehaviour method shouldMapStoriesAllowedByFilter.
@Test
public void shouldMapStoriesAllowedByFilter() throws Throwable {
// Given
Meta meta1 = mock(Meta.class, "meta1");
Story story1 = new Story("/path/to/story1", Description.EMPTY, meta1, Narrative.EMPTY, asList(new Scenario("scenario1", meta1)));
Meta meta2 = mock(Meta.class, "meta2");
Story story2 = new Story("/path/to/story2", Description.EMPTY, meta2, Narrative.EMPTY, asList(new Scenario("scenario2", meta2)));
MetaFilter filter = mock(MetaFilter.class);
String filterAsString = "-some property";
// When
StoryMapper mapper = new StoryMapper();
when(meta1.inheritFrom(meta1)).thenReturn(meta1);
when(meta2.inheritFrom(meta2)).thenReturn(meta2);
when(filter.allow(meta1)).thenReturn(false);
when(filter.allow(meta2)).thenReturn(true);
when(filter.asString()).thenReturn(filterAsString);
mapper.map(story1, filter);
mapper.map(story2, filter);
// Then
StoryMaps storyMaps = mapper.getStoryMaps();
assertThat(storyMaps.getMaps().size(), equalTo(1));
StoryMap storyMap = storyMaps.getMap(filterAsString);
assertThat(storyMap.getMetaFilter(), equalTo(filterAsString));
assertThat(storyMap.getStories().get(0).getPath(), equalTo(story2.getPath()));
assertThat(storyMap.getStoryPaths(), equalTo(asList(story2.getPath())));
}
Aggregations