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