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