Coverage Report - org.jbehave.core.embedder.PropertyBasedEmbedderControls
 
Classes in this File Line Coverage Branch Coverage Complexity
PropertyBasedEmbedderControls
100%
29/29
100%
2/2
1.154
 
 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 STORY_TIMEOUT_IN_SECS_BY_PATH = "STORY_TIMEOUT_IN_SECS_BY_PATH";
 18  
     public static final String FAIL_ON_STORY_TIMEOUT = "FAIL_ON_STORY_TIMEOUT";
 19  
     public static final String THREADS = "THREADS";
 20  
 
 21  1
     private ParameterConverters converters = new ParameterConverters();
 22  
 
 23  
     @Override
 24  
     public boolean batch() {
 25  3
         return propertyAs(BATCH, Boolean.class, super.batch());
 26  
     }
 27  
 
 28  
     @Override
 29  
     public boolean ignoreFailureInView() {
 30  3
         return propertyAs(IGNORE_FAILURE_IN_VIEW, Boolean.class, super.ignoreFailureInView()); 
 31  
     }
 32  
 
 33  
     @Override
 34  
     public boolean ignoreFailureInStories() {
 35  3
         return propertyAs(IGNORE_FAILURE_IN_STORIES, Boolean.class, super.ignoreFailureInStories()); 
 36  
     }
 37  
 
 38  
     @Override
 39  
     public boolean generateViewAfterStories() {
 40  3
         return propertyAs(GENERATE_VIEW_AFTER_STORIES, Boolean.class, super.generateViewAfterStories()); 
 41  
     }
 42  
 
 43  
     @Override
 44  
     public boolean skip() {
 45  3
         return propertyAs(SKIP, Boolean.class, super.skip()); 
 46  
     }
 47  
     
 48  
     @Override
 49  
     public boolean verboseFailures() {
 50  3
         return propertyAs(VERBOSE_FAILURES, Boolean.class, super.verboseFailures()); 
 51  
     }
 52  
 
 53  
     @Override
 54  
     public boolean verboseFiltering() {
 55  3
         return propertyAs(VERBOSE_FILTERING, Boolean.class, super.verboseFiltering()); 
 56  
     }
 57  
     
 58  
     @Override
 59  
     public long storyTimeoutInSecs() {
 60  3
         return propertyAs(STORY_TIMEOUT_IN_SECS, Long.class, super.storyTimeoutInSecs()); 
 61  
     }
 62  
     
 63  
     @Override
 64  
     public String storyTimeoutInSecsByPath() {
 65  3
         return propertyAs(STORY_TIMEOUT_IN_SECS_BY_PATH, String.class, super.storyTimeoutInSecsByPath()); 
 66  
     }
 67  
 
 68  
     @Override
 69  
         public boolean failOnStoryTimeout() {
 70  2
         return propertyAs(FAIL_ON_STORY_TIMEOUT, Boolean.class, super.failOnStoryTimeout()); 
 71  
         }
 72  
 
 73  
     @Override
 74  
     public int threads() {
 75  3
         return propertyAs(THREADS, Integer.class, super.threads()); 
 76  
     }
 77  
    
 78  
     @SuppressWarnings("unchecked")
 79  
     private <T> T propertyAs(String name, Class<T> type, T defaultValue) {
 80  32
         String property = System.getProperty(name);
 81  32
         if ( property == null ){
 82  21
             return defaultValue;
 83  
         }
 84  11
         return (T) converters.convert(property, type);
 85  
     }
 86  
 
 87  
     @Override
 88  
     public String toString() {
 89  
         // Calling accessor methods to show the expected system based values
 90  
         // rather than the object values
 91  1
         return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
 92  1
         .append("batch", batch())
 93  1
         .append("skip", skip())
 94  1
         .append("generateViewAfterStories", generateViewAfterStories())
 95  1
         .append("ignoreFailureInStories", ignoreFailureInStories())
 96  1
         .append("ignoreFailureInView", ignoreFailureInView())
 97  1
         .append("verboseFailures", verboseFailures())
 98  1
         .append("verboseFiltering", verboseFiltering())
 99  1
         .append("storyTimeoutInSecs", storyTimeoutInSecs())
 100  1
         .append("storyTimeoutInSecsByPath", storyTimeoutInSecsByPath())
 101  1
         .append("threads", threads())
 102  1
         .toString();        
 103  
     }
 104  
     
 105  
 }