##### Coverage Report - org.jbehave.core.embedder.PropertyBasedEmbedderControls

Classes in this File | Line Coverage | Branch Coverage | Complexity
PropertyBasedEmbedderControls |
100% | 16/16
100% | 2/2
| 1.1818181818181819;1.182

1 |  |
     package org.jbehave.core.embedder;
2 |  |
3 |  |
     import org.apache.commons.lang.builder.ToStringBuilder;
4 |  |
     import org.apache.commons.lang.builder.ToStringStyle;
5 |  |
     import org.jbehave.core.steps.ParameterConverters;
6 |  |
7 | 1 |
     public class PropertyBasedEmbedderControls extends EmbedderControls {
8 |  |
9 |  |
         public static final String BATCH = "BATCH";
10 |  |
         public static final String IGNORE_FAILURE_IN_VIEW = "IGNORE_FAILURE_IN_VIEW";
11 |  |
         public static final String IGNORE_FAILURE_IN_STORIES = "IGNORE_FAILURE_IN_STORIES";
12 |  |
         public static final String GENERATE_VIEW_AFTER_STORIES = "GENERATE_VIEW_AFTER_STORIES";
13 |  |
         public static final String SKIP = "SKIP";
14 |  |
         public static final String VERBOSE_FAILURES = "VERBOSE_FAILURES";
15 |  |
         public static final String VERBOSE_FILTERING = "VERBOSE_FILTERING";
16 |  |
         public static final String STORY_TIMEOUT_IN_SECS = "STORY_TIMEOUT_IN_SECS";
17 |  |
         public static final String THREADS = "THREADS";
18 |  |
19 | 1 |
         private ParameterConverters converters = new ParameterConverters();
20 |  |
21 |  |
         @Override
22 |  |
         public boolean batch() {
23 | 2 |
             return propertyAs(BATCH, Boolean.class, super.batch());
24 |  |
         }
25 |  |
26 |  |
         @Override
27 |  |
         public boolean ignoreFailureInView() {
28 | 2 |
             return propertyAs(IGNORE_FAILURE_IN_VIEW, Boolean.class, super.ignoreFailureInView());
29 |  |
         }
30 |  |
31 |  |
         @Override
32 |  |
         public boolean ignoreFailureInStories() {
33 | 2 |
             return propertyAs(IGNORE_FAILURE_IN_STORIES, Boolean.class, super.ignoreFailureInStories());
34 |  |
         }
35 |  |
36 |  |
         @Override
37 |  |
         public boolean generateViewAfterStories() {
38 | 2 |
             return propertyAs(GENERATE_VIEW_AFTER_STORIES, Boolean.class, super.generateViewAfterStories());
39 |  |
         }
40 |  |
41 |  |
         @Override
42 |  |
         public boolean skip() {
43 | 2 |
             return propertyAs(SKIP, Boolean.class, super.skip());
44 |  |
         }
45 |  |
46 |  |
         @Override
47 |  |
         public boolean verboseFailures() {
48 | 2 |
             return propertyAs(VERBOSE_FAILURES, Boolean.class, super.verboseFailures());
49 |  |
         }
50 |  |
51 |  |
         @Override
52 |  |
         public boolean verboseFiltering() {
53 | 2 |
             return propertyAs(VERBOSE_FILTERING, Boolean.class, super.verboseFiltering());
54 |  |
         }
55 |  |
56 |  |
         @Override
57 |  |
         public long storyTimeoutInSecs() {
58 | 2 |
             return propertyAs(STORY_TIMEOUT_IN_SECS, Long.class, super.storyTimeoutInSecs());
59 |  |
         }
60 |  |
61 |  |
         @Override
62 |  |
         public int threads() {
63 | 2 |
             return propertyAs(THREADS, Integer.class, super.threads());
64 |  |
         }
65 |  |
66 |  |
         @SuppressWarnings("unchecked")
67 |  |
         private <T> T propertyAs(String name, Class<T> type, T defaultValue) {
68 | 18 |
             String property = System.getProperty(name);
69 | 18 |
             if ( property == null ){
70 | 9 |
                 return defaultValue;
71 |  |
             }
72 | 9 |
             return (T) converters.convert(property, type);
73 |  |
         }
74 |  |
75 |  |
         @Override
76 |  |
         public String toString() {
77 | 1 |
             return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
78 |  |
         }
79 |  |
80 |  |
     }