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 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
public class DelegatingStoryReporter implements StoryReporter { |
20 | |
|
21 | |
private final Collection<StoryReporter> delegates; |
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | 24 | public DelegatingStoryReporter(Collection<StoryReporter> delegates) { |
29 | 24 | this.delegates = delegates; |
30 | 24 | } |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
public DelegatingStoryReporter(StoryReporter... delegates) { |
38 | 5 | this(asList(delegates)); |
39 | 5 | } |
40 | |
|
41 | |
public void afterScenario() { |
42 | 18 | for (StoryReporter reporter : delegates) { |
43 | 26 | reporter.afterScenario(); |
44 | 26 | } |
45 | 18 | } |
46 | |
|
47 | |
public void afterStory(boolean givenStory) { |
48 | 12 | for (StoryReporter reporter : delegates) { |
49 | 22 | reporter.afterStory(givenStory); |
50 | 22 | } |
51 | 12 | } |
52 | |
|
53 | |
public void beforeScenario(String scenarioTitle) { |
54 | 18 | for (StoryReporter reporter : delegates) { |
55 | 26 | reporter.beforeScenario(scenarioTitle); |
56 | 26 | } |
57 | 18 | } |
58 | |
|
59 | |
public void scenarioMeta(Meta meta) { |
60 | 3 | for (StoryReporter reporter : delegates) { |
61 | 7 | reporter.scenarioMeta(meta); |
62 | 7 | } |
63 | 3 | } |
64 | |
|
65 | |
public void beforeStory(Story story, boolean givenStory) { |
66 | 12 | for (StoryReporter reporter : delegates) { |
67 | 22 | reporter.beforeStory(story, givenStory); |
68 | 22 | } |
69 | 12 | } |
70 | |
|
71 | |
public void narrative(final Narrative narrative) { |
72 | 9 | for (StoryReporter reporter : delegates) { |
73 | 15 | reporter.narrative(narrative); |
74 | 15 | } |
75 | 9 | } |
76 | |
|
77 | |
public void lifecyle(Lifecycle lifecycle) { |
78 | 2 | for (StoryReporter reporter : delegates) { |
79 | 6 | reporter.lifecyle(lifecycle); |
80 | 6 | } |
81 | 2 | } |
82 | |
|
83 | |
public void beforeExamples(List<String> steps, ExamplesTable table) { |
84 | 8 | for (StoryReporter reporter : delegates) { |
85 | 10 | reporter.beforeExamples(steps, table); |
86 | 10 | } |
87 | 8 | } |
88 | |
|
89 | |
public void example(Map<String, String> tableRow) { |
90 | 15 | for (StoryReporter reporter : delegates) { |
91 | 19 | reporter.example(tableRow); |
92 | 19 | } |
93 | 15 | } |
94 | |
|
95 | |
public void afterExamples() { |
96 | 8 | for (StoryReporter reporter : delegates) { |
97 | 10 | reporter.afterExamples(); |
98 | 10 | } |
99 | 8 | } |
100 | |
|
101 | |
public void failed(String step, Throwable cause) { |
102 | 11 | for (StoryReporter reporter : delegates) { |
103 | 14 | reporter.failed(step, cause); |
104 | 14 | } |
105 | 11 | } |
106 | |
|
107 | |
public void failedOutcomes(String step, OutcomesTable table) { |
108 | 7 | for (StoryReporter reporter : delegates) { |
109 | 9 | reporter.failedOutcomes(step, table); |
110 | 9 | } |
111 | 7 | } |
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 | 8 | for (StoryReporter reporter : delegates) { |
121 | 10 | reporter.givenStories(storyPaths); |
122 | 10 | } |
123 | 8 | } |
124 | |
|
125 | |
public void beforeStep(String step) { |
126 | 1 | for (StoryReporter reporter : delegates) { |
127 | 3 | reporter.beforeStep(step); |
128 | 3 | } |
129 | 1 | } |
130 | |
|
131 | |
public void ignorable(String step) { |
132 | 8 | for (StoryReporter reporter : delegates) { |
133 | 10 | reporter.ignorable(step); |
134 | 10 | } |
135 | 8 | } |
136 | |
|
137 | |
public void notPerformed(String step) { |
138 | 8 | for (StoryReporter reporter : delegates) { |
139 | 10 | reporter.notPerformed(step); |
140 | 10 | } |
141 | 8 | } |
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 | 80 | for (StoryReporter reporter : delegates) { |
151 | 102 | reporter.successful(step); |
152 | 102 | } |
153 | 80 | } |
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 | 8 | for (StoryReporter reporter : delegates) { |
169 | 10 | reporter.dryRun(); |
170 | 10 | } |
171 | 8 | } |
172 | |
|
173 | |
public void pendingMethods(List<String> methods) { |
174 | 7 | for (StoryReporter reporter : delegates) { |
175 | 9 | reporter.pendingMethods(methods); |
176 | 9 | } |
177 | 7 | } |
178 | |
|
179 | |
public void restarted(String step, Throwable cause) { |
180 | 7 | for (StoryReporter reporter : delegates) { |
181 | 9 | reporter.restarted(step, cause); |
182 | 9 | } |
183 | 7 | } |
184 | |
|
185 | |
public void storyCancelled(Story story, StoryDuration storyDuration) { |
186 | 8 | for (StoryReporter reporter : delegates) { |
187 | 12 | reporter.storyCancelled(story, storyDuration); |
188 | 12 | } |
189 | 8 | } |
190 | |
|
191 | |
public Collection<StoryReporter> getDelegates() { |
192 | 6 | return delegates; |
193 | |
} |
194 | |
|
195 | |
@Override |
196 | |
public String toString() { |
197 | 1 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); |
198 | |
} |
199 | |
|
200 | |
} |