use of org.jbehave.core.model.StoryMap 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.StoryMap 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