| 1 | |
package org.jbehave.core.embedder; |
| 2 | |
|
| 3 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
| 4 | |
import org.apache.commons.lang.builder.ToStringStyle; |
| 5 | |
|
| 6 | |
public class UnmodifiableEmbedderControls extends EmbedderControls { |
| 7 | |
|
| 8 | |
private EmbedderControls delegate; |
| 9 | |
|
| 10 | 1 | public UnmodifiableEmbedderControls(EmbedderControls delegate) { |
| 11 | 1 | this.delegate = delegate; |
| 12 | 1 | } |
| 13 | |
|
| 14 | |
@Override |
| 15 | |
public boolean batch() { |
| 16 | 1 | return delegate.batch(); |
| 17 | |
} |
| 18 | |
|
| 19 | |
@Override |
| 20 | |
public boolean ignoreFailureInView() { |
| 21 | 1 | return delegate.ignoreFailureInView(); |
| 22 | |
} |
| 23 | |
|
| 24 | |
@Override |
| 25 | |
public boolean ignoreFailureInStories() { |
| 26 | 1 | return delegate.ignoreFailureInStories(); |
| 27 | |
} |
| 28 | |
|
| 29 | |
@Override |
| 30 | |
public boolean generateViewAfterStories() { |
| 31 | 1 | return delegate.generateViewAfterStories(); |
| 32 | |
} |
| 33 | |
|
| 34 | |
@Override |
| 35 | |
public boolean skip() { |
| 36 | 1 | return delegate.skip(); |
| 37 | |
} |
| 38 | |
|
| 39 | |
@Override |
| 40 | |
public long storyTimeoutInSecs() { |
| 41 | 1 | return delegate.storyTimeoutInSecs(); |
| 42 | |
} |
| 43 | |
|
| 44 | |
@Override |
| 45 | |
public int threads() { |
| 46 | 1 | return delegate.threads(); |
| 47 | |
} |
| 48 | |
|
| 49 | |
@Override |
| 50 | |
public EmbedderControls doBatch(boolean batch) { |
| 51 | 1 | throw notAllowed(); |
| 52 | |
} |
| 53 | |
|
| 54 | |
@Override |
| 55 | |
public EmbedderControls doIgnoreFailureInView(boolean ignoreFailureInReports) { |
| 56 | 1 | throw notAllowed(); |
| 57 | |
} |
| 58 | |
|
| 59 | |
@Override |
| 60 | |
public EmbedderControls doIgnoreFailureInStories(boolean ignoreFailureInStories) { |
| 61 | 1 | throw notAllowed(); |
| 62 | |
} |
| 63 | |
|
| 64 | |
@Override |
| 65 | |
public EmbedderControls doGenerateViewAfterStories(boolean generateViewAfterStories) { |
| 66 | 1 | throw notAllowed(); |
| 67 | |
} |
| 68 | |
|
| 69 | |
@Override |
| 70 | |
public EmbedderControls doSkip(boolean skip) { |
| 71 | 1 | throw notAllowed(); |
| 72 | |
} |
| 73 | |
|
| 74 | |
@Override |
| 75 | |
public EmbedderControls useStoryTimeoutInSecs(long storyTimeoutInSecs) { |
| 76 | 1 | throw notAllowed(); |
| 77 | |
} |
| 78 | |
|
| 79 | |
@Override |
| 80 | |
public EmbedderControls useThreads(int threads) { |
| 81 | 1 | throw notAllowed(); |
| 82 | |
} |
| 83 | |
|
| 84 | |
private RuntimeException notAllowed() { |
| 85 | 7 | return new ModificationNotAllowed(); |
| 86 | |
} |
| 87 | |
|
| 88 | |
@Override |
| 89 | |
public String toString() { |
| 90 | 1 | return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append(delegate).toString(); |
| 91 | |
} |
| 92 | |
|
| 93 | |
@SuppressWarnings("serial") |
| 94 | |
public static class ModificationNotAllowed extends RuntimeException { |
| 95 | |
public ModificationNotAllowed() { |
| 96 | 7 | super("Configuration elements are unmodifiable"); |
| 97 | 7 | } |
| 98 | |
} |
| 99 | |
|
| 100 | |
} |