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