Coverage Report - org.jbehave.core.configuration.UnmodifiableConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
UnmodifiableConfiguration
100%
40/40
N/A
1.436
UnmodifiableConfiguration$ModificationNotAllowed
100%
2/2
N/A
1.436
 
 1  
 package org.jbehave.core.configuration;
 2  
 
 3  
 import org.apache.commons.lang.builder.ToStringBuilder;
 4  
 import org.apache.commons.lang.builder.ToStringStyle;
 5  
 import org.jbehave.core.embedder.StoryControls;
 6  
 import org.jbehave.core.failures.FailureStrategy;
 7  
 import org.jbehave.core.failures.PendingStepStrategy;
 8  
 import org.jbehave.core.io.StoryLoader;
 9  
 import org.jbehave.core.io.StoryPathResolver;
 10  
 import org.jbehave.core.parsers.StepPatternParser;
 11  
 import org.jbehave.core.parsers.StoryParser;
 12  
 import org.jbehave.core.reporters.StoryReporter;
 13  
 import org.jbehave.core.reporters.StoryReporterBuilder;
 14  
 import org.jbehave.core.reporters.ViewGenerator;
 15  
 import org.jbehave.core.steps.ParameterControls;
 16  
 import org.jbehave.core.steps.ParameterConverters;
 17  
 import org.jbehave.core.steps.StepCollector;
 18  
 import org.jbehave.core.steps.StepMonitor;
 19  
 
 20  
 import com.thoughtworks.paranamer.Paranamer;
 21  
 
 22  
 /**
 23  
  * Decorator of Configuration that disables modification of configuration
 24  
  * elements.
 25  
  */
 26  
 public class UnmodifiableConfiguration extends Configuration {
 27  
 
 28  
     private final Configuration delegate;
 29  
 
 30  3
     public UnmodifiableConfiguration(Configuration delegate) {
 31  3
         this.delegate = delegate;
 32  3
     }
 33  
 
 34  
     /**
 35  
      * @deprecated Use {@link StoryReporterBuilder}
 36  
      */
 37  
     public StoryReporter defaultStoryReporter() {
 38  1
         return delegate.defaultStoryReporter();
 39  
     }
 40  
 
 41  
     public StoryParser storyParser() {
 42  1
         return delegate.storyParser();
 43  
     }
 44  
 
 45  
     public PendingStepStrategy pendingStepStrategy() {
 46  1
         return delegate.pendingStepStrategy();
 47  
     }
 48  
 
 49  
     public StepCollector stepCollector() {
 50  1
         return delegate.stepCollector();
 51  
     }
 52  
 
 53  
     public FailureStrategy failureStrategy() {
 54  1
         return delegate.failureStrategy();
 55  
     }
 56  
 
 57  
     public Keywords keywords() {
 58  1
         return delegate.keywords();
 59  
     }
 60  
 
 61  
     public ParameterConverters parameterConverters() {
 62  1
         return delegate.parameterConverters();
 63  
     }
 64  
 
 65  
     public ParameterControls parameterControls(){
 66  1
         return delegate.parameterControls();
 67  
     }
 68  
     
 69  
     public Paranamer paranamer() {
 70  1
         return delegate.paranamer();
 71  
     }
 72  
 
 73  
     public ViewGenerator viewGenerator() {
 74  1
         return delegate.viewGenerator();
 75  
     }
 76  
 
 77  
     public StepMonitor stepMonitor() {
 78  1
         return delegate.stepMonitor();
 79  
     }
 80  
 
 81  
     public StepPatternParser stepPatternParser() {
 82  1
         return delegate.stepPatternParser();
 83  
     }
 84  
 
 85  
     public boolean dryRun() {
 86  1
         return delegate.dryRun();
 87  
     }
 88  
 
 89  
     public StoryControls storyControls() {
 90  1
         return delegate.storyControls();
 91  
     }
 92  
 
 93  
     public StoryLoader storyLoader() {
 94  1
         return delegate.storyLoader();
 95  
     }
 96  
 
 97  
     public StoryPathResolver storyPathResolver() {
 98  1
         return delegate.storyPathResolver();
 99  
     }
 100  
 
 101  
     public StoryReporter storyReporter(String storyPath) {
 102  1
         return delegate.storyReporter(storyPath);
 103  
     }
 104  
 
 105  
     public StoryReporterBuilder storyReporterBuilder() {
 106  1
         return delegate.storyReporterBuilder();
 107  
     }
 108  
 
 109  
     @Override
 110  
     public Configuration useKeywords(Keywords keywords) {
 111  1
         throw notAllowed();
 112  
     }
 113  
 
 114  
     @Override
 115  
     public Configuration useStepCollector(StepCollector stepCollector) {
 116  1
         throw notAllowed();
 117  
     }
 118  
 
 119  
     @Override
 120  
     public Configuration usePendingStepStrategy(PendingStepStrategy pendingStepStrategy) {
 121  1
         throw notAllowed();
 122  
     }
 123  
 
 124  
     @Override
 125  
     public Configuration useFailureStrategy(FailureStrategy failureStrategy) {
 126  1
         throw notAllowed();
 127  
     }
 128  
 
 129  
     @Override
 130  
     public Configuration doDryRun(Boolean dryRun) {
 131  1
         throw notAllowed();
 132  
     }
 133  
 
 134  
     @Override
 135  
     public Configuration useStoryControls(StoryControls storyControls) {
 136  1
         throw notAllowed();
 137  
     }
 138  
 
 139  
     @Override
 140  
     public Configuration useStoryParser(StoryParser storyParser) {
 141  1
         throw notAllowed();
 142  
     }
 143  
 
 144  
     @Override
 145  
     public Configuration useDefaultStoryReporter(StoryReporter storyReporter) {
 146  1
         throw notAllowed();
 147  
     }
 148  
 
 149  
     @Override
 150  
     public Configuration useParameterConverters(ParameterConverters parameterConverters) {
 151  1
         throw notAllowed();
 152  
     }
 153  
     
 154  
     @Override
 155  
     public Configuration useParameterControls(ParameterControls parameterControls) {
 156  1
         throw notAllowed();
 157  
     }    
 158  
 
 159  
     @Override
 160  
     public Configuration useParanamer(Paranamer paranamer) {
 161  1
         throw notAllowed();
 162  
     }
 163  
 
 164  
     @Override
 165  
     public Configuration useStepMonitor(StepMonitor stepMonitor) {
 166  1
         throw notAllowed();
 167  
     }
 168  
 
 169  
     @Override
 170  
     public Configuration useStepPatternParser(StepPatternParser stepPatternParser) {
 171  1
         throw notAllowed();
 172  
     }
 173  
 
 174  
     @Override
 175  
     public Configuration useViewGenerator(ViewGenerator viewGenerator) {
 176  1
         throw notAllowed();
 177  
     }
 178  
 
 179  
     @Override
 180  
     public Configuration useStoryLoader(StoryLoader storyLoader) {
 181  1
         throw notAllowed();
 182  
     }
 183  
 
 184  
     @Override
 185  
     public Configuration useStoryPathResolver(StoryPathResolver storyPathResolver) {
 186  2
         throw notAllowed();
 187  
     }
 188  
 
 189  
     @Override
 190  
     public Configuration useStoryReporterBuilder(StoryReporterBuilder storyReporterBuilder) {
 191  1
         throw notAllowed();
 192  
     }
 193  
 
 194  
     private RuntimeException notAllowed() {
 195  18
         return new ModificationNotAllowed();
 196  
     }
 197  
 
 198  
     @Override
 199  
     public String toString() {
 200  1
         return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append(delegate).toString();
 201  
     }
 202  
 
 203  
     @SuppressWarnings("serial")
 204  
     public static class ModificationNotAllowed extends RuntimeException {
 205  
         public ModificationNotAllowed(){
 206  18
             super("Configuration elements are unmodifiable");
 207  18
         }
 208  
     }
 209  
 }