Coverage Report - org.jbehave.core.embedder.FilteredStory
 
Classes in this File Line Coverage Branch Coverage Complexity
FilteredStory
100%
14/14
83%
5/6
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  42
     public FilteredStory(MetaFilter filter, Story story, StoryControls storyControls) {
 16  42
         String storyMetaPrefix = storyControls.storyMetaPrefix();
 17  42
         String scenarioMetaPrefix = storyControls.scenarioMetaPrefix();
 18  42
         Meta storyMeta = story.getMeta().inheritFrom(story.asMeta(storyMetaPrefix));
 19  41
         storyAllowed = filter.allow(storyMeta);
 20  41
         scenariosAllowed = new HashMap<Scenario, Boolean>();
 21  41
         for (Scenario scenario : story.getScenarios()) {
 22  29
             Meta scenarioMeta = scenario.getMeta().inheritFrom(
 23  
                     scenario.asMeta(scenarioMetaPrefix).inheritFrom(storyMeta));
 24  29
             boolean scenarioAllowed = filter.allow(scenarioMeta);
 25  29
             scenariosAllowed.put(scenario, scenarioAllowed);
 26  29
         }
 27  41
     }
 28  
 
 29  
     public boolean allowed() {
 30  41
         return storyAllowed || scenariosAllowed.values().contains(true);
 31  
     }
 32  
 
 33  
     public boolean allowed(Scenario scenario) {
 34  25
         return scenariosAllowed.get(scenario);
 35  
     }
 36  
 }