[ 
http://jira.codehaus.org/browse/JBEHAVE-263?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mauro Talevi updated JBEHAVE-263:
---------------------------------

      Component/s: Core
      Description: 
Right now the converters are called before running the scenario, which prevents 
using stateful converters.

Here is an easy fix : change StepCreator#createParametrisedStep to the following

{code}
protected Step createParametrisedStep(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}

  was:
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}

    Fix Version/s: 3.0
          Summary: Allow lazy parameter convertion  (was: Allow lazy parameter 
convertion : fix CandidateStep)

> Allow lazy parameter convertion
> -------------------------------
>
>                 Key: JBEHAVE-263
>                 URL: http://jira.codehaus.org/browse/JBEHAVE-263
>             Project: JBehave
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 2.5
>            Reporter: Bruno Bieth
>             Fix For: 3.0
>
>
> Right now the converters are called before running the scenario, which 
> prevents using stateful converters.
> Here is an easy fix : change StepCreator#createParametrisedStep to the 
> following
> {code}
> protected Step createParametrisedStep(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


Reply via email to