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