1 | |
package org.jbehave.core.steps; |
2 | |
|
3 | |
import com.thoughtworks.paranamer.NullParanamer; |
4 | |
import com.thoughtworks.paranamer.Paranamer; |
5 | |
|
6 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
7 | |
import org.apache.commons.lang.builder.ToStringStyle; |
8 | |
import org.jbehave.core.annotations.AfterScenario.Outcome; |
9 | |
import org.jbehave.core.annotations.Named; |
10 | |
import org.jbehave.core.failures.BeforeOrAfterFailed; |
11 | |
import org.jbehave.core.failures.UUIDExceptionWrapper; |
12 | |
import org.jbehave.core.parsers.StepMatcher; |
13 | |
|
14 | |
import java.lang.annotation.Annotation; |
15 | |
import java.lang.reflect.InvocationTargetException; |
16 | |
import java.lang.reflect.Method; |
17 | |
import java.lang.reflect.Type; |
18 | |
import java.util.HashMap; |
19 | |
import java.util.Map; |
20 | |
|
21 | |
import static java.util.Arrays.asList; |
22 | |
import static org.jbehave.core.steps.AbstractStepResult.*; |
23 | |
|
24 | 636 | public class StepCreator { |
25 | |
|
26 | |
public static final String PARAMETER_NAME_START = "<"; |
27 | |
public static final String PARAMETER_NAME_END = ">"; |
28 | |
public static final String PARAMETER_VALUE_START = "\uFF5F"; |
29 | |
public static final String PARAMETER_VALUE_END = "\uFF60"; |
30 | |
public static final String PARAMETER_VALUE_NEWLINE = "\u2424"; |
31 | 1 | public static final UUIDExceptionWrapper NO_FAILURE = new UUIDExceptionWrapper("no failure"); |
32 | |
private final Object stepsInstance; |
33 | |
private final ParameterConverters parameterConverters; |
34 | |
private final StepMatcher stepMatcher; |
35 | |
private final StepRunner beforeOrAfter; |
36 | |
private final StepRunner skip; |
37 | |
private StepMonitor stepMonitor; |
38 | 119 | private Paranamer paranamer = new NullParanamer(); |
39 | 119 | private boolean dryRun = false; |
40 | |
|
41 | |
public StepCreator(Object stepsInstance, StepMonitor stepMonitor) { |
42 | 34 | this(stepsInstance, null, null, stepMonitor); |
43 | 34 | } |
44 | |
|
45 | |
public StepCreator(Object stepsInstance, ParameterConverters parameterConverters, StepMatcher stepMatcher, |
46 | 119 | StepMonitor stepMonitor) { |
47 | 119 | this.stepsInstance = stepsInstance; |
48 | 119 | this.parameterConverters = parameterConverters; |
49 | 119 | this.stepMatcher = stepMatcher; |
50 | 119 | this.stepMonitor = stepMonitor; |
51 | 119 | this.beforeOrAfter = new BeforeOrAfter(); |
52 | 119 | this.skip = new Skip(); |
53 | 119 | } |
54 | |
|
55 | |
public void useStepMonitor(StepMonitor stepMonitor) { |
56 | 56 | this.stepMonitor = stepMonitor; |
57 | 56 | } |
58 | |
|
59 | |
public void useParanamer(Paranamer paranamer) { |
60 | 58 | this.paranamer = paranamer; |
61 | 58 | } |
62 | |
|
63 | |
public void doDryRun(boolean dryRun) { |
64 | 55 | this.dryRun = dryRun; |
65 | 55 | } |
66 | |
|
67 | |
public Step createBeforeOrAfterStep(final Method method) { |
68 | 15 | return new BeforeOrAfterStep(method); |
69 | |
} |
70 | |
|
71 | |
public Step createAfterStepUponOutcome(final Method method, final Outcome outcome, final boolean failureOccured) { |
72 | 11 | switch (outcome) { |
73 | |
case ANY: |
74 | |
default: |
75 | 5 | return new AnyOrDefaultStep(method); |
76 | |
case SUCCESS: |
77 | 3 | return new SuccessStep(failureOccured, method); |
78 | |
case FAILURE: |
79 | 3 | return new FailureStep(failureOccured, method); |
80 | |
} |
81 | |
} |
82 | |
|
83 | |
public Map<String, String> matchedParameters(final Method method, final String stepAsString, |
84 | |
final String stepWithoutStartingWord, final Map<String, String> namedParameters) { |
85 | 1 | stepMatcher.find(stepWithoutStartingWord); |
86 | 1 | String[] annotationNames = annotatedParameterNames(method); |
87 | 1 | String[] parameterNames = paranamer.lookupParameterNames(method, false); |
88 | 1 | Type[] types = method.getGenericParameterTypes(); |
89 | 1 | String[] names = (annotationNames.length > 0 ? annotationNames : parameterNames); |
90 | 1 | String[] parameters = parametersForStep(namedParameters, types, annotationNames, parameterNames); |
91 | 1 | Map<String, String> matchedParameters = new HashMap<String, String>(); |
92 | 3 | for (int i = 0; i < names.length; i++) { |
93 | 2 | matchedParameters.put(names[i], parameters[i]); |
94 | |
} |
95 | 1 | return matchedParameters; |
96 | |
} |
97 | |
|
98 | |
public Step createParametrisedStep(final Method method, final String stepAsString, |
99 | |
final String stepWithoutStartingWord, final Map<String, String> namedParameters) { |
100 | 62 | return new ParameterizedStep(stepAsString, method, stepWithoutStartingWord, namedParameters); |
101 | |
} |
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | |
private String[] annotatedParameterNames(Method method) { |
112 | 62 | Annotation[][] parameterAnnotations = method.getParameterAnnotations(); |
113 | 62 | String[] names = new String[parameterAnnotations.length]; |
114 | 112 | for (int x = 0; x < parameterAnnotations.length; x++) { |
115 | 50 | Annotation[] annotations = parameterAnnotations[x]; |
116 | 72 | for (Annotation annotation : annotations) { |
117 | 22 | names[x] = annotationName(annotation); |
118 | |
} |
119 | |
} |
120 | 62 | return names; |
121 | |
} |
122 | |
|
123 | |
private String annotationName(Annotation annotation) { |
124 | 22 | if (annotation.annotationType().isAssignableFrom(Named.class)) { |
125 | 16 | return ((Named) annotation).value(); |
126 | 6 | } else if ("javax.inject.Named".equals(annotation.annotationType().getName())) { |
127 | 6 | return Jsr330Helper.getNamedValue(annotation); |
128 | |
} else { |
129 | 0 | return null; |
130 | |
} |
131 | |
} |
132 | |
|
133 | |
private String parametrisedStep(String stepAsString, Map<String, String> namedParameters, Type[] types, |
134 | |
String[] annotationNames, String[] parameterNames, String[] parameters) { |
135 | 59 | String parametrisedStep = stepAsString; |
136 | 103 | for (int position = 0; position < types.length; position++) { |
137 | 44 | parametrisedStep = replaceParameterValuesInStep(parametrisedStep, position, annotationNames, |
138 | |
parameterNames, parameters, namedParameters); |
139 | |
} |
140 | 59 | return parametrisedStep; |
141 | |
} |
142 | |
|
143 | |
private String replaceParameterValuesInStep(String stepText, int position, String[] annotationNames, |
144 | |
String[] parameterNames, String[] parameters, Map<String, String> namedParameters) { |
145 | 44 | int annotatedNamePosition = parameterPosition(annotationNames, position); |
146 | 44 | int parameterNamePosition = parameterPosition(parameterNames, position); |
147 | 44 | if (annotatedNamePosition != -1) { |
148 | 16 | stepText = replaceParameterValue(stepText, namedParameters, annotationNames[position]); |
149 | 28 | } else if (parameterNamePosition != -1) { |
150 | 6 | stepText = replaceParameterValue(stepText, namedParameters, parameterNames[position]); |
151 | |
} |
152 | 44 | stepText = replaceParameterValue(stepText, position, parameters); |
153 | 44 | return stepText; |
154 | |
} |
155 | |
|
156 | |
private String replaceParameterValue(String stepText, int position, String[] parameters) { |
157 | 44 | String value = parameters[position]; |
158 | 44 | if (value != null) { |
159 | 44 | stepText = stepText.replace(value, PARAMETER_VALUE_START + value + PARAMETER_VALUE_END); |
160 | 44 | stepText = stepText.replace("\n", PARAMETER_VALUE_NEWLINE); |
161 | |
} |
162 | 44 | return stepText; |
163 | |
} |
164 | |
|
165 | |
private String replaceParameterValue(String stepText, Map<String, String> namedParameters, String name) { |
166 | 22 | String value = tableParameter(namedParameters, name); |
167 | 22 | if (value != null) { |
168 | 10 | stepText = stepText.replace(PARAMETER_NAME_START + name + PARAMETER_NAME_END, PARAMETER_VALUE_START + value |
169 | |
+ PARAMETER_VALUE_END); |
170 | |
} |
171 | 22 | return stepText; |
172 | |
} |
173 | |
|
174 | |
private String[] parametersForStep(Map<String, String> namedParameters, Type[] types, String[] annotationNames, |
175 | |
String[] parameterNames) { |
176 | 62 | final String[] parameters = new String[types.length]; |
177 | 108 | for (int position = 0; position < types.length; position++) { |
178 | 48 | parameters[position] = parameterForPosition(position, annotationNames, parameterNames, namedParameters); |
179 | |
} |
180 | 60 | return parameters; |
181 | |
} |
182 | |
|
183 | |
private Object[] convertParameters(String[] parametersAsString, Type[] types) { |
184 | 59 | final Object[] parameters = new Object[parametersAsString.length]; |
185 | 103 | for (int position = 0; position < parametersAsString.length; position++) { |
186 | 44 | parameters[position] = parameterConverters.convert(parametersAsString[position], types[position]); |
187 | |
} |
188 | 59 | return parameters; |
189 | |
} |
190 | |
|
191 | |
private String parameterForPosition(int position, String[] annotationNames, String[] parameterNames, |
192 | |
Map<String, String> namedParameters) { |
193 | 48 | int annotatedNamePosition = parameterPosition(annotationNames, position); |
194 | 48 | int parameterNamePosition = parameterPosition(parameterNames, position); |
195 | 48 | String parameter = null; |
196 | 48 | if (annotatedNamePosition != -1 && isGroupName(annotationNames[position])) { |
197 | 10 | String name = annotationNames[position]; |
198 | 10 | stepMonitor.usingAnnotatedNameForParameter(name, position); |
199 | 10 | parameter = matchedParameter(name); |
200 | 10 | } else if (parameterNamePosition != -1 && isGroupName(parameterNames[position])) { |
201 | 4 | String name = parameterNames[position]; |
202 | 4 | stepMonitor.usingParameterNameForParameter(name, position); |
203 | 4 | parameter = matchedParameter(name); |
204 | 4 | } else if (annotatedNamePosition != -1 && isTableName(namedParameters, annotationNames[position])) { |
205 | 8 | String name = annotationNames[position]; |
206 | 8 | stepMonitor.usingTableAnnotatedNameForParameter(name, position); |
207 | 8 | parameter = tableParameter(namedParameters, name); |
208 | 8 | } else if (parameterNamePosition != -1 && isTableName(namedParameters, parameterNames[position])) { |
209 | 2 | String name = parameterNames[position]; |
210 | 2 | stepMonitor.usingTableParameterNameForParameter(name, position); |
211 | 2 | parameter = tableParameter(namedParameters, name); |
212 | 2 | } else { |
213 | 24 | stepMonitor.usingNaturalOrderForParameter(position); |
214 | 24 | parameter = matchedParameter(position); |
215 | |
} |
216 | 46 | stepMonitor.foundParameter(parameter, position); |
217 | 46 | return parameter; |
218 | |
} |
219 | |
|
220 | |
String matchedParameter(String name) { |
221 | 15 | String[] parameterNames = stepMatcher.parameterNames(); |
222 | 22 | for (int i = 0; i < parameterNames.length; i++) { |
223 | 21 | String parameterName = parameterNames[i]; |
224 | 21 | if (name.equals(parameterName)) { |
225 | 14 | return matchedParameter(i); |
226 | |
} |
227 | |
} |
228 | 1 | throw new ParameterNotFound(name, parameterNames); |
229 | |
} |
230 | |
|
231 | |
private String matchedParameter(int position) { |
232 | 38 | String[] parameterNames = stepMatcher.parameterNames(); |
233 | 38 | int matchedPosition = position + 1; |
234 | 38 | if (matchedPosition <= parameterNames.length) { |
235 | 36 | return stepMatcher.parameter(matchedPosition); |
236 | |
} |
237 | 2 | throw new ParameterNotFound(position, parameterNames); |
238 | |
} |
239 | |
|
240 | |
private int parameterPosition(String[] names, int position) { |
241 | 184 | if (names.length == 0) { |
242 | 80 | return -1; |
243 | |
} |
244 | 104 | String positionName = names[position]; |
245 | 191 | for (int i = 0; i < names.length; i++) { |
246 | 135 | String name = names[i]; |
247 | 135 | if (name != null && positionName.equals(name)) { |
248 | 48 | return i; |
249 | |
} |
250 | |
} |
251 | 56 | return -1; |
252 | |
} |
253 | |
|
254 | |
private boolean isGroupName(String name) { |
255 | 26 | String[] groupNames = stepMatcher.parameterNames(); |
256 | 33 | for (String groupName : groupNames) { |
257 | 21 | if (name.equals(groupName)) { |
258 | 14 | return true; |
259 | |
} |
260 | |
} |
261 | 12 | return false; |
262 | |
} |
263 | |
|
264 | |
private String tableParameter(Map<String, String> namedParameters, String name) { |
265 | 44 | return namedParameters.get(name); |
266 | |
} |
267 | |
|
268 | |
private boolean isTableName(Map<String, String> namedParameters, String name) { |
269 | 12 | return tableParameter(namedParameters, name) != null; |
270 | |
} |
271 | |
|
272 | |
public interface StepRunner { |
273 | |
|
274 | |
StepResult run(Method method, UUIDExceptionWrapper failureIfItHappened); |
275 | |
|
276 | |
} |
277 | |
|
278 | 238 | private class BeforeOrAfter implements StepRunner { |
279 | |
|
280 | |
public StepResult run(Method method, UUIDExceptionWrapper failureIfItHappened) { |
281 | 19 | if (method == null) { |
282 | 1 | return failed(method, new UUIDExceptionWrapper(new BeforeOrAfterFailed(new NullPointerException( |
283 | |
"method")))); |
284 | |
} |
285 | |
try { |
286 | 18 | if (method.getParameterTypes().length == 0) { |
287 | 18 | method.invoke(stepsInstance); |
288 | |
} else { |
289 | 0 | method.invoke(stepsInstance, failureIfItHappened); |
290 | |
} |
291 | 2 | } catch (InvocationTargetException e) { |
292 | 2 | return failed(method, new UUIDExceptionWrapper(new BeforeOrAfterFailed(method, e.getCause()))); |
293 | 0 | } catch (Throwable t) { |
294 | 0 | return failed(method, new UUIDExceptionWrapper(new BeforeOrAfterFailed(method, t))); |
295 | 16 | } |
296 | 16 | return skipped(); |
297 | |
} |
298 | |
} |
299 | |
|
300 | 238 | private class Skip implements StepRunner { |
301 | |
|
302 | |
public StepResult run(Method method, UUIDExceptionWrapper failureIfItHappened) { |
303 | 3 | return skipped(); |
304 | |
} |
305 | |
} |
306 | |
|
307 | |
public static Step createPendingStep(final String stepAsString, String previousNonAndStep) { |
308 | 12 | return new PendingStep(stepAsString, previousNonAndStep); |
309 | |
} |
310 | |
|
311 | |
public static Step createIgnorableStep(final String stepAsString) { |
312 | 2 | return new IgnorableStep(stepAsString); |
313 | |
} |
314 | |
|
315 | |
|
316 | |
|
317 | |
|
318 | |
|
319 | 6 | public static class Jsr330Helper { |
320 | |
|
321 | |
private static String getNamedValue(Annotation annotation) { |
322 | 6 | return ((javax.inject.Named) annotation).value(); |
323 | |
} |
324 | |
|
325 | |
} |
326 | |
|
327 | |
@SuppressWarnings("serial") |
328 | |
public static class ParameterNotFound extends RuntimeException { |
329 | |
|
330 | |
public ParameterNotFound(String name, String[] parameters) { |
331 | 1 | super("Parameter not found for name '" + name + "' amongst '" + asList(parameters) + "'"); |
332 | 1 | } |
333 | |
|
334 | |
public ParameterNotFound(int position, String[] parameters) { |
335 | 2 | super("Parameter not found for position '" + position + "' amongst '" + asList(parameters) + "'"); |
336 | 2 | } |
337 | |
} |
338 | |
|
339 | 102 | public static abstract class AbstractStep implements Step { |
340 | |
|
341 | |
@Override |
342 | |
public String toString() { |
343 | 0 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE); |
344 | |
} |
345 | |
|
346 | |
} |
347 | |
|
348 | |
public class BeforeOrAfterStep extends AbstractStep { |
349 | |
private final Method method; |
350 | |
|
351 | 15 | public BeforeOrAfterStep(Method method) { |
352 | 15 | this.method = method; |
353 | 15 | } |
354 | |
|
355 | |
public StepResult doNotPerform() { |
356 | 1 | return beforeOrAfter.run(method, NO_FAILURE); |
357 | |
} |
358 | |
|
359 | |
public StepResult perform(UUIDExceptionWrapper storyFailureIfItHappened) { |
360 | 12 | return beforeOrAfter.run(method, NO_FAILURE); |
361 | |
} |
362 | |
|
363 | |
} |
364 | |
|
365 | |
public class AnyOrDefaultStep extends AbstractStep { |
366 | |
|
367 | |
private final Method method; |
368 | |
|
369 | 5 | public AnyOrDefaultStep(Method method) { |
370 | 5 | this.method = method; |
371 | 5 | } |
372 | |
|
373 | |
public StepResult doNotPerform() { |
374 | 1 | return beforeOrAfter.run(method, NO_FAILURE); |
375 | |
} |
376 | |
|
377 | |
public StepResult perform(UUIDExceptionWrapper storyFailureIfItHappened) { |
378 | 2 | return beforeOrAfter.run(method, NO_FAILURE); |
379 | |
} |
380 | |
|
381 | |
} |
382 | |
|
383 | |
public class SuccessStep extends AbstractStep { |
384 | |
|
385 | |
private final boolean failureOccured; |
386 | |
private final Method method; |
387 | |
|
388 | 3 | public SuccessStep(boolean failureOccured, Method method) { |
389 | 3 | this.failureOccured = failureOccured; |
390 | 3 | this.method = method; |
391 | 3 | } |
392 | |
|
393 | |
public StepResult doNotPerform() { |
394 | 1 | return (failureOccured ? skip.run(method, NO_FAILURE) : beforeOrAfter.run(method, NO_FAILURE)); |
395 | |
} |
396 | |
|
397 | |
public StepResult perform(UUIDExceptionWrapper storyFailureIfItHappened) { |
398 | 2 | return (failureOccured ? skip.run(method, NO_FAILURE) : beforeOrAfter.run(method, NO_FAILURE)); |
399 | |
} |
400 | |
|
401 | |
} |
402 | |
|
403 | |
public class FailureStep extends AbstractStep { |
404 | |
|
405 | |
private final boolean failureOccured; |
406 | |
private final Method method; |
407 | |
|
408 | 3 | public FailureStep(boolean failureOccured, Method method) { |
409 | 3 | this.failureOccured = failureOccured; |
410 | 3 | this.method = method; |
411 | 3 | } |
412 | |
|
413 | |
public StepResult doNotPerform() { |
414 | 1 | return (failureOccured ? beforeOrAfter.run(method, NO_FAILURE) : skip.run(method, NO_FAILURE)); |
415 | |
} |
416 | |
|
417 | |
public StepResult perform(UUIDExceptionWrapper storyFailureIfItHappened) { |
418 | 2 | return (failureOccured ? beforeOrAfter.run(method, storyFailureIfItHappened) : skip.run(method, NO_FAILURE)); |
419 | |
} |
420 | |
|
421 | |
} |
422 | |
|
423 | |
public class ParameterizedStep extends AbstractStep { |
424 | |
private Object[] convertedParameters; |
425 | |
private String parametrisedStep; |
426 | |
private final String stepAsString; |
427 | |
private final Method method; |
428 | |
private final String stepWithoutStartingWord; |
429 | |
private final Map<String, String> namedParameters; |
430 | |
|
431 | |
public ParameterizedStep(String stepAsString, Method method, String stepWithoutStartingWord, |
432 | 62 | Map<String, String> namedParameters) { |
433 | 62 | this.stepAsString = stepAsString; |
434 | 62 | this.method = method; |
435 | 62 | this.stepWithoutStartingWord = stepWithoutStartingWord; |
436 | 62 | this.namedParameters = namedParameters; |
437 | 62 | } |
438 | |
|
439 | |
public StepResult perform(UUIDExceptionWrapper storyFailureIfItHappened) { |
440 | |
try { |
441 | 62 | parametriseStep(); |
442 | 59 | stepMonitor.performing(stepAsString, dryRun); |
443 | 59 | if (!dryRun) { |
444 | 55 | method.invoke(stepsInstance, convertedParameters); |
445 | |
} |
446 | 58 | return successful(stepAsString).withParameterValues(parametrisedStep); |
447 | 1 | } catch (ParameterNotFound e) { |
448 | |
|
449 | 1 | return pending(stepAsString).withParameterValues(parametrisedStep); |
450 | 1 | } catch (InvocationTargetException e) { |
451 | 1 | if (e.getCause() instanceof UUIDExceptionWrapper) { |
452 | 1 | return failed(stepAsString, ((UUIDExceptionWrapper) e.getCause())).withParameterValues( |
453 | |
parametrisedStep); |
454 | |
} |
455 | 0 | return failed(stepAsString, new UUIDExceptionWrapper(e.getCause())).withParameterValues( |
456 | |
parametrisedStep); |
457 | 2 | } catch (Throwable t) { |
458 | 2 | return failed(stepAsString, new UUIDExceptionWrapper(t)).withParameterValues(parametrisedStep); |
459 | |
} |
460 | |
} |
461 | |
|
462 | |
public StepResult doNotPerform() { |
463 | |
try { |
464 | 1 | parametriseStep(); |
465 | |
|
466 | 1 | } catch (Throwable t) { |
467 | |
|
468 | |
|
469 | 0 | } |
470 | 1 | return notPerformed(stepAsString).withParameterValues(parametrisedStep); |
471 | |
} |
472 | |
|
473 | |
private void parametriseStep() { |
474 | 63 | stepMatcher.find(stepWithoutStartingWord); |
475 | 61 | String[] annotationNames = annotatedParameterNames(method); |
476 | 61 | String[] parameterNames = paranamer.lookupParameterNames(method, false); |
477 | 61 | Type[] types = method.getGenericParameterTypes(); |
478 | 61 | String[] parameters = parametersForStep(namedParameters, types, annotationNames, parameterNames); |
479 | 59 | convertedParameters = convertParameters(parameters, types); |
480 | 59 | parametrisedStep = parametrisedStep(stepAsString, namedParameters, types, annotationNames, parameterNames, |
481 | |
parameters); |
482 | 59 | } |
483 | |
|
484 | |
} |
485 | |
|
486 | |
public static class PendingStep extends AbstractStep { |
487 | |
private final String stepAsString; |
488 | |
private final String previousNonAndStep; |
489 | |
private Method method; |
490 | |
|
491 | 12 | public PendingStep(String stepAsString, String previousNonAndStep) { |
492 | 12 | this.stepAsString = stepAsString; |
493 | 12 | this.previousNonAndStep = previousNonAndStep; |
494 | 12 | } |
495 | |
|
496 | |
public StepResult perform(UUIDExceptionWrapper storyFailureIfItHappened) { |
497 | 2 | return pending(stepAsString); |
498 | |
} |
499 | |
|
500 | |
public StepResult doNotPerform() { |
501 | 1 | return pending(stepAsString); |
502 | |
} |
503 | |
|
504 | |
public String stepAsString() { |
505 | 3 | return stepAsString; |
506 | |
} |
507 | |
|
508 | |
public String previousNonAndStepAsString() { |
509 | 3 | return previousNonAndStep; |
510 | |
} |
511 | |
|
512 | |
public void annotatedOn(Method method) { |
513 | 0 | this.method = method; |
514 | 0 | } |
515 | |
|
516 | |
public boolean annotated() { |
517 | 0 | return method != null; |
518 | |
} |
519 | |
|
520 | |
} |
521 | |
|
522 | |
public static class IgnorableStep extends AbstractStep { |
523 | |
private final String stepAsString; |
524 | |
|
525 | 2 | public IgnorableStep(String stepAsString) { |
526 | 2 | this.stepAsString = stepAsString; |
527 | 2 | } |
528 | |
|
529 | |
public StepResult perform(UUIDExceptionWrapper storyFailureIfItHappened) { |
530 | 2 | return ignorable(stepAsString); |
531 | |
} |
532 | |
|
533 | |
public StepResult doNotPerform() { |
534 | 1 | return ignorable(stepAsString); |
535 | |
} |
536 | |
} |
537 | |
|
538 | |
} |