Coverage Report - org.jbehave.core.reporters.DelegatingStoryReporter
 
Classes in this File Line Coverage Branch Coverage Complexity
DelegatingStoryReporter
100%
76/76
100%
46/46
1.852
 
 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  23
     public DelegatingStoryReporter(Collection<StoryReporter> delegates) {
 29  23
         this.delegates = delegates;
 30  23
     }
 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  5
         this(asList(delegates));
 39  5
     }
 40  
 
 41  
     public void afterScenario() {
 42  9
         for (StoryReporter reporter : delegates) {
 43  11
             reporter.afterScenario();
 44  
         }
 45  9
     }
 46  
 
 47  
     public void afterStory(boolean givenStory) {
 48  11
         for (StoryReporter reporter : delegates) {
 49  19
             reporter.afterStory(givenStory);
 50  
         }
 51  11
     }
 52  
 
 53  
     public void beforeScenario(String scenarioTitle) {
 54  10
         for (StoryReporter reporter : delegates) {
 55  14
             reporter.beforeScenario(scenarioTitle);
 56  
         }
 57  10
     }
 58  
 
 59  
     public void scenarioMeta(Meta meta) {
 60  2
         for (StoryReporter reporter : delegates) {
 61  4
             reporter.scenarioMeta(meta);
 62  
         }
 63  2
     }
 64  
 
 65  
     public void beforeStory(Story story, boolean givenStory) {
 66  11
         for (StoryReporter reporter : delegates) {
 67  19
             reporter.beforeStory(story, givenStory);
 68  
         }
 69  11
     }
 70  
 
 71  
     public void narrative(final Narrative narrative) {
 72  8
         for (StoryReporter reporter : delegates) {
 73  12
             reporter.narrative(narrative);
 74  
         }
 75  8
     }
 76  
 
 77  
     public void beforeExamples(List<String> steps, ExamplesTable table) {
 78  8
         for (StoryReporter reporter : delegates) {
 79  10
             reporter.beforeExamples(steps, table);
 80  
         }
 81  8
     }
 82  
 
 83  
     public void example(Map<String, String> tableRow) {
 84  15
         for (StoryReporter reporter : delegates) {
 85  19
             reporter.example(tableRow);
 86  
         }
 87  15
     }
 88  
 
 89  
     public void afterExamples() {
 90  8
         for (StoryReporter reporter : delegates) {
 91  10
             reporter.afterExamples();
 92  
         }
 93  8
     }
 94  
 
 95  
     public void failed(String step, Throwable cause) {
 96  7
         for (StoryReporter reporter : delegates) {
 97  10
             reporter.failed(step, cause);
 98  
         }
 99  7
     }
 100  
 
 101  
     public void failedOutcomes(String step, OutcomesTable table) {
 102  7
         for (StoryReporter reporter : delegates) {
 103  9
             reporter.failedOutcomes(step, table);
 104  
         }
 105  7
     }
 106  
 
 107  
     public void givenStories(GivenStories givenStories) {
 108  1
         for (StoryReporter reporter : delegates) {
 109  1
             reporter.givenStories(givenStories);
 110  
         }
 111  1
     }
 112  
 
 113  
     public void givenStories(List<String> storyPaths) {
 114  8
         for (StoryReporter reporter : delegates) {
 115  10
             reporter.givenStories(storyPaths);
 116  
         }
 117  8
     }
 118  
 
 119  
     public void ignorable(String step) {
 120  8
         for (StoryReporter reporter : delegates) {
 121  10
             reporter.ignorable(step);
 122  
         }
 123  8
     }
 124  
     
 125  
     public void notPerformed(String step) {
 126  8
         for (StoryReporter reporter : delegates) {
 127  10
             reporter.notPerformed(step);
 128  
         }
 129  8
     }
 130  
 
 131  
     public void pending(String step) {
 132  4
         for (StoryReporter reporter : delegates) {
 133  6
             reporter.pending(step);
 134  
         }
 135  4
     }
 136  
 
 137  
     public void successful(String step) {
 138  24
         for (StoryReporter reporter : delegates) {
 139  30
             reporter.successful(step);
 140  
         }
 141  24
     }
 142  
 
 143  
     public void scenarioNotAllowed(Scenario scenario, String filter) {
 144  1
         for (StoryReporter reporter : delegates) {
 145  1
             reporter.scenarioNotAllowed(scenario, filter);
 146  
         }
 147  1
     }
 148  
 
 149  
     public void storyNotAllowed(Story story, String filter) {
 150  1
         for (StoryReporter reporter : delegates) {
 151  1
             reporter.storyNotAllowed(story, filter);
 152  
         }
 153  1
     }
 154  
         
 155  
     public void dryRun() {
 156  8
         for (StoryReporter reporter : delegates) {
 157  10
             reporter.dryRun();
 158  
         }
 159  8
     }
 160  
     
 161  
     public void pendingMethods(List<String> methods) {
 162  7
         for (StoryReporter reporter : delegates) {
 163  9
             reporter.pendingMethods(methods);
 164  
         }
 165  7
     }
 166  
 
 167  
     public void restarted(String step, Throwable cause) {
 168  7
         for (StoryReporter reporter : delegates) {
 169  9
             reporter.restarted(step, cause);
 170  
         }
 171  7
     }
 172  
 
 173  
     public void storyCancelled(Story story, StoryDuration storyDuration) {
 174  8
         for (StoryReporter reporter : delegates) {
 175  12
             reporter.storyCancelled(story, storyDuration);
 176  
         }
 177  8
     }
 178  
 
 179  
     public Collection<StoryReporter> getDelegates() {
 180  6
         return delegates;
 181  
     }
 182  
 
 183  
     @Override
 184  
     public String toString() {
 185  1
             return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
 186  
     }
 187  
 
 188  
 }