1 | |
package org.jbehave.core.configuration; |
2 | |
|
3 | |
import org.jbehave.core.Embeddable; |
4 | |
import org.jbehave.core.embedder.Embedder; |
5 | |
import org.jbehave.core.embedder.StoryControls; |
6 | |
import org.jbehave.core.failures.FailingUponPendingStep; |
7 | |
import org.jbehave.core.failures.FailureStrategy; |
8 | |
import org.jbehave.core.failures.PassingUponPendingStep; |
9 | |
import org.jbehave.core.failures.PendingStepStrategy; |
10 | |
import org.jbehave.core.failures.RethrowingFailure; |
11 | |
import org.jbehave.core.failures.SilentlyAbsorbingFailure; |
12 | |
import org.jbehave.core.i18n.LocalizedKeywords; |
13 | |
import org.jbehave.core.io.AbsolutePathCalculator; |
14 | |
import org.jbehave.core.io.LoadFromClasspath; |
15 | |
import org.jbehave.core.io.PathCalculator; |
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.ParameterControls; |
32 | |
import org.jbehave.core.steps.ParameterConverters; |
33 | |
import org.jbehave.core.steps.PrintStreamStepMonitor; |
34 | |
import org.jbehave.core.steps.SilentStepMonitor; |
35 | |
import org.jbehave.core.steps.StepCollector; |
36 | |
import org.jbehave.core.steps.StepFinder; |
37 | |
import org.jbehave.core.steps.StepMonitor; |
38 | |
|
39 | |
import com.thoughtworks.paranamer.NullParanamer; |
40 | |
import com.thoughtworks.paranamer.Paranamer; |
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
public abstract class Configuration { |
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
protected StoryControls storyControls; |
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
protected Keywords keywords; |
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
protected StepCollector stepCollector; |
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
protected StoryParser storyParser; |
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
protected StoryLoader storyLoader; |
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
protected StoryPathResolver storyPathResolver; |
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
protected FailureStrategy failureStrategy; |
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
protected PendingStepStrategy pendingStepStrategy; |
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | |
protected StoryReporter defaultStoryReporter; |
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
protected StoryReporterBuilder storyReporterBuilder; |
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
protected StepFinder stepFinder; |
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
protected StepdocReporter stepdocReporter; |
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
protected StepPatternParser stepPatternParser; |
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
protected ParameterControls parameterControls; |
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
protected StepMonitor stepMonitor; |
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
protected Paranamer paranamer; |
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
protected ParameterConverters parameterConverters; |
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
protected ViewGenerator viewGenerator; |
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
protected PathCalculator pathCalculator; |
166 | |
|
167 | 295 | public Configuration() { |
168 | 295 | } |
169 | |
|
170 | |
public Keywords keywords() { |
171 | 647 | if (keywords == null) { |
172 | 0 | keywords = new LocalizedKeywords(); |
173 | |
} |
174 | 647 | return keywords; |
175 | |
} |
176 | |
|
177 | |
public boolean dryRun() { |
178 | 2 | return storyControls().dryRun(); |
179 | |
} |
180 | |
|
181 | |
public StoryControls storyControls() { |
182 | 667 | if (storyControls == null) { |
183 | 0 | storyControls = new StoryControls(); |
184 | |
} |
185 | 667 | return storyControls; |
186 | |
} |
187 | |
|
188 | |
public StoryParser storyParser() { |
189 | 51 | if (storyParser == null) { |
190 | 0 | storyParser = new RegexStoryParser(); |
191 | |
} |
192 | 51 | return storyParser; |
193 | |
} |
194 | |
|
195 | |
public StoryLoader storyLoader() { |
196 | 51 | if (storyLoader == null) { |
197 | 0 | storyLoader = new LoadFromClasspath(); |
198 | |
} |
199 | 51 | return storyLoader; |
200 | |
} |
201 | |
|
202 | |
public StoryPathResolver storyPathResolver() { |
203 | 11 | if (storyPathResolver == null) { |
204 | 10 | storyPathResolver = new UnderscoredCamelCaseResolver(); |
205 | |
} |
206 | 11 | return storyPathResolver; |
207 | |
} |
208 | |
|
209 | |
public FailureStrategy failureStrategy() { |
210 | 50 | if (failureStrategy == null) { |
211 | 0 | failureStrategy = new RethrowingFailure(); |
212 | |
} |
213 | 50 | return failureStrategy; |
214 | |
} |
215 | |
|
216 | |
public PendingStepStrategy pendingStepStrategy() { |
217 | 55 | if (pendingStepStrategy == null) { |
218 | 0 | pendingStepStrategy = new PassingUponPendingStep(); |
219 | |
} |
220 | 55 | return pendingStepStrategy; |
221 | |
} |
222 | |
|
223 | |
|
224 | |
|
225 | |
|
226 | |
public StoryReporter defaultStoryReporter() { |
227 | 4 | if (defaultStoryReporter == null) { |
228 | 3 | defaultStoryReporter = new ConsoleOutput(); |
229 | |
} |
230 | 4 | return defaultStoryReporter; |
231 | |
} |
232 | |
|
233 | |
public StoryReporter storyReporter(String storyPath) { |
234 | 63 | return storyReporterBuilder().build(storyPath); |
235 | |
} |
236 | |
|
237 | |
public StoryReporterBuilder storyReporterBuilder() { |
238 | 286 | if (storyReporterBuilder == null) { |
239 | 26 | storyReporterBuilder = new StoryReporterBuilder(); |
240 | |
} |
241 | 286 | return storyReporterBuilder; |
242 | |
} |
243 | |
|
244 | |
public StepCollector stepCollector() { |
245 | 682 | if (stepCollector == null) { |
246 | 0 | stepCollector = new MarkUnmatchedStepsAsPending(); |
247 | |
} |
248 | 682 | return stepCollector; |
249 | |
} |
250 | |
|
251 | |
public StepFinder stepFinder() { |
252 | 4 | if (stepFinder == null) { |
253 | 0 | stepFinder = new StepFinder(); |
254 | |
} |
255 | 4 | return stepFinder; |
256 | |
} |
257 | |
|
258 | |
public StepdocReporter stepdocReporter() { |
259 | 4 | if (stepdocReporter == null) { |
260 | 0 | stepdocReporter = new PrintStreamStepdocReporter(); |
261 | |
} |
262 | 4 | return stepdocReporter; |
263 | |
} |
264 | |
|
265 | |
public StepPatternParser stepPatternParser() { |
266 | 304 | if (stepPatternParser == null) { |
267 | 0 | stepPatternParser = new RegexPrefixCapturingPatternParser(); |
268 | |
} |
269 | 304 | return stepPatternParser; |
270 | |
} |
271 | |
|
272 | |
public ParameterControls parameterControls() { |
273 | 354 | if (parameterControls == null) { |
274 | 0 | parameterControls = new ParameterControls(); |
275 | |
} |
276 | 354 | return parameterControls; |
277 | |
} |
278 | |
|
279 | |
public StepMonitor stepMonitor() { |
280 | 354 | if (stepMonitor == null) { |
281 | 0 | stepMonitor = new SilentStepMonitor(); |
282 | |
} |
283 | 354 | return stepMonitor; |
284 | |
} |
285 | |
|
286 | |
public Paranamer paranamer() { |
287 | 305 | if (paranamer == null) { |
288 | 0 | paranamer = new NullParanamer(); |
289 | |
} |
290 | 305 | return paranamer; |
291 | |
} |
292 | |
|
293 | |
public ParameterConverters parameterConverters() { |
294 | 425 | if (parameterConverters == null) { |
295 | 60 | parameterConverters = new ParameterConverters(); |
296 | |
} |
297 | 425 | return parameterConverters; |
298 | |
} |
299 | |
|
300 | |
public ViewGenerator viewGenerator() { |
301 | 32 | if (viewGenerator == null) { |
302 | 0 | viewGenerator = new FreemarkerViewGenerator(); |
303 | |
} |
304 | 32 | return viewGenerator; |
305 | |
} |
306 | |
|
307 | |
public PathCalculator pathCalculator() { |
308 | 3 | if (pathCalculator == null) { |
309 | 2 | pathCalculator = new AbsolutePathCalculator(); |
310 | |
} |
311 | 3 | return pathCalculator; |
312 | |
} |
313 | |
|
314 | |
public Configuration useKeywords(Keywords keywords) { |
315 | 307 | this.keywords = keywords; |
316 | 307 | return this; |
317 | |
} |
318 | |
|
319 | |
public Configuration doDryRun(Boolean dryRun) { |
320 | 1 | this.storyControls().doDryRun(dryRun); |
321 | 1 | return this; |
322 | |
} |
323 | |
|
324 | |
public Configuration useStoryControls(StoryControls storyControls){ |
325 | 304 | this.storyControls = storyControls; |
326 | 304 | return this; |
327 | |
} |
328 | |
|
329 | |
public Configuration usePendingStepStrategy(PendingStepStrategy pendingStepStrategy) { |
330 | 330 | this.pendingStepStrategy = pendingStepStrategy; |
331 | 330 | return this; |
332 | |
} |
333 | |
|
334 | |
public Configuration useFailureStrategy(FailureStrategy failureStrategy) { |
335 | 329 | this.failureStrategy = failureStrategy; |
336 | 329 | return this; |
337 | |
} |
338 | |
|
339 | |
public Configuration useStoryParser(StoryParser storyParser) { |
340 | 329 | this.storyParser = storyParser; |
341 | 329 | return this; |
342 | |
} |
343 | |
|
344 | |
public Configuration useStoryLoader(StoryLoader storyLoader) { |
345 | 361 | this.storyLoader = storyLoader; |
346 | 361 | return this; |
347 | |
} |
348 | |
|
349 | |
public Configuration useStoryPathResolver(StoryPathResolver storyPathResolver) { |
350 | 15 | this.storyPathResolver = storyPathResolver; |
351 | 15 | return this; |
352 | |
} |
353 | |
|
354 | |
public Configuration useDefaultStoryReporter(StoryReporter storyReporter) { |
355 | 13 | this.defaultStoryReporter = storyReporter; |
356 | 13 | return this; |
357 | |
} |
358 | |
|
359 | |
public Configuration useStoryReporterBuilder(StoryReporterBuilder storyReporterBuilder) { |
360 | 208 | this.storyReporterBuilder = storyReporterBuilder; |
361 | 208 | return this; |
362 | |
} |
363 | |
|
364 | |
public Configuration useStepCollector(StepCollector stepCollector) { |
365 | 329 | this.stepCollector = stepCollector; |
366 | 329 | return this; |
367 | |
} |
368 | |
|
369 | |
public Configuration useStepFinder(StepFinder stepFinder) { |
370 | 308 | this.stepFinder = stepFinder; |
371 | 308 | return this; |
372 | |
} |
373 | |
|
374 | |
public Configuration useStepdocReporter(StepdocReporter stepdocReporter) { |
375 | 308 | this.stepdocReporter = stepdocReporter; |
376 | 308 | return this; |
377 | |
} |
378 | |
|
379 | |
public Configuration useStepPatternParser(StepPatternParser stepPatternParser) { |
380 | 304 | this.stepPatternParser = stepPatternParser; |
381 | 304 | return this; |
382 | |
} |
383 | |
|
384 | |
public Configuration useParameterControls(ParameterControls parameterControls) { |
385 | 304 | this.parameterControls = parameterControls; |
386 | 304 | return this; |
387 | |
} |
388 | |
|
389 | |
public Configuration useStepMonitor(StepMonitor stepMonitor) { |
390 | 304 | this.stepMonitor = stepMonitor; |
391 | 304 | return this; |
392 | |
} |
393 | |
|
394 | |
public Configuration useParanamer(Paranamer paranamer) { |
395 | 305 | this.paranamer = paranamer; |
396 | 305 | return this; |
397 | |
} |
398 | |
|
399 | |
public Configuration useParameterConverters(ParameterConverters parameterConverters) { |
400 | 13 | this.parameterConverters = parameterConverters; |
401 | 13 | return this; |
402 | |
} |
403 | |
|
404 | |
public Configuration useViewGenerator(ViewGenerator viewGenerator) { |
405 | 313 | this.viewGenerator = viewGenerator; |
406 | 313 | return this; |
407 | |
} |
408 | |
|
409 | |
public Configuration usePathCalculator(PathCalculator pathCalculator) { |
410 | 13 | this.pathCalculator = pathCalculator; |
411 | 13 | return this; |
412 | |
} |
413 | |
|
414 | |
} |