| 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 | 19 | public DelegatingStoryReporter(Collection<StoryReporter> delegates) { |
| 29 | 19 | this.delegates = delegates; |
| 30 | 19 | } |
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 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 | 8 | for (StoryReporter reporter : delegates) { |
| 49 | 10 | reporter.afterStory(givenStory); |
| 50 | |
} |
| 51 | 8 | } |
| 52 | |
|
| 53 | |
public void beforeScenario(String scenarioTitle) { |
| 54 | 9 | for (StoryReporter reporter : delegates) { |
| 55 | 11 | reporter.beforeScenario(scenarioTitle); |
| 56 | |
} |
| 57 | 9 | } |
| 58 | |
|
| 59 | |
public void scenarioMeta(Meta meta) { |
| 60 | 1 | for (StoryReporter reporter : delegates) { |
| 61 | 1 | reporter.scenarioMeta(meta); |
| 62 | |
} |
| 63 | 1 | } |
| 64 | |
|
| 65 | |
public void beforeStory(Story story, boolean givenStory) { |
| 66 | 8 | for (StoryReporter reporter : delegates) { |
| 67 | 10 | reporter.beforeStory(story, givenStory); |
| 68 | |
} |
| 69 | 8 | } |
| 70 | |
|
| 71 | |
public void narrative(final Narrative narrative) { |
| 72 | 7 | for (StoryReporter reporter : delegates) { |
| 73 | 9 | reporter.narrative(narrative); |
| 74 | |
} |
| 75 | 7 | } |
| 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 | 6 | for (StoryReporter reporter : delegates) { |
| 97 | 7 | reporter.failed(step, cause); |
| 98 | |
} |
| 99 | 6 | } |
| 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 Collection<StoryReporter> getDelegates() { |
| 168 | 5 | return delegates; |
| 169 | |
} |
| 170 | |
|
| 171 | |
@Override |
| 172 | |
public String toString() { |
| 173 | 1 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); |
| 174 | |
} |
| 175 | |
|
| 176 | |
} |