Title: [1364] trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps: JBEHAVE-196: Ensured check on duplicate steps takes the step type into account.
Revision
1364
Author
mauro
Date
2009-10-26 15:59:58 -0500 (Mon, 26 Oct 2009)

Log Message

JBEHAVE-196:  Ensured check on duplicate steps takes the step type into account.

Modified Paths

Diff

Modified: trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/TraderSteps.java (1363 => 1364)

--- trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/TraderSteps.java	2009-10-26 20:38:12 UTC (rev 1363)
+++ trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/TraderSteps.java	2009-10-26 20:59:58 UTC (rev 1364)
@@ -7,6 +7,7 @@
 import org.jbehave.examples.trader.converters.TraderConverter;
 import org.jbehave.examples.trader.model.Stock;
 import org.jbehave.examples.trader.model.Trader;
+import org.jbehave.examples.trader.model.Stock.AlertStatus;
 import org.jbehave.examples.trader.persistence.TraderPersister;
 import org.jbehave.scenario.annotations.Alias;
 import org.jbehave.scenario.annotations.Aliases;
@@ -71,9 +72,11 @@
         ensureThat(stock.getStatus().name(), equalTo(status));
     }
 
-    @Given("the alert status is OFF") // shows that matching pattern need only be unique for step type
-    public void theAlertStatusIsReset() {
-    	stock.resetAlert();
+    @Given("the alert status is %status") // shows that matching pattern need only be unique for step type
+    public void theAlertStatusIsReset(@Named("status") String status) {
+    	if ( AlertStatus.OFF.name().startsWith(status) ){
+        	stock.resetAlert();    		
+    	}
     }
 
     @Then("the alert status is %status")

Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/CandidateStep.java (1363 => 1364)

--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/CandidateStep.java	2009-10-26 20:38:12 UTC (rev 1363)
+++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/CandidateStep.java	2009-10-26 20:59:58 UTC (rev 1364)
@@ -244,6 +244,10 @@
 		};
 	}
 
+	public StepType getStepType() {
+		return stepType;
+	}
+
 	public String getStepAsString() {
 		return stepAsString;
 	}

Modified: trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/Steps.java (1363 => 1364)

--- trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/Steps.java	2009-10-26 20:38:12 UTC (rev 1363)
+++ trunk/core/jbehave-core/src/java/org/jbehave/scenario/steps/Steps.java	2009-10-26 20:59:58 UTC (rev 1364)
@@ -156,7 +156,7 @@
 
 	private void createCandidateStep(List<CandidateStep> steps, Method method,
 			StepType stepType, String stepAsString) {
-		checkForDuplicateCandidateSteps(steps, stepAsString);
+		checkForDuplicateCandidateSteps(steps, stepType, stepAsString);
 		CandidateStep step = new CandidateStep(stepAsString, stepType, method,
 				this, configuration.getPatternBuilder(), configuration
 						.getParameterConverters(), configuration
@@ -167,10 +167,10 @@
 	}
 
 	private void checkForDuplicateCandidateSteps(List<CandidateStep> steps,
-			String stepAsString) {
+			StepType stepType, String stepAsString) {
 		for (CandidateStep step : steps) {
-			if (step.getStepAsString().equals(stepAsString)) {
-				throw new DuplicateCandidateStepFoundException(stepAsString);
+			if (step.getStepType() == stepType && step.getStepAsString().equals(stepAsString)) {
+				throw new DuplicateCandidateStepFoundException(stepType, stepAsString);
 			}
 		}
 	}
@@ -296,8 +296,8 @@
 	public static class DuplicateCandidateStepFoundException extends
 			RuntimeException {
 
-		public DuplicateCandidateStepFoundException(String message) {
-			super(message);
+		public DuplicateCandidateStepFoundException(StepType stepType, String stepAsString) {
+			super(stepType+" "+stepAsString);
 		}
 
 	}


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to