##### Coverage Report - org.jbehave.core.embedder.FilteredStory

Classes in this File | Line Coverage | Branch Coverage | Complexity
FilteredStory |
100% | 14/14
83% | 5/6
| 1.6666666666666667;1.667

1 |  |
     package org.jbehave.core.embedder;
2 |  |
3 |  |
     import java.util.HashMap;
4 |  |
     import java.util.Map;
5 |  |
6 |  |
     import org.jbehave.core.model.Meta;
7 |  |
     import org.jbehave.core.model.Scenario;
8 |  |
     import org.jbehave.core.model.Story;
9 |  |
10 |  |
     public class FilteredStory {
11 |  |
12 |  |
         private boolean storyAllowed;
13 |  |
         private Map<Scenario, Boolean> scenariosAllowed;
14 |  |
15 | 45 |
         public FilteredStory(MetaFilter filter, Story story, StoryControls storyControls) {
16 | 45 |
             String storyMetaPrefix = storyControls.storyMetaPrefix();
17 | 45 |
             String scenarioMetaPrefix = storyControls.scenarioMetaPrefix();
18 | 45 |
             Meta storyMeta = story.getMeta().inheritFrom(story.asMeta(storyMetaPrefix));
19 | 44 |
             storyAllowed = filter.allow(storyMeta);
20 | 44 |
             scenariosAllowed = new HashMap<Scenario, Boolean>();
21 | 44 |
             for (Scenario scenario : story.getScenarios()) {
22 | 32 |
                 Meta scenarioMeta = scenario.getMeta().inheritFrom(
23 |  |
                         scenario.asMeta(scenarioMetaPrefix).inheritFrom(storyMeta));
24 | 32 |
                 boolean scenarioAllowed = filter.allow(scenarioMeta);
25 | 32 |
                 scenariosAllowed.put(scenario, scenarioAllowed);
26 | 32 |
             }
27 | 44 |
         }
28 |  |
29 |  |
         public boolean allowed() {
30 | 44 |
             return storyAllowed || scenariosAllowed.values().contains(true);
31 |  |
         }
32 |  |
33 |  |
         public boolean allowed(Scenario scenario) {
34 | 27 |
             return scenariosAllowed.get(scenario);
35 |  |
         }
36 |  |
     }