1 | |
package org.jbehave.core.embedder; |
2 | |
|
3 | |
import java.io.File; |
4 | |
import java.util.ArrayList; |
5 | |
import java.util.List; |
6 | |
import java.util.Properties; |
7 | |
import java.util.concurrent.ExecutorService; |
8 | |
import java.util.concurrent.ThreadPoolExecutor; |
9 | |
|
10 | |
import org.apache.commons.lang.StringUtils; |
11 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
12 | |
import org.apache.commons.lang.builder.ToStringStyle; |
13 | |
import org.jbehave.core.ConfigurableEmbedder; |
14 | |
import org.jbehave.core.Embeddable; |
15 | |
import org.jbehave.core.configuration.Configuration; |
16 | |
import org.jbehave.core.configuration.MostUsefulConfiguration; |
17 | |
import org.jbehave.core.embedder.executors.FixedThreadExecutors; |
18 | |
import org.jbehave.core.failures.BatchFailures; |
19 | |
import org.jbehave.core.failures.FailingUponPendingStep; |
20 | |
import org.jbehave.core.junit.AnnotatedEmbedderRunner; |
21 | |
import org.jbehave.core.junit.AnnotatedEmbedderUtils; |
22 | |
import org.jbehave.core.model.Story; |
23 | |
import org.jbehave.core.model.StoryMaps; |
24 | |
import org.jbehave.core.reporters.ReportsCount; |
25 | |
import org.jbehave.core.reporters.StepdocReporter; |
26 | |
import org.jbehave.core.reporters.StoryReporterBuilder; |
27 | |
import org.jbehave.core.reporters.ViewGenerator; |
28 | |
import org.jbehave.core.steps.CandidateSteps; |
29 | |
import org.jbehave.core.steps.InjectableStepsFactory; |
30 | |
import org.jbehave.core.steps.ProvidedStepsFactory; |
31 | |
import org.jbehave.core.steps.StepFinder; |
32 | |
import org.jbehave.core.steps.Stepdoc; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
public class Embedder { |
40 | |
|
41 | |
protected StoryMapper storyMapper; |
42 | |
protected StoryRunner storyRunner; |
43 | |
protected EmbedderMonitor embedderMonitor; |
44 | |
protected EmbedderClassLoader classLoader; |
45 | |
protected EmbedderControls embedderControls; |
46 | |
protected EmbedderFailureStrategy embedderFailureStrategy; |
47 | |
protected Configuration configuration; |
48 | |
protected List<CandidateSteps> candidateSteps; |
49 | |
protected InjectableStepsFactory stepsFactory; |
50 | |
protected List<String> metaFilters; |
51 | |
protected Properties systemProperties; |
52 | |
protected ExecutorService executorService; |
53 | |
protected boolean executorServiceCreated; |
54 | |
protected PerformableTree performableTree; |
55 | |
protected StoryManager storyManager; |
56 | |
|
57 | |
public Embedder() { |
58 | 63 | this(new PrintStreamEmbedderMonitor()); |
59 | 63 | } |
60 | |
|
61 | |
public Embedder(EmbedderMonitor embedderMonitor) { |
62 | 71 | this(new StoryMapper(), new PerformableTree(), embedderMonitor); |
63 | 71 | } |
64 | |
|
65 | 100 | public Embedder(StoryMapper storyMapper, PerformableTree performableTree, EmbedderMonitor embedderMonitor) { |
66 | 100 | this.storyMapper = storyMapper; |
67 | 100 | this.performableTree = performableTree; |
68 | 100 | this.embedderMonitor = embedderMonitor; |
69 | 100 | } |
70 | |
|
71 | |
public void mapStoriesAsPaths(List<String> storyPaths) { |
72 | 1 | EmbedderControls embedderControls = embedderControls(); |
73 | 1 | embedderMonitor.usingControls(embedderControls); |
74 | |
|
75 | 1 | if (embedderControls.skip()) { |
76 | 0 | embedderMonitor.storiesSkipped(storyPaths); |
77 | 0 | return; |
78 | |
} |
79 | |
|
80 | 1 | processSystemProperties(); |
81 | |
|
82 | 1 | StoryManager storyManager = storyManager(); |
83 | 1 | for (String storyPath : storyPaths) { |
84 | 2 | Story story = storyManager.storyOfPath(storyPath); |
85 | 2 | embedderMonitor.mappingStory(storyPath, metaFilters()); |
86 | 2 | storyMapper.map(story, new MetaFilter("")); |
87 | 2 | for (String filter : metaFilters) { |
88 | 0 | storyMapper.map(story, new MetaFilter(filter)); |
89 | 0 | } |
90 | 2 | } |
91 | |
|
92 | 1 | generateMapsView(storyMapper.getStoryMaps()); |
93 | |
|
94 | 1 | } |
95 | |
|
96 | |
private void generateMapsView(StoryMaps storyMaps) { |
97 | 1 | Configuration configuration = configuration(); |
98 | 1 | StoryReporterBuilder builder = configuration.storyReporterBuilder(); |
99 | 1 | File outputDirectory = builder.outputDirectory(); |
100 | 1 | Properties viewResources = builder.viewResources(); |
101 | 1 | ViewGenerator viewGenerator = configuration.viewGenerator(); |
102 | |
try { |
103 | 1 | embedderMonitor.generatingMapsView(outputDirectory, storyMaps, viewResources); |
104 | 1 | viewGenerator.generateMapsView(outputDirectory, storyMaps, viewResources); |
105 | 0 | } catch (RuntimeException e) { |
106 | 0 | embedderMonitor.mapsViewGenerationFailed(outputDirectory, storyMaps, viewResources, e); |
107 | 0 | throw new ViewGenerationFailed(outputDirectory, storyMaps, viewResources, e); |
108 | 1 | } |
109 | 1 | } |
110 | |
|
111 | |
public void runAsEmbeddables(List<String> classNames) { |
112 | 26 | EmbedderControls embedderControls = embedderControls(); |
113 | 26 | embedderMonitor.usingControls(embedderControls); |
114 | |
|
115 | 26 | if (embedderControls.skip()) { |
116 | 1 | embedderMonitor.embeddablesSkipped(classNames); |
117 | 1 | return; |
118 | |
} |
119 | |
|
120 | 25 | BatchFailures failures = new BatchFailures(embedderControls.verboseFailures()); |
121 | 25 | for (Embeddable embeddable : embeddables(classNames, classLoader())) { |
122 | 31 | String name = embeddable.getClass().getName(); |
123 | |
try { |
124 | 31 | embedderMonitor.runningEmbeddable(name); |
125 | 31 | embeddable.useEmbedder(this); |
126 | 31 | embeddable.run(); |
127 | 14 | } catch (Throwable e) { |
128 | 14 | if (embedderControls.batch()) { |
129 | |
|
130 | 2 | failures.put(name, e); |
131 | |
} else { |
132 | 12 | if (ignoreFailure(embedderControls)) { |
133 | 1 | embedderMonitor.embeddableFailed(name, e); |
134 | |
} else { |
135 | 11 | throw new RunningEmbeddablesFailed(name, e); |
136 | |
} |
137 | |
} |
138 | 17 | } |
139 | 20 | } |
140 | |
|
141 | 14 | if (embedderControls.batch() && failures.size() > 0) { |
142 | 2 | if (ignoreFailure(embedderControls)) { |
143 | 1 | embedderMonitor.batchFailed(failures); |
144 | |
} else { |
145 | 1 | throw new RunningEmbeddablesFailed(failures); |
146 | |
} |
147 | |
} |
148 | |
|
149 | 13 | } |
150 | |
|
151 | |
private boolean ignoreFailure(EmbedderControls embedderControls) { |
152 | 14 | boolean ignore = embedderControls.ignoreFailureInStories(); |
153 | 14 | if (embedderControls.generateViewAfterStories()) { |
154 | 14 | ignore = ignore && embedderControls.ignoreFailureInView(); |
155 | |
} |
156 | 14 | return ignore; |
157 | |
} |
158 | |
|
159 | |
private List<Embeddable> embeddables(List<String> classNames, EmbedderClassLoader classLoader) { |
160 | 25 | List<Embeddable> embeddables = new ArrayList<Embeddable>(); |
161 | 25 | for (String className : classNames) { |
162 | 33 | if (!classLoader.isAbstract(className)) { |
163 | 32 | embeddables.add(classLoader.newInstance(Embeddable.class, className)); |
164 | |
} |
165 | 33 | } |
166 | 25 | return embeddables; |
167 | |
} |
168 | |
|
169 | |
public void runStoriesWithAnnotatedEmbedderRunner(List<String> classNames) { |
170 | 4 | EmbedderClassLoader classLoader = classLoader(); |
171 | 4 | for (String className : classNames) { |
172 | 4 | embedderMonitor.runningWithAnnotatedEmbedderRunner(className); |
173 | 4 | AnnotatedEmbedderRunner runner = AnnotatedEmbedderUtils.annotatedEmbedderRunner(className, classLoader); |
174 | |
try { |
175 | 3 | Object annotatedInstance = runner.createTest(); |
176 | 3 | if (annotatedInstance instanceof Embeddable) { |
177 | 2 | ((Embeddable) annotatedInstance).run(); |
178 | |
} else { |
179 | 1 | embedderMonitor.annotatedInstanceNotOfType(annotatedInstance, Embeddable.class); |
180 | |
} |
181 | 1 | } catch (Throwable e) { |
182 | 1 | throw new AnnotatedEmbedderRunFailed(runner, e); |
183 | 2 | } |
184 | 2 | } |
185 | 2 | } |
186 | |
|
187 | |
public void runStoriesAsPaths(List<String> storyPaths) { |
188 | |
|
189 | 23 | processSystemProperties(); |
190 | |
|
191 | 23 | EmbedderControls embedderControls = embedderControls(); |
192 | |
|
193 | 23 | embedderMonitor.usingControls(embedderControls); |
194 | |
|
195 | 23 | if (embedderControls.skip()) { |
196 | 1 | embedderMonitor.storiesSkipped(storyPaths); |
197 | 1 | return; |
198 | |
} |
199 | |
|
200 | |
try { |
201 | |
|
202 | |
|
203 | 22 | StoryManager storyManager = createStoryManager(); |
204 | 22 | MetaFilter filter = metaFilter(); |
205 | 22 | BatchFailures failures = new BatchFailures(embedderControls.verboseFailures()); |
206 | |
|
207 | |
|
208 | 22 | storyManager.runStoriesAsPaths(storyPaths, filter, failures); |
209 | |
|
210 | |
|
211 | 15 | handleFailures(failures); |
212 | |
|
213 | |
} finally { |
214 | |
|
215 | |
|
216 | 10 | try { |
217 | 22 | if (embedderControls.generateViewAfterStories()) { |
218 | 21 | generateReportsView(); |
219 | |
} |
220 | |
} finally { |
221 | |
|
222 | 22 | shutdownExecutorService(); |
223 | 22 | } |
224 | |
|
225 | 12 | } |
226 | 12 | } |
227 | |
|
228 | |
private void handleFailures(BatchFailures failures) { |
229 | 15 | if (failures.size() > 0) { |
230 | 3 | if (embedderControls().ignoreFailureInStories()) { |
231 | 0 | embedderMonitor.batchFailed(failures); |
232 | |
} else { |
233 | 3 | embedderFailureStrategy().handleFailures(failures); |
234 | |
} |
235 | |
} |
236 | 12 | } |
237 | |
|
238 | |
public void generateReportsView() { |
239 | 21 | StoryReporterBuilder builder = configuration().storyReporterBuilder(); |
240 | 21 | File outputDirectory = builder.outputDirectory(); |
241 | 21 | List<String> formatNames = builder.formatNames(true); |
242 | 21 | generateReportsView(outputDirectory, formatNames, builder.viewResources()); |
243 | 21 | } |
244 | |
|
245 | |
public void generateReportsView(File outputDirectory, List<String> formats, Properties viewResources) { |
246 | |
|
247 | 30 | if (embedderControls().skip()) { |
248 | 1 | embedderMonitor.reportsViewNotGenerated(); |
249 | 1 | return; |
250 | |
} |
251 | 29 | ViewGenerator viewGenerator = configuration().viewGenerator(); |
252 | |
try { |
253 | 29 | embedderMonitor.generatingReportsView(outputDirectory, formats, viewResources); |
254 | 29 | viewGenerator.generateReportsView(outputDirectory, formats, viewResources); |
255 | 1 | } catch (RuntimeException e) { |
256 | 1 | embedderMonitor.reportsViewGenerationFailed(outputDirectory, formats, viewResources, e); |
257 | 1 | throw new ViewGenerationFailed(outputDirectory, formats, viewResources, e); |
258 | 28 | } |
259 | 28 | ReportsCount count = viewGenerator.getReportsCount(); |
260 | 28 | embedderMonitor.reportsViewGenerated(count); |
261 | 28 | handleFailures(count); |
262 | |
|
263 | 24 | } |
264 | |
|
265 | |
private void handleFailures(ReportsCount count) { |
266 | 28 | boolean failed = count.failed(); |
267 | 28 | if (configuration().pendingStepStrategy() instanceof FailingUponPendingStep) { |
268 | 1 | failed = failed || count.pending(); |
269 | |
} |
270 | 28 | if (failed) { |
271 | 6 | if (embedderControls().ignoreFailureInView()) { |
272 | 1 | embedderMonitor.reportsViewFailures(count); |
273 | |
} else { |
274 | 5 | embedderFailureStrategy().handleFailures(count); |
275 | |
} |
276 | |
} |
277 | 24 | } |
278 | |
|
279 | |
public void generateCrossReference() { |
280 | 18 | StoryReporterBuilder builder = configuration().storyReporterBuilder(); |
281 | 18 | if (builder.hasCrossReference()) { |
282 | 17 | builder.crossReference().serialise(storyManager().performableRoot(), builder.outputDirectory()); |
283 | |
} |
284 | 18 | } |
285 | |
|
286 | |
public void reportStepdocs() { |
287 | 1 | reportStepdocs(configuration(), candidateSteps()); |
288 | 1 | } |
289 | |
|
290 | |
public void reportStepdocsAsEmbeddables(List<String> classNames) { |
291 | 0 | EmbedderControls embedderControls = embedderControls(); |
292 | 0 | if (embedderControls.skip()) { |
293 | 0 | embedderMonitor.embeddablesSkipped(classNames); |
294 | 0 | return; |
295 | |
} |
296 | |
|
297 | 0 | for (Embeddable embeddable : embeddables(classNames, classLoader())) { |
298 | 0 | if (embeddable instanceof ConfigurableEmbedder) { |
299 | 0 | ConfigurableEmbedder configurableEmbedder = (ConfigurableEmbedder) embeddable; |
300 | 0 | Embedder configuredEmbedder = configurableEmbedder.configuredEmbedder(); |
301 | 0 | List<CandidateSteps> steps = configuredEmbedder.candidateSteps(); |
302 | 0 | if (steps.isEmpty()) { |
303 | 0 | steps = configuredEmbedder.stepsFactory().createCandidateSteps(); |
304 | |
} |
305 | 0 | reportStepdocs(configuredEmbedder.configuration(), steps); |
306 | 0 | } else { |
307 | 0 | embedderMonitor.embeddableNotConfigurable(embeddable.getClass().getName()); |
308 | |
} |
309 | 0 | } |
310 | 0 | } |
311 | |
|
312 | |
public void reportStepdocs(Configuration configuration, List<CandidateSteps> candidateSteps) { |
313 | 1 | StepFinder finder = configuration.stepFinder(); |
314 | 1 | StepdocReporter reporter = configuration.stepdocReporter(); |
315 | 1 | List<Object> stepsInstances = finder.stepsInstances(candidateSteps); |
316 | 1 | reporter.stepdocs(finder.stepdocs(candidateSteps), stepsInstances); |
317 | 1 | } |
318 | |
|
319 | |
public void reportMatchingStepdocs(String stepAsString) { |
320 | 3 | Configuration configuration = configuration(); |
321 | 3 | List<CandidateSteps> candidateSteps = candidateSteps(); |
322 | 3 | StepFinder finder = configuration.stepFinder(); |
323 | 3 | StepdocReporter reporter = configuration.stepdocReporter(); |
324 | 3 | List<Stepdoc> matching = finder.findMatching(stepAsString, candidateSteps); |
325 | 3 | List<Object> stepsInstances = finder.stepsInstances(candidateSteps); |
326 | 3 | reporter.stepdocsMatching(stepAsString, matching, stepsInstances); |
327 | 3 | } |
328 | |
|
329 | |
public void processSystemProperties() { |
330 | 26 | Properties properties = systemProperties(); |
331 | 26 | embedderMonitor.processingSystemProperties(properties); |
332 | 26 | if (!properties.isEmpty()) { |
333 | 1 | for (Object key : properties.keySet()) { |
334 | 2 | String name = (String) key; |
335 | 2 | String value = properties.getProperty(name); |
336 | 2 | System.setProperty(name, value); |
337 | 2 | embedderMonitor.systemPropertySet(name, value); |
338 | 2 | } |
339 | |
} |
340 | 26 | } |
341 | |
|
342 | |
public EmbedderClassLoader classLoader() { |
343 | 29 | if (classLoader == null) { |
344 | 16 | this.classLoader = new EmbedderClassLoader(this.getClass().getClassLoader()); |
345 | |
} |
346 | 29 | return classLoader; |
347 | |
} |
348 | |
|
349 | |
public Configuration configuration() { |
350 | 176 | if (configuration == null) { |
351 | 22 | this.configuration = new MostUsefulConfiguration(); |
352 | |
} |
353 | 176 | configureThreads(configuration, embedderControls().threads()); |
354 | 176 | return configuration; |
355 | |
} |
356 | |
|
357 | |
public List<CandidateSteps> candidateSteps() { |
358 | 18 | if (candidateSteps == null) { |
359 | 10 | candidateSteps = new ArrayList<CandidateSteps>(); |
360 | |
} |
361 | 18 | return candidateSteps; |
362 | |
} |
363 | |
|
364 | |
public InjectableStepsFactory stepsFactory() { |
365 | 50 | if (stepsFactory == null) { |
366 | 10 | stepsFactory = new ProvidedStepsFactory(candidateSteps()); |
367 | |
} |
368 | 50 | return stepsFactory; |
369 | |
} |
370 | |
|
371 | |
public EmbedderControls embedderControls() { |
372 | 372 | if (embedderControls == null) { |
373 | 32 | embedderControls = new EmbedderControls(); |
374 | |
} |
375 | 372 | return embedderControls; |
376 | |
} |
377 | |
|
378 | |
public EmbedderMonitor embedderMonitor() { |
379 | 41 | return embedderMonitor; |
380 | |
} |
381 | |
|
382 | |
public EmbedderFailureStrategy embedderFailureStrategy() { |
383 | 8 | if (embedderFailureStrategy == null) { |
384 | 7 | this.embedderFailureStrategy = new ThrowingRunningStoriesFailed(); |
385 | |
} |
386 | 8 | return embedderFailureStrategy; |
387 | |
} |
388 | |
|
389 | |
public boolean hasExecutorService() { |
390 | 1 | return executorService != null; |
391 | |
} |
392 | |
|
393 | |
public ExecutorService executorService() { |
394 | 39 | if (executorService == null) { |
395 | 39 | executorService = createExecutorService(); |
396 | 39 | executorServiceCreated = true; |
397 | |
} |
398 | 39 | return executorService; |
399 | |
} |
400 | |
|
401 | |
|
402 | |
|
403 | |
|
404 | |
|
405 | |
|
406 | |
|
407 | |
private ExecutorService createExecutorService() { |
408 | 39 | return new FixedThreadExecutors().create(embedderControls()); |
409 | |
} |
410 | |
|
411 | |
|
412 | |
|
413 | |
|
414 | |
|
415 | |
|
416 | |
|
417 | |
protected void shutdownExecutorService() { |
418 | 22 | if (executorServiceCreated) { |
419 | 22 | executorService.shutdownNow(); |
420 | 22 | executorService = null; |
421 | 22 | executorServiceCreated = false; |
422 | |
} |
423 | 22 | } |
424 | |
|
425 | |
public StoryManager storyManager() { |
426 | 18 | if (storyManager == null) { |
427 | 17 | storyManager = createStoryManager(); |
428 | |
} |
429 | 18 | return storyManager; |
430 | |
} |
431 | |
|
432 | |
private StoryManager createStoryManager() { |
433 | 39 | return new StoryManager(configuration(), stepsFactory(), embedderControls(), embedderMonitor(), |
434 | 39 | executorService(), performableTree()); |
435 | |
} |
436 | |
|
437 | |
protected void configureThreads(Configuration configuration, int threads) { |
438 | 176 | StoryReporterBuilder reporterBuilder = configuration.storyReporterBuilder(); |
439 | 176 | reporterBuilder.withMultiThreading(threads > 1); |
440 | 176 | configuration.useStoryReporterBuilder(reporterBuilder); |
441 | 176 | } |
442 | |
|
443 | |
public List<String> metaFilters() { |
444 | 34 | if (metaFilters == null) { |
445 | 24 | metaFilters = new ArrayList<String>(); |
446 | |
} |
447 | 34 | return metaFilters; |
448 | |
} |
449 | |
|
450 | |
public MetaFilter metaFilter() { |
451 | 28 | return new MetaFilter(StringUtils.join(metaFilters(), " "), embedderMonitor); |
452 | |
} |
453 | |
|
454 | |
public StoryRunner storyRunner() { |
455 | 0 | return storyRunner; |
456 | |
} |
457 | |
|
458 | |
public PerformableTree performableTree() { |
459 | 41 | return performableTree; |
460 | |
} |
461 | |
|
462 | |
public Properties systemProperties() { |
463 | 29 | if (systemProperties == null) { |
464 | 25 | systemProperties = new Properties(); |
465 | |
} |
466 | 29 | return systemProperties; |
467 | |
} |
468 | |
|
469 | |
public void useClassLoader(EmbedderClassLoader classLoader) { |
470 | 14 | this.classLoader = classLoader; |
471 | 14 | } |
472 | |
|
473 | |
public void useConfiguration(Configuration configuration) { |
474 | 33 | this.configuration = configuration; |
475 | 33 | } |
476 | |
|
477 | |
public void useCandidateSteps(List<CandidateSteps> candidateSteps) { |
478 | 26 | this.candidateSteps = candidateSteps; |
479 | 26 | } |
480 | |
|
481 | |
public void useStepsFactory(InjectableStepsFactory stepsFactory) { |
482 | 26 | this.stepsFactory = stepsFactory; |
483 | 26 | } |
484 | |
|
485 | |
public void useEmbedderControls(EmbedderControls embedderControls) { |
486 | 29 | this.embedderControls = embedderControls; |
487 | 29 | } |
488 | |
|
489 | |
public void useEmbedderFailureStrategy(EmbedderFailureStrategy failureStategy) { |
490 | 1 | this.embedderFailureStrategy = failureStategy; |
491 | 1 | } |
492 | |
|
493 | |
public void useEmbedderMonitor(EmbedderMonitor embedderMonitor) { |
494 | 1 | this.embedderMonitor = embedderMonitor; |
495 | 1 | } |
496 | |
|
497 | |
public void useExecutorService(ExecutorService executorService) { |
498 | 0 | this.executorService = executorService; |
499 | 0 | embedderMonitor.usingExecutorService(executorService); |
500 | 0 | } |
501 | |
|
502 | |
public void useMetaFilters(List<String> metaFilters) { |
503 | 4 | this.metaFilters = metaFilters; |
504 | 4 | } |
505 | |
|
506 | |
public void usePerformableTree(PerformableTree performableTree) { |
507 | 1 | this.performableTree = performableTree; |
508 | 1 | } |
509 | |
|
510 | |
public void useStoryRunner(StoryRunner storyRunner) { |
511 | 0 | this.storyRunner = storyRunner; |
512 | 0 | } |
513 | |
|
514 | |
public void useSystemProperties(Properties systemProperties) { |
515 | 2 | this.systemProperties = systemProperties; |
516 | 2 | } |
517 | |
|
518 | |
@Override |
519 | |
public String toString() { |
520 | 1 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); |
521 | |
} |
522 | |
|
523 | |
public static interface EmbedderFailureStrategy { |
524 | |
|
525 | |
void handleFailures(BatchFailures failures); |
526 | |
|
527 | |
void handleFailures(ReportsCount count); |
528 | |
|
529 | |
} |
530 | |
|
531 | 7 | public static class ThrowingRunningStoriesFailed implements EmbedderFailureStrategy { |
532 | |
|
533 | |
public void handleFailures(BatchFailures failures) { |
534 | 3 | throw new RunningStoriesFailed(failures); |
535 | |
} |
536 | |
|
537 | |
public void handleFailures(ReportsCount count) { |
538 | 4 | throw new RunningStoriesFailed(count); |
539 | |
} |
540 | |
|
541 | |
} |
542 | |
|
543 | |
@SuppressWarnings("serial") |
544 | |
public static class AnnotatedEmbedderRunFailed extends RuntimeException { |
545 | |
|
546 | |
public AnnotatedEmbedderRunFailed(AnnotatedEmbedderRunner runner, Throwable cause) { |
547 | 1 | super("Annotated embedder run failed with runner " + runner.toString(), cause); |
548 | 1 | } |
549 | |
|
550 | |
} |
551 | |
|
552 | |
@SuppressWarnings("serial") |
553 | |
public static class RunningEmbeddablesFailed extends RuntimeException { |
554 | |
|
555 | |
public RunningEmbeddablesFailed(String name, Throwable failure) { |
556 | 11 | super("Failure in running embeddable: " + name, failure); |
557 | 11 | } |
558 | |
|
559 | |
public RunningEmbeddablesFailed(BatchFailures failures) { |
560 | 1 | super("Failures in running embeddables: " + failures); |
561 | 1 | } |
562 | |
|
563 | |
} |
564 | |
|
565 | |
@SuppressWarnings("serial") |
566 | |
public static class RunningStoriesFailed extends RuntimeException { |
567 | |
|
568 | |
public RunningStoriesFailed(ReportsCount reportsCount) { |
569 | 4 | super("Failures in running stories: " + reportsCount); |
570 | 4 | } |
571 | |
|
572 | |
public RunningStoriesFailed(BatchFailures failures) { |
573 | 3 | super("Failures in running stories: " + failures); |
574 | 3 | } |
575 | |
|
576 | |
} |
577 | |
|
578 | |
@SuppressWarnings("serial") |
579 | |
public static class ViewGenerationFailed extends RuntimeException { |
580 | |
public ViewGenerationFailed(File outputDirectory, List<String> formats, Properties viewResources, |
581 | |
RuntimeException cause) { |
582 | 1 | super("View generation failed to " + outputDirectory + " for formats " + formats + " and resources " |
583 | |
+ viewResources, cause); |
584 | 1 | } |
585 | |
|
586 | |
public ViewGenerationFailed(File outputDirectory, StoryMaps storyMaps, Properties viewResources, |
587 | |
RuntimeException cause) { |
588 | 0 | super("View generation failed to " + outputDirectory + " for story maps " + storyMaps + " for resources " |
589 | |
+ viewResources, cause); |
590 | 0 | } |
591 | |
} |
592 | |
|
593 | |
|
594 | |
} |