1 | |
package org.jbehave.core.configuration; |
2 | |
|
3 | |
import java.util.HashMap; |
4 | |
import java.util.Map; |
5 | |
|
6 | |
import org.jbehave.core.Embeddable; |
7 | |
import org.jbehave.core.embedder.Embedder; |
8 | |
import org.jbehave.core.failures.FailingUponPendingStep; |
9 | |
import org.jbehave.core.failures.FailureStrategy; |
10 | |
import org.jbehave.core.failures.PassingUponPendingStep; |
11 | |
import org.jbehave.core.failures.PendingStepStrategy; |
12 | |
import org.jbehave.core.failures.RethrowingFailure; |
13 | |
import org.jbehave.core.failures.SilentlyAbsorbingFailure; |
14 | |
import org.jbehave.core.i18n.LocalizedKeywords; |
15 | |
import org.jbehave.core.io.LoadFromClasspath; |
16 | |
import org.jbehave.core.io.StoryLoader; |
17 | |
import org.jbehave.core.io.StoryPathResolver; |
18 | |
import org.jbehave.core.io.UnderscoredCamelCaseResolver; |
19 | |
import org.jbehave.core.parsers.RegexPrefixCapturingPatternParser; |
20 | |
import org.jbehave.core.parsers.RegexStoryParser; |
21 | |
import org.jbehave.core.parsers.StepPatternParser; |
22 | |
import org.jbehave.core.parsers.StoryParser; |
23 | |
import org.jbehave.core.reporters.ConsoleOutput; |
24 | |
import org.jbehave.core.reporters.FreemarkerViewGenerator; |
25 | |
import org.jbehave.core.reporters.PrintStreamStepdocReporter; |
26 | |
import org.jbehave.core.reporters.StepdocReporter; |
27 | |
import org.jbehave.core.reporters.StoryReporter; |
28 | |
import org.jbehave.core.reporters.StoryReporterBuilder; |
29 | |
import org.jbehave.core.reporters.ViewGenerator; |
30 | |
import org.jbehave.core.steps.MarkUnmatchedStepsAsPending; |
31 | |
import org.jbehave.core.steps.ParameterConverters; |
32 | |
import org.jbehave.core.steps.PrintStreamStepMonitor; |
33 | |
import org.jbehave.core.steps.SilentStepMonitor; |
34 | |
import org.jbehave.core.steps.StepCollector; |
35 | |
import org.jbehave.core.steps.StepFinder; |
36 | |
import org.jbehave.core.steps.StepMonitor; |
37 | |
|
38 | |
import com.thoughtworks.paranamer.NullParanamer; |
39 | |
import com.thoughtworks.paranamer.Paranamer; |
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | 191 | public abstract class Configuration { |
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | 191 | private boolean dryRun = false; |
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | 191 | private Keywords keywords = new LocalizedKeywords(); |
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | 191 | private StepCollector stepCollector = new MarkUnmatchedStepsAsPending(); |
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | 191 | private StoryParser storyParser = new RegexStoryParser(keywords); |
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | 191 | private StoryLoader storyLoader = new LoadFromClasspath(); |
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | 191 | private StoryPathResolver storyPathResolver = new UnderscoredCamelCaseResolver(); |
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | 191 | private FailureStrategy failureStrategy = new RethrowingFailure(); |
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | 191 | private PendingStepStrategy pendingStepStrategy = new PassingUponPendingStep(); |
108 | |
|
109 | |
|
110 | |
|
111 | |
|
112 | 191 | private StoryReporter defaultStoryReporter = new ConsoleOutput(); |
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | 191 | private Map<String, StoryReporter> storyReporters = new HashMap<String, StoryReporter>(); |
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | 191 | private StoryReporterBuilder storyReporterBuilder = new StoryReporterBuilder(); |
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | 191 | private StepFinder stepFinder = new StepFinder(); |
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | 191 | private StepdocReporter stepdocReporter = new PrintStreamStepdocReporter(); |
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | 191 | private StepPatternParser stepPatternParser = new RegexPrefixCapturingPatternParser(); |
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | 191 | private StepMonitor stepMonitor = new SilentStepMonitor(); |
145 | |
|
146 | |
|
147 | |
|
148 | |
|
149 | 191 | private Paranamer paranamer = new NullParanamer(); |
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | 191 | private ParameterConverters parameterConverters = new ParameterConverters(); |
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | 191 | private ViewGenerator viewGenerator = new FreemarkerViewGenerator(); |
160 | |
|
161 | |
public boolean dryRun() { |
162 | 60 | return dryRun; |
163 | |
} |
164 | |
|
165 | |
public Keywords keywords() { |
166 | 239 | return keywords; |
167 | |
} |
168 | |
|
169 | |
public StoryParser storyParser() { |
170 | 3 | return storyParser; |
171 | |
} |
172 | |
|
173 | |
public StoryLoader storyLoader() { |
174 | 3 | return storyLoader; |
175 | |
} |
176 | |
|
177 | |
public StoryPathResolver storyPathResolver() { |
178 | 20 | return storyPathResolver; |
179 | |
} |
180 | |
|
181 | |
public FailureStrategy failureStrategy() { |
182 | 13 | return failureStrategy; |
183 | |
} |
184 | |
|
185 | |
public PendingStepStrategy pendingStepStrategy() { |
186 | 14 | return pendingStepStrategy; |
187 | |
} |
188 | |
|
189 | |
public StoryReporter defaultStoryReporter() { |
190 | 17 | return defaultStoryReporter; |
191 | |
} |
192 | |
|
193 | |
public StoryReporter storyReporter(String storyPath) { |
194 | 15 | StoryReporter storyReporter = storyReporters.get(storyPath); |
195 | 15 | if (storyReporter != null) { |
196 | 2 | return storyReporter; |
197 | |
} |
198 | |
|
199 | 13 | return defaultStoryReporter(); |
200 | |
} |
201 | |
|
202 | |
public StoryReporterBuilder storyReporterBuilder() { |
203 | 36 | return storyReporterBuilder; |
204 | |
} |
205 | |
|
206 | |
public StepCollector stepCollector() { |
207 | 15 | return stepCollector; |
208 | |
} |
209 | |
|
210 | |
public StepFinder stepFinder() { |
211 | 4 | return stepFinder; |
212 | |
} |
213 | |
|
214 | |
public StepdocReporter stepdocReporter() { |
215 | 4 | return stepdocReporter; |
216 | |
} |
217 | |
|
218 | |
public StepPatternParser stepPatternParser() { |
219 | 49 | return stepPatternParser; |
220 | |
} |
221 | |
|
222 | |
public StepMonitor stepMonitor() { |
223 | 49 | return stepMonitor; |
224 | |
} |
225 | |
|
226 | |
public Paranamer paranamer() { |
227 | 49 | return paranamer; |
228 | |
} |
229 | |
|
230 | |
public ParameterConverters parameterConverters() { |
231 | 62 | return parameterConverters; |
232 | |
} |
233 | |
|
234 | |
public ViewGenerator viewGenerator() { |
235 | 23 | return viewGenerator; |
236 | |
} |
237 | |
|
238 | |
public Configuration doDryRun(Boolean dryRun) { |
239 | 191 | this.dryRun = dryRun; |
240 | 191 | return this; |
241 | |
} |
242 | |
|
243 | |
public Configuration useKeywords(Keywords keywords) { |
244 | 200 | this.keywords = keywords; |
245 | 200 | return this; |
246 | |
} |
247 | |
|
248 | |
public Configuration usePendingStepStrategy(PendingStepStrategy pendingStepStrategy) { |
249 | 209 | this.pendingStepStrategy = pendingStepStrategy; |
250 | 209 | return this; |
251 | |
} |
252 | |
|
253 | |
public Configuration useFailureStrategy(FailureStrategy failureStrategy) { |
254 | 209 | this.failureStrategy = failureStrategy; |
255 | 209 | return this; |
256 | |
} |
257 | |
|
258 | |
public Configuration useStoryParser(StoryParser storyParser) { |
259 | 209 | this.storyParser = storyParser; |
260 | 209 | return this; |
261 | |
} |
262 | |
|
263 | |
public Configuration useStoryLoader(StoryLoader storyLoader) { |
264 | 209 | this.storyLoader = storyLoader; |
265 | 209 | return this; |
266 | |
} |
267 | |
|
268 | |
public Configuration useStoryPathResolver(StoryPathResolver storyPathResolver) { |
269 | 11 | this.storyPathResolver = storyPathResolver; |
270 | 11 | return this; |
271 | |
} |
272 | |
|
273 | |
public Configuration useDefaultStoryReporter(StoryReporter storyReporter) { |
274 | 209 | this.defaultStoryReporter = storyReporter; |
275 | 209 | return this; |
276 | |
} |
277 | |
|
278 | |
public Configuration useStoryReporter(String storyPath, StoryReporter storyReporter) { |
279 | 2 | this.storyReporters.put(storyPath, storyReporter); |
280 | 2 | return this; |
281 | |
} |
282 | |
|
283 | |
public Configuration useStoryReporters(Map<String, StoryReporter> storyReporters) { |
284 | 17 | this.storyReporters.putAll(storyReporters); |
285 | 17 | return this; |
286 | |
} |
287 | |
|
288 | |
public Configuration useStoryReporterBuilder(StoryReporterBuilder storyReporterBuilder) { |
289 | 10 | this.storyReporterBuilder = storyReporterBuilder; |
290 | 10 | return this; |
291 | |
} |
292 | |
|
293 | |
public Configuration useStepCollector(StepCollector stepCollector) { |
294 | 209 | this.stepCollector = stepCollector; |
295 | 209 | return this; |
296 | |
} |
297 | |
|
298 | |
public Configuration useStepFinder(StepFinder stepFinder) { |
299 | 201 | this.stepFinder = stepFinder; |
300 | 201 | return this; |
301 | |
} |
302 | |
|
303 | |
public Configuration useStepdocReporter(StepdocReporter stepdocReporter) { |
304 | 201 | this.stepdocReporter = stepdocReporter; |
305 | 201 | return this; |
306 | |
} |
307 | |
|
308 | |
public Configuration useStepPatternParser(StepPatternParser stepPatternParser) { |
309 | 197 | this.stepPatternParser = stepPatternParser; |
310 | 197 | return this; |
311 | |
} |
312 | |
|
313 | |
public Configuration useStepMonitor(StepMonitor stepMonitor) { |
314 | 197 | this.stepMonitor = stepMonitor; |
315 | 197 | return this; |
316 | |
} |
317 | |
|
318 | |
public Configuration useParanamer(Paranamer paranamer) { |
319 | 197 | this.paranamer = paranamer; |
320 | 197 | return this; |
321 | |
} |
322 | |
|
323 | |
public Configuration useParameterConverters(ParameterConverters parameterConverters) { |
324 | 9 | this.parameterConverters = parameterConverters; |
325 | 9 | return this; |
326 | |
} |
327 | |
|
328 | |
public void useViewGenerator(ViewGenerator viewGenerator) { |
329 | 202 | this.viewGenerator = viewGenerator; |
330 | 202 | } |
331 | |
|
332 | |
|
333 | |
} |