Title: [1646] trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps: JBEHAVE-291: Added method and steps instance information to match events in StepMonitor.
Revision
1646
Author
mauro
Date
2010-05-20 06:16:51 -0500 (Thu, 20 May 2010)

Log Message

JBEHAVE-291:  Added method and steps instance information to match events in StepMonitor.

Modified Paths

Diff

Modified: trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/CandidateStep.java (1645 => 1646)

--- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/CandidateStep.java	2010-05-15 12:53:06 UTC (rev 1645)
+++ trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/CandidateStep.java	2010-05-20 11:16:51 UTC (rev 1646)
@@ -35,7 +35,7 @@
     private final Integer priority;
     private final StepType stepType;
     private final Method method;
-    private final Object steps;
+    private final Object stepsInstance;
     private final ParameterConverters parameterConverters;
     private final Map<StepType, String> startingWordsByType;
     private final Pattern pattern;
@@ -58,7 +58,7 @@
         this.priority = priority;
         this.stepType = stepType;
         this.method = method;
-        this.steps = stepsInstance;
+        this.stepsInstance = stepsInstance;
         this.parameterConverters = parameterConverters;
         this.startingWordsByType = startingWords;
         this.pattern = patternBuilder.buildPattern(patternAsString);
@@ -113,9 +113,9 @@
         			matchesType = startingWordFor(stepType).equals(findStartingWord(previousNonAndStep));
         		}
         	}
-            stepMonitor.stepMatchesType(step, previousNonAndStep, matchesType, stepType);
+            stepMonitor.stepMatchesType(step, previousNonAndStep, matchesType, stepType, method, stepsInstance);
             boolean matchesPattern = matcherForStep(step).matches();
-            stepMonitor.stepMatchesPattern(step, matchesPattern, pattern.pattern());
+            stepMonitor.stepMatchesPattern(step, matchesPattern, pattern.pattern(), method, stepsInstance);
             // must match both type and pattern
             return matchesType && matchesPattern;
         } catch (StartingWordNotFound e) {
@@ -317,7 +317,7 @@
                 try {
                     stepMonitor.performing(stepAsString, dryRun);
                     if ( !dryRun ){
-                        method.invoke(steps, args);                    	
+                        method.invoke(stepsInstance, args);                    	
                     }
                     return StepResult.success(stepAsString).withTranslatedText(translatedStep);
                 } catch (Throwable t) {

Modified: trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/PrintStreamStepMonitor.java (1645 => 1646)

--- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/PrintStreamStepMonitor.java	2010-05-15 12:53:06 UTC (rev 1645)
+++ trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/PrintStreamStepMonitor.java	2010-05-20 11:16:51 UTC (rev 1646)
@@ -1,8 +1,10 @@
 package org.jbehave.scenario.steps;
 
 import static java.text.MessageFormat.format;
+import static java.util.Arrays.asList;
 
 import java.io.PrintStream;
+import java.lang.reflect.Method;
 import java.lang.reflect.Type;
 
 /**
@@ -12,8 +14,8 @@
 public class PrintStreamStepMonitor implements StepMonitor {
 
 	private static final String CONVERTED_VALUE_OF_TYPE = "Converted value ''{0}'' of type ''{1}'' to ''{2}'' with converter ''{3}''";
-	private static final String STEP_MATCHES_TYPE = "Step ''{0}'' (with previous step ''{1}'') ''{2}'' type ''{3}''";
-	private static final String STEP_MATCHES_PATTERN = "Step ''{0}'' {1} pattern ''{2}''";
+	private static final String STEP_MATCHES_TYPE = "Step ''{0}'' (with previous step ''{1}'') ''{2}'' type ''{3}'' for method ''{4}'' with annotations ''{5}'' in Steps ''{6}''";
+	private static final String STEP_MATCHES_PATTERN = "Step ''{0}'' {1} pattern ''{2}'' for method ''{3}'' with annotations ''{4}'' in Steps ''{5}''";
 	private static final String PERFORMING = "Performing step ''{0}'' {1}";
 	private static final String DRY_RUN = "(DRY RUN)";
 	private static final String MATCHES = "matches";
@@ -37,15 +39,15 @@
 	}
 
 	public void stepMatchesType(String step, String previous, boolean matches,
-			StepType stepType) {
+			StepType stepType, Method method, Object stepsInstance) {
 		String message = format(STEP_MATCHES_TYPE, step, previous,
-				(matches ? MATCHES : DOES_NOT_MATCH), stepType);
+				(matches ? MATCHES : DOES_NOT_MATCH), stepType, method, asList(method.getAnnotations()), stepsInstance);
 		print(output, message);
 	}
 
-	public void stepMatchesPattern(String step, boolean matches, String pattern) {
+	public void stepMatchesPattern(String step, boolean matches, String pattern, Method method, Object stepsInstance) {
 		String message = format(STEP_MATCHES_PATTERN, step, (matches ? MATCHES
-				: DOES_NOT_MATCH), pattern);
+				: DOES_NOT_MATCH), pattern, method, asList(method.getAnnotations()), stepsInstance);
 		print(output, message);
 	}
 

Modified: trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/StepMonitor.java (1645 => 1646)

--- trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/StepMonitor.java	2010-05-15 12:53:06 UTC (rev 1645)
+++ trunk/core/jbehave-core/src/main/java/org/jbehave/scenario/steps/StepMonitor.java	2010-05-20 11:16:51 UTC (rev 1646)
@@ -1,5 +1,6 @@
 package org.jbehave.scenario.steps;
 
+import java.lang.reflect.Method;
 import java.lang.reflect.Type;
 
 /**
@@ -10,9 +11,9 @@
 public interface StepMonitor {
 
 	void stepMatchesType(String stepAsString, String previousAsString,
-			boolean matchesType, StepType stepType);
+			boolean matchesType, StepType stepType, Method method, Object stepsInstance);
 
-	void stepMatchesPattern(String step, boolean matches, String pattern);
+	void stepMatchesPattern(String step, boolean matches, String pattern, Method method, Object stepsInstance);
 
     void convertedValueOfType(String value, Type type, Object converted, Class<?> converterClass);
 


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to