Title: [1230] trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/TraderSteps.java: Better steps method names
Revision
1230
Author
mauro
Date
2009-09-07 16:07:27 -0500 (Mon, 07 Sep 2009)

Log Message

Better steps method names

Modified Paths


Diff

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

--- trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/TraderSteps.java	2009-09-07 20:52:35 UTC (rev 1229)
+++ trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/TraderSteps.java	2009-09-07 21:07:27 UTC (rev 1230)
@@ -31,8 +31,8 @@
         super(configuration);
         StepMonitor monitor = new SilentStepMonitor();
 		configuration.useParameterConverters(new ParameterConverters(
-        		monitor, new TraderConverter(mockTradePersister())));
-        configuration.usePatternBuilder(new PrefixCapturingPatternBuilder("%"));
+        		monitor, new TraderConverter(mockTradePersister())));  // define converter for custom type Trader
+        configuration.usePatternBuilder(new PrefixCapturingPatternBuilder("%")); // use '%' instead of '$' to identify parameters
         configuration.useMonitor(monitor);
     }
 
@@ -46,37 +46,37 @@
     }
 
     @Given("a stock of <symbol> and a <threshold>")
-    public void aStock(@Named("symbol") String symbol, @Named("threshold") double threshold) {
+    public void aStockWithTableParams(@Named("symbol") String symbol, @Named("threshold") double threshold) {
         stock = new Stock(symbol, threshold);
     }
 
+    @Given("a stock of symbol %symbol and a threshold of %threshold")
+    public void aStockWithNamedParams(@Named("symbol") String symbol, @Named("threshold") double threshold) {
+        stock = new Stock(symbol, threshold);
+    }
+
     @When("the stock is traded with <price>")
-    public void theStockIsBoughtAt(@Named("price") double price) {
+    public void theStockIsTradedAtWithTableParam(@Named("price") double price) {
         stock.tradeAt(price);
     }
 
-    @Then("the trader is alerted with <status>")
-    public void theAlertIs(@Named("status") String status) {
-        ensureThat(stock.getStatus().name(), equalTo(status));
-    }
-
-    @Given("a stock of symbol %symbol and a threshold of %threshold")
-    public void aStockWithNamedParameters(@Named("symbol") String symbol, @Named("threshold") double threshold) {
-        stock = new Stock(symbol, threshold);
-    }
-
     @When("the stock is traded at price %price")
-    @Aliases(values={"the stock is sold at price %price"})
-    public void theStockIsTradedAt(@Named("price") double price) {
+    @Aliases(values={"the stock is sold at price %price", "the stock is exchanged at price %price"}) // multiple aliases
+    public void theStockIsTradedAtWithNamedParam(@Named("price") double price) {
         stock.tradeAt(price);
     }
 
-    @Then("the alert status should be %status")
-    @Alias("the alert status is %status")
-    public void theAlertStatusShouldBe(@Named("status") String status) {
+    @Then("the trader is alerted with <status>")
+    public void theAlertStatusIsWithTableParam(@Named("status") String status) {
         ensureThat(stock.getStatus().name(), equalTo(status));
     }
 
+    @Then("the alert status is %status")
+    @Alias("the alert status will be %status") // single alias
+    public void theAlertStatusIsWithNamedParam(@Named("status") String status) {
+        ensureThat(stock.getStatus().name(), equalTo(status));
+    }
+
     @When("the trader sells all stocks")
     public void theTraderSellsAllStocks() {
         trader.sellAllStocks();


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to