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