Allow lazy parameter convertion : fix CandidateStep
---------------------------------------------------
Key: JBEHAVE-263
URL: http://jira.codehaus.org/browse/JBEHAVE-263
Project: JBehave
Issue Type: Improvement
Affects Versions: 2.5
Reporter: Bruno Bieth
Right now the converters are called before running the scenario, which prevents
using stateful converters.
Here is an easy fix : change CandidateStep#createStep to the following
{code}
protected Step createStep(final String stepAsString, final Map<String, String>
tableRow, final Matcher matcher,
final Method method, final StepMonitor
stepMonitor, String[] groupNames) {
final Type[] types = method.getGenericParameterTypes();
final String[] annotationNames = annotatedParameterNames();
final String[] parameterNames = paranamer.lookupParameterNames(method,
false);
final String translatedStep = translatedStep(stepAsString, tableRow,
types, annotationNames, parameterNames);
return new Step() {
public StepResult perform() {
try {
stepMonitor.performing(stepAsString);
method.invoke(steps, argsForStep(tableRow, matcher, types,
annotationNames, parameterNames));
return
StepResult.success(stepAsString).withTranslatedText(translatedStep);
} catch (Throwable t) {
return failureWithOriginalException(stepAsString, t);
}
}
private StepResult failureWithOriginalException(final String
stepAsString, Throwable t) {
if (t instanceof InvocationTargetException && t.getCause() !=
null) {
if (t.getCause() instanceof PendingError) {
return StepResult.pending(stepAsString, (PendingError)
t.getCause());
} else {
return StepResult.failure(stepAsString, t.getCause());
}
}
return StepResult.failure(stepAsString, t);
}
public StepResult doNotPerform() {
return StepResult.notPerformed(stepAsString);
}
};
}
{code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email