Coverage Report - org.jbehave.core.reporters.DelegatingStoryReporter
 
Classes in this File Line Coverage Branch Coverage Complexity
DelegatingStoryReporter
100%
64/64
100%
38/38
1.826
 
 1  
 package org.jbehave.core.reporters;
 2  
 
 3  
 import static java.util.Arrays.asList;
 4  
 
 5  
 import java.util.Collection;
 6  
 import java.util.List;
 7  
 import java.util.Map;
 8  
 
 9  
 import org.apache.commons.lang.builder.ToStringBuilder;
 10  
 import org.apache.commons.lang.builder.ToStringStyle;
 11  
 import org.jbehave.core.model.ExamplesTable;
 12  
 import org.jbehave.core.model.GivenStories;
 13  
 import org.jbehave.core.model.Meta;
 14  
 import org.jbehave.core.model.OutcomesTable;
 15  
 import org.jbehave.core.model.Scenario;
 16  
 import org.jbehave.core.model.Story;
 17  
 
 18  
 /**
 19  
  * Reporter which collects other {@link StoryReporter}s and delegates all
 20  
  * invocations to the collected reporters.
 21  
  * 
 22  
  * @author Mirko FriedenHagen
 23  
  */
 24  
 public class DelegatingStoryReporter implements StoryReporter {
 25  
 
 26  
     private final Collection<StoryReporter> delegates;
 27  
 
 28  
     /**
 29  
      * Creates DelegatingStoryReporter with a given collections of delegates
 30  
      * 
 31  
      * @param delegates the ScenarioReporters to delegate to
 32  
      */
 33  39
     public DelegatingStoryReporter(Collection<StoryReporter> delegates) {
 34  39
         this.delegates = delegates;
 35  39
     }
 36  
 
 37  
     /**
 38  
      * Creates DelegatingStoryReporter with a given varargs of delegates
 39  
      * 
 40  
      * @param delegates the StoryReporters to delegate to
 41  
      */
 42  
     public DelegatingStoryReporter(StoryReporter... delegates) {
 43  1
         this(asList(delegates));
 44  1
     }
 45  
 
 46  
     public void afterScenario() {
 47  5
         for (StoryReporter reporter : delegates) {
 48  7
             reporter.afterScenario();
 49  
         }
 50  5
     }
 51  
 
 52  
     public void afterStory(boolean givenStory) {
 53  4
         for (StoryReporter reporter : delegates) {
 54  6
             reporter.afterStory(givenStory);
 55  
         }
 56  4
     }
 57  
 
 58  
     public void beforeScenario(String scenarioTitle) {
 59  5
         for (StoryReporter reporter : delegates) {
 60  7
             reporter.beforeScenario(scenarioTitle);
 61  
         }
 62  5
     }
 63  
 
 64  
     public void scenarioMeta(Meta meta) {
 65  1
         for (StoryReporter reporter : delegates) {
 66  1
             reporter.scenarioMeta(meta);
 67  
         }
 68  1
     }
 69  
 
 70  
     public void beforeStory(Story story, boolean givenStory) {
 71  4
         for (StoryReporter reporter : delegates) {
 72  6
             reporter.beforeStory(story, givenStory);
 73  
         }
 74  4
     }
 75  
 
 76  
     public void beforeExamples(List<String> steps, ExamplesTable table) {
 77  4
         for (StoryReporter reporter : delegates) {
 78  6
             reporter.beforeExamples(steps, table);
 79  
         }
 80  4
     }
 81  
 
 82  
     public void example(Map<String, String> tableRow) {
 83  7
         for (StoryReporter reporter : delegates) {
 84  11
             reporter.example(tableRow);
 85  
         }
 86  7
     }
 87  
 
 88  
     public void afterExamples() {
 89  4
         for (StoryReporter reporter : delegates) {
 90  6
             reporter.afterExamples();
 91  
         }
 92  4
     }
 93  
 
 94  
     public void failed(String step, Throwable cause) {
 95  2
         for (StoryReporter reporter : delegates) {
 96  3
             reporter.failed(step, cause);
 97  
         }
 98  2
     }
 99  
 
 100  
     public void failedOutcomes(String step, OutcomesTable table) {
 101  3
         for (StoryReporter reporter : delegates) {
 102  5
             reporter.failedOutcomes(step, table);
 103  
         }
 104  3
     }
 105  
 
 106  
     public void givenStories(GivenStories givenStories) {
 107  1
         for (StoryReporter reporter : delegates) {
 108  1
             reporter.givenStories(givenStories);
 109  
         }
 110  1
     }
 111  
 
 112  
     public void givenStories(List<String> storyPaths) {
 113  4
         for (StoryReporter reporter : delegates) {
 114  6
             reporter.givenStories(storyPaths);
 115  
         }
 116  4
     }
 117  
 
 118  
     public void ignorable(String step) {
 119  4
         for (StoryReporter reporter : delegates) {
 120  6
             reporter.ignorable(step);
 121  
         }
 122  4
     }
 123  
     
 124  
     public void notPerformed(String step) {
 125  4
         for (StoryReporter reporter : delegates) {
 126  6
             reporter.notPerformed(step);
 127  
         }
 128  4
     }
 129  
 
 130  
     public void pending(String step) {
 131  4
         for (StoryReporter reporter : delegates) {
 132  6
             reporter.pending(step);
 133  
         }
 134  4
     }
 135  
 
 136  
     public void successful(String step) {
 137  12
         for (StoryReporter reporter : delegates) {
 138  18
             reporter.successful(step);
 139  
         }
 140  12
     }
 141  
 
 142  
         public void dryRun() {
 143  4
         for (StoryReporter reporter : delegates) {
 144  6
             reporter.dryRun();
 145  
         }
 146  4
         }
 147  
         
 148  
     public void scenarioNotAllowed(Scenario scenario, String filter) {
 149  1
         for (StoryReporter reporter : delegates) {
 150  1
             reporter.scenarioNotAllowed(scenario, filter);
 151  
         }
 152  1
     }
 153  
 
 154  
     public void storyNotAllowed(Story story, String filter) {
 155  1
         for (StoryReporter reporter : delegates) {
 156  1
             reporter.storyNotAllowed(story, filter);
 157  
         }
 158  1
     }
 159  
         
 160  
     public Collection<StoryReporter> getDelegates() {
 161  4
         return delegates;
 162  
     }
 163  
 
 164  
     @Override
 165  
     public String toString() {
 166  1
             return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
 167  
     }
 168  
 
 169  
 }