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