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