Coverage Report - org.jbehave.core.embedder.PropertyBasedEmbedderControls
 
Classes in this File Line Coverage Branch Coverage Complexity
PropertyBasedEmbedderControls
100%
14/14
100%
2/2
1.222
 
 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 STORY_TIMEOUT_IN_SECS = "STORY_TIMEOUT_IN_SECS";
 15  
     public static final String THREADS = "THREADS";
 16  
 
 17  1
     private ParameterConverters converters = new ParameterConverters();
 18  
 
 19  
     @Override
 20  
     public boolean batch() {
 21  2
         return propertyAs(BATCH, Boolean.class, super.batch());
 22  
     }
 23  
 
 24  
     @Override
 25  
     public boolean ignoreFailureInView() {
 26  2
         return propertyAs(IGNORE_FAILURE_IN_VIEW, Boolean.class, super.ignoreFailureInView()); 
 27  
     }
 28  
 
 29  
     @Override
 30  
     public boolean ignoreFailureInStories() {
 31  2
         return propertyAs(IGNORE_FAILURE_IN_STORIES, Boolean.class, super.ignoreFailureInStories()); 
 32  
     }
 33  
 
 34  
     @Override
 35  
     public boolean generateViewAfterStories() {
 36  2
         return propertyAs(GENERATE_VIEW_AFTER_STORIES, Boolean.class, super.generateViewAfterStories()); 
 37  
     }
 38  
 
 39  
     @Override
 40  
     public boolean skip() {
 41  2
         return propertyAs(SKIP, Boolean.class, super.skip()); 
 42  
     }
 43  
     
 44  
     @Override
 45  
     public long storyTimeoutInSecs() {
 46  2
         return propertyAs(STORY_TIMEOUT_IN_SECS, Long.class, super.storyTimeoutInSecs()); 
 47  
     }
 48  
 
 49  
     @Override
 50  
     public int threads() {
 51  2
         return propertyAs(THREADS, Integer.class, super.threads()); 
 52  
     }
 53  
    
 54  
     @SuppressWarnings("unchecked")
 55  
     private <T> T propertyAs(String name, Class<T> type, T defaultValue) {
 56  14
         String property = System.getProperty(name);
 57  14
         if ( property == null ){
 58  7
             return defaultValue;
 59  
         }
 60  7
         return (T) converters.convert(property, type);
 61  
     }
 62  
 
 63  
     @Override
 64  
     public String toString() {
 65  1
         return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
 66  
     }
 67  
     
 68  
 }