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