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