##### Coverage Report - org.jbehave.core.reporters.DelegatingStoryReporter

Classes in this File | Line Coverage | Branch Coverage | Complexity
DelegatingStoryReporter |
100% | 79/79
100% | 48/48
| 1.8571428571428572;1.857

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 | 24 |
         public DelegatingStoryReporter(Collection<StoryReporter> delegates) {
29 | 24 |
             this.delegates = delegates;
30 | 24 |
         }
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 | 17 |
             for (StoryReporter reporter : delegates) {
43 | 23 |
                 reporter.afterScenario();
44 |  |
             }
45 | 17 |
         }
46 |  |
47 |  |
         public void afterStory(boolean givenStory) {
48 | 12 |
             for (StoryReporter reporter : delegates) {
49 | 22 |
                 reporter.afterStory(givenStory);
50 |  |
             }
51 | 12 |
         }
52 |  |
53 |  |
         public void beforeScenario(String scenarioTitle) {
54 | 18 |
             for (StoryReporter reporter : delegates) {
55 | 26 |
                 reporter.beforeScenario(scenarioTitle);
56 |  |
             }
57 | 18 |
         }
58 |  |
59 |  |
         public void scenarioMeta(Meta meta) {
60 | 3 |
             for (StoryReporter reporter : delegates) {
61 | 7 |
                 reporter.scenarioMeta(meta);
62 |  |
             }
63 | 3 |
         }
64 |  |
65 |  |
         public void beforeStory(Story story, boolean givenStory) {
66 | 12 |
             for (StoryReporter reporter : delegates) {
67 | 22 |
                 reporter.beforeStory(story, givenStory);
68 |  |
             }
69 | 12 |
         }
70 |  |
71 |  |
         public void narrative(final Narrative narrative) {
72 | 9 |
             for (StoryReporter reporter : delegates) {
73 | 15 |
                 reporter.narrative(narrative);
74 |  |
             }
75 | 9 |
         }
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 | 11 |
             for (StoryReporter reporter : delegates) {
97 | 14 |
                 reporter.failed(step, cause);
98 |  |
             }
99 | 11 |
         }
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 beforeStep(String step) {
120 | 1 |
             for (StoryReporter reporter : delegates) {
121 | 3 |
                 reporter.beforeStep(step);
122 |  |
             }
123 | 1 |
         }
124 |  |
125 |  |
         public void ignorable(String step) {
126 | 8 |
             for (StoryReporter reporter : delegates) {
127 | 10 |
                 reporter.ignorable(step);
128 |  |
             }
129 | 8 |
         }
130 |  |
131 |  |
         public void notPerformed(String step) {
132 | 8 |
             for (StoryReporter reporter : delegates) {
133 | 10 |
                 reporter.notPerformed(step);
134 |  |
             }
135 | 8 |
         }
136 |  |
137 |  |
         public void pending(String step) {
138 | 7 |
             for (StoryReporter reporter : delegates) {
139 | 11 |
                 reporter.pending(step);
140 |  |
             }
141 | 7 |
         }
142 |  |
143 |  |
         public void successful(String step) {
144 | 80 |
             for (StoryReporter reporter : delegates) {
145 | 102 |
                 reporter.successful(step);
146 |  |
             }
147 | 80 |
         }
148 |  |
149 |  |
         public void scenarioNotAllowed(Scenario scenario, String filter) {
150 | 1 |
             for (StoryReporter reporter : delegates) {
151 | 1 |
                 reporter.scenarioNotAllowed(scenario, filter);
152 |  |
             }
153 | 1 |
         }
154 |  |
155 |  |
         public void storyNotAllowed(Story story, String filter) {
156 | 1 |
             for (StoryReporter reporter : delegates) {
157 | 1 |
                 reporter.storyNotAllowed(story, filter);
158 |  |
             }
159 | 1 |
         }
160 |  |
161 |  |
         public void dryRun() {
162 | 8 |
             for (StoryReporter reporter : delegates) {
163 | 10 |
                 reporter.dryRun();
164 |  |
             }
165 | 8 |
         }
166 |  |
167 |  |
         public void pendingMethods(List<String> methods) {
168 | 7 |
             for (StoryReporter reporter : delegates) {
169 | 9 |
                 reporter.pendingMethods(methods);
170 |  |
             }
171 | 7 |
         }
172 |  |
173 |  |
         public void restarted(String step, Throwable cause) {
174 | 7 |
             for (StoryReporter reporter : delegates) {
175 | 9 |
                 reporter.restarted(step, cause);
176 |  |
             }
177 | 7 |
         }
178 |  |
179 |  |
         public void storyCancelled(Story story, StoryDuration storyDuration) {
180 | 8 |
             for (StoryReporter reporter : delegates) {
181 | 12 |
                 reporter.storyCancelled(story, storyDuration);
182 |  |
             }
183 | 8 |
         }
184 |  |
185 |  |
         public Collection<StoryReporter> getDelegates() {
186 | 6 |
             return delegates;
187 |  |
         }
188 |  |
189 |  |
         @Override
190 |  |
         public String toString() {
191 | 1 |
                 return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
192 |  |
         }
193 |  |
194 |  |
     }