| 1 | |
package org.jbehave.core.configuration; |
| 2 | |
|
| 3 | |
import com.thoughtworks.paranamer.BytecodeReadingParanamer; |
| 4 | |
import com.thoughtworks.paranamer.CachingParanamer; |
| 5 | |
import com.thoughtworks.paranamer.NullParanamer; |
| 6 | |
import com.thoughtworks.paranamer.Paranamer; |
| 7 | |
import org.jbehave.core.Embeddable; |
| 8 | |
import org.jbehave.core.embedder.Embedder; |
| 9 | |
import org.jbehave.core.embedder.StoryControls; |
| 10 | |
import org.jbehave.core.failures.FailingUponPendingStep; |
| 11 | |
import org.jbehave.core.failures.FailureStrategy; |
| 12 | |
import org.jbehave.core.failures.PassingUponPendingStep; |
| 13 | |
import org.jbehave.core.failures.PendingStepStrategy; |
| 14 | |
import org.jbehave.core.failures.RethrowingFailure; |
| 15 | |
import org.jbehave.core.failures.SilentlyAbsorbingFailure; |
| 16 | |
import org.jbehave.core.i18n.LocalizedKeywords; |
| 17 | |
import org.jbehave.core.io.LoadFromClasspath; |
| 18 | |
import org.jbehave.core.io.StoryLoader; |
| 19 | |
import org.jbehave.core.io.StoryPathResolver; |
| 20 | |
import org.jbehave.core.io.UnderscoredCamelCaseResolver; |
| 21 | |
import org.jbehave.core.parsers.RegexPrefixCapturingPatternParser; |
| 22 | |
import org.jbehave.core.parsers.RegexStoryParser; |
| 23 | |
import org.jbehave.core.parsers.StepPatternParser; |
| 24 | |
import org.jbehave.core.parsers.StoryParser; |
| 25 | |
import org.jbehave.core.reporters.ConsoleOutput; |
| 26 | |
import org.jbehave.core.reporters.FreemarkerViewGenerator; |
| 27 | |
import org.jbehave.core.reporters.PrintStreamStepdocReporter; |
| 28 | |
import org.jbehave.core.reporters.StepdocReporter; |
| 29 | |
import org.jbehave.core.reporters.StoryReporter; |
| 30 | |
import org.jbehave.core.reporters.StoryReporterBuilder; |
| 31 | |
import org.jbehave.core.reporters.ViewGenerator; |
| 32 | |
import org.jbehave.core.steps.MarkUnmatchedStepsAsPending; |
| 33 | |
import org.jbehave.core.steps.ParameterConverters; |
| 34 | |
import org.jbehave.core.steps.PrintStreamStepMonitor; |
| 35 | |
import org.jbehave.core.steps.SilentStepMonitor; |
| 36 | |
import org.jbehave.core.steps.StepCollector; |
| 37 | |
import org.jbehave.core.steps.StepFinder; |
| 38 | |
import org.jbehave.core.steps.StepMonitor; |
| 39 | |
|
| 40 | |
import java.util.HashMap; |
| 41 | |
import java.util.Map; |
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | 206 | public abstract class Configuration { |
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | 206 | private StoryControls storyControls = new StoryControls(); |
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | 206 | private Keywords keywords = new LocalizedKeywords(); |
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | 206 | private StepCollector stepCollector = new MarkUnmatchedStepsAsPending(); |
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | 206 | private StoryParser storyParser = new RegexStoryParser(keywords); |
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | 206 | private StoryLoader storyLoader = new LoadFromClasspath(); |
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | 206 | private StoryPathResolver storyPathResolver = new UnderscoredCamelCaseResolver(); |
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | 206 | private FailureStrategy failureStrategy = new RethrowingFailure(); |
| 101 | |
|
| 102 | |
|
| 103 | |
|
| 104 | |
|
| 105 | |
|
| 106 | |
|
| 107 | |
|
| 108 | |
|
| 109 | 206 | private PendingStepStrategy pendingStepStrategy = new PassingUponPendingStep(); |
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | |
|
| 114 | 206 | private StoryReporter defaultStoryReporter = new ConsoleOutput(); |
| 115 | |
|
| 116 | |
|
| 117 | |
|
| 118 | |
|
| 119 | 206 | private Map<String, StoryReporter> storyReporters = new HashMap<String, StoryReporter>(); |
| 120 | |
|
| 121 | |
|
| 122 | |
|
| 123 | |
|
| 124 | 206 | private StoryReporterBuilder storyReporterBuilder = new StoryReporterBuilder(); |
| 125 | |
|
| 126 | |
|
| 127 | |
|
| 128 | |
|
| 129 | 206 | private StepFinder stepFinder = new StepFinder(); |
| 130 | |
|
| 131 | |
|
| 132 | |
|
| 133 | |
|
| 134 | 206 | private StepdocReporter stepdocReporter = new PrintStreamStepdocReporter(); |
| 135 | |
|
| 136 | |
|
| 137 | |
|
| 138 | |
|
| 139 | 206 | private StepPatternParser stepPatternParser = new RegexPrefixCapturingPatternParser(); |
| 140 | |
|
| 141 | |
|
| 142 | |
|
| 143 | |
|
| 144 | |
|
| 145 | |
|
| 146 | 206 | private StepMonitor stepMonitor = new SilentStepMonitor(); |
| 147 | |
|
| 148 | |
|
| 149 | |
|
| 150 | |
|
| 151 | 206 | private Paranamer paranamer = new NullParanamer(); |
| 152 | |
|
| 153 | |
|
| 154 | |
|
| 155 | |
|
| 156 | 206 | private ParameterConverters parameterConverters = new ParameterConverters(); |
| 157 | |
|
| 158 | |
|
| 159 | |
|
| 160 | |
|
| 161 | 206 | private ViewGenerator viewGenerator = new FreemarkerViewGenerator(); |
| 162 | |
|
| 163 | |
public Keywords keywords() { |
| 164 | 254 | return keywords; |
| 165 | |
} |
| 166 | |
|
| 167 | |
public boolean dryRun() { |
| 168 | 2 | return storyControls.dryRun(); |
| 169 | |
} |
| 170 | |
|
| 171 | |
public StoryControls storyControls() { |
| 172 | 90 | return storyControls; |
| 173 | |
} |
| 174 | |
|
| 175 | |
public StoryParser storyParser() { |
| 176 | 4 | return storyParser; |
| 177 | |
} |
| 178 | |
|
| 179 | |
public StoryLoader storyLoader() { |
| 180 | 4 | return storyLoader; |
| 181 | |
} |
| 182 | |
|
| 183 | |
public StoryPathResolver storyPathResolver() { |
| 184 | 22 | return storyPathResolver; |
| 185 | |
} |
| 186 | |
|
| 187 | |
public FailureStrategy failureStrategy() { |
| 188 | 18 | return failureStrategy; |
| 189 | |
} |
| 190 | |
|
| 191 | |
public PendingStepStrategy pendingStepStrategy() { |
| 192 | 19 | return pendingStepStrategy; |
| 193 | |
} |
| 194 | |
|
| 195 | |
public StoryReporter defaultStoryReporter() { |
| 196 | 22 | return defaultStoryReporter; |
| 197 | |
} |
| 198 | |
|
| 199 | |
public StoryReporter storyReporter(String storyPath) { |
| 200 | 22 | StoryReporter storyReporter = storyReporters.get(storyPath); |
| 201 | 22 | if (storyReporter != null) { |
| 202 | 4 | return storyReporter; |
| 203 | |
} |
| 204 | |
|
| 205 | 18 | return defaultStoryReporter(); |
| 206 | |
} |
| 207 | |
|
| 208 | |
public StoryReporterBuilder storyReporterBuilder() { |
| 209 | 34 | return storyReporterBuilder; |
| 210 | |
} |
| 211 | |
|
| 212 | |
public StepCollector stepCollector() { |
| 213 | 20 | return stepCollector; |
| 214 | |
} |
| 215 | |
|
| 216 | |
public StepFinder stepFinder() { |
| 217 | 4 | return stepFinder; |
| 218 | |
} |
| 219 | |
|
| 220 | |
public StepdocReporter stepdocReporter() { |
| 221 | 4 | return stepdocReporter; |
| 222 | |
} |
| 223 | |
|
| 224 | |
public StepPatternParser stepPatternParser() { |
| 225 | 49 | return stepPatternParser; |
| 226 | |
} |
| 227 | |
|
| 228 | |
public StepMonitor stepMonitor() { |
| 229 | 49 | return stepMonitor; |
| 230 | |
} |
| 231 | |
|
| 232 | |
public Paranamer paranamer() { |
| 233 | 49 | return paranamer; |
| 234 | |
} |
| 235 | |
|
| 236 | |
public ParameterConverters parameterConverters() { |
| 237 | 62 | return parameterConverters; |
| 238 | |
} |
| 239 | |
|
| 240 | |
public ViewGenerator viewGenerator() { |
| 241 | 20 | return viewGenerator; |
| 242 | |
} |
| 243 | |
|
| 244 | |
public Configuration useKeywords(Keywords keywords) { |
| 245 | 215 | this.keywords = keywords; |
| 246 | 215 | return this; |
| 247 | |
} |
| 248 | |
|
| 249 | |
public Configuration doDryRun(Boolean dryRun) { |
| 250 | 0 | this.storyControls.doDryRun(dryRun); |
| 251 | 0 | return this; |
| 252 | |
} |
| 253 | |
|
| 254 | |
public Configuration useStoryControls(StoryControls storyControls){ |
| 255 | 212 | this.storyControls = storyControls; |
| 256 | 212 | return this; |
| 257 | |
} |
| 258 | |
|
| 259 | |
public Configuration usePendingStepStrategy(PendingStepStrategy pendingStepStrategy) { |
| 260 | 228 | this.pendingStepStrategy = pendingStepStrategy; |
| 261 | 228 | return this; |
| 262 | |
} |
| 263 | |
|
| 264 | |
public Configuration useFailureStrategy(FailureStrategy failureStrategy) { |
| 265 | 228 | this.failureStrategy = failureStrategy; |
| 266 | 228 | return this; |
| 267 | |
} |
| 268 | |
|
| 269 | |
public Configuration useStoryParser(StoryParser storyParser) { |
| 270 | 228 | this.storyParser = storyParser; |
| 271 | 228 | return this; |
| 272 | |
} |
| 273 | |
|
| 274 | |
public Configuration useStoryLoader(StoryLoader storyLoader) { |
| 275 | 228 | this.storyLoader = storyLoader; |
| 276 | 228 | return this; |
| 277 | |
} |
| 278 | |
|
| 279 | |
public Configuration useStoryPathResolver(StoryPathResolver storyPathResolver) { |
| 280 | 11 | this.storyPathResolver = storyPathResolver; |
| 281 | 11 | return this; |
| 282 | |
} |
| 283 | |
|
| 284 | |
public Configuration useDefaultStoryReporter(StoryReporter storyReporter) { |
| 285 | 228 | this.defaultStoryReporter = storyReporter; |
| 286 | 228 | return this; |
| 287 | |
} |
| 288 | |
|
| 289 | |
public Configuration useStoryReporter(String storyPath, StoryReporter storyReporter) { |
| 290 | 4 | this.storyReporters.put(storyPath, storyReporter); |
| 291 | 4 | return this; |
| 292 | |
} |
| 293 | |
|
| 294 | |
public Configuration useStoryReporters(Map<String, StoryReporter> storyReporters) { |
| 295 | 18 | this.storyReporters.putAll(storyReporters); |
| 296 | 18 | return this; |
| 297 | |
} |
| 298 | |
|
| 299 | |
public Configuration useStoryReporterBuilder(StoryReporterBuilder storyReporterBuilder) { |
| 300 | 10 | this.storyReporterBuilder = storyReporterBuilder; |
| 301 | 10 | return this; |
| 302 | |
} |
| 303 | |
|
| 304 | |
public Configuration useStepCollector(StepCollector stepCollector) { |
| 305 | 228 | this.stepCollector = stepCollector; |
| 306 | 228 | return this; |
| 307 | |
} |
| 308 | |
|
| 309 | |
public Configuration useStepFinder(StepFinder stepFinder) { |
| 310 | 216 | this.stepFinder = stepFinder; |
| 311 | 216 | return this; |
| 312 | |
} |
| 313 | |
|
| 314 | |
public Configuration useStepdocReporter(StepdocReporter stepdocReporter) { |
| 315 | 216 | this.stepdocReporter = stepdocReporter; |
| 316 | 216 | return this; |
| 317 | |
} |
| 318 | |
|
| 319 | |
public Configuration useStepPatternParser(StepPatternParser stepPatternParser) { |
| 320 | 212 | this.stepPatternParser = stepPatternParser; |
| 321 | 212 | return this; |
| 322 | |
} |
| 323 | |
|
| 324 | |
public Configuration useStepMonitor(StepMonitor stepMonitor) { |
| 325 | 212 | this.stepMonitor = stepMonitor; |
| 326 | 212 | return this; |
| 327 | |
} |
| 328 | |
|
| 329 | |
public Configuration useParanamer(Paranamer paranamer) { |
| 330 | 212 | this.paranamer = paranamer; |
| 331 | 212 | return this; |
| 332 | |
} |
| 333 | |
|
| 334 | |
public Configuration useParanamer() { |
| 335 | 0 | return useParanamer(new CachingParanamer(new BytecodeReadingParanamer())); |
| 336 | |
} |
| 337 | |
|
| 338 | |
public Configuration useParameterConverters(ParameterConverters parameterConverters) { |
| 339 | 9 | this.parameterConverters = parameterConverters; |
| 340 | 9 | return this; |
| 341 | |
} |
| 342 | |
|
| 343 | |
public Configuration useViewGenerator(ViewGenerator viewGenerator) { |
| 344 | 217 | this.viewGenerator = viewGenerator; |
| 345 | 217 | return this; |
| 346 | |
} |
| 347 | |
|
| 348 | |
} |