Title: [1229] trunk/core/.settings: Reworked trader example model

Diff

Modified: trunk/core/.settings/org.eclipse.jdt.core.prefs (1228 => 1229)

--- trunk/core/.settings/org.eclipse.jdt.core.prefs	2009-09-06 23:41:29 UTC (rev 1228)
+++ trunk/core/.settings/org.eclipse.jdt.core.prefs	2009-09-07 20:52:35 UTC (rev 1229)
@@ -1,6 +1,6 @@
-#Sat Aug 23 15:39:19 BST 2008
+#Mon Sep 07 21:49:56 BST 2009
 eclipse.preferences.version=1
-org.eclipse.jdt.core.builder.cleanOutputFolder=ignore
 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
 org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
 org.eclipse.jdt.core.compiler.source=1.5

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

--- trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/TraderSteps.java	2009-09-06 23:41:29 UTC (rev 1228)
+++ trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/TraderSteps.java	2009-09-07 20:52:35 UTC (rev 1229)
@@ -4,8 +4,6 @@
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.jbehave.Ensure.ensureThat;
 
-import java.util.List;
-
 import org.jbehave.examples.trader.converters.TraderConverter;
 import org.jbehave.examples.trader.model.Stock;
 import org.jbehave.examples.trader.model.Trader;
@@ -39,7 +37,7 @@
     }
 
     private TraderPersister mockTradePersister() {
-        return new TraderPersister(new Trader("Mauro", asList(new Stock(asList(1.0d), 10.d))));
+        return new TraderPersister(new Trader("Mauro", asList(new Stock("STK1", 10.d))));
     }
 
     @Given("a trader of name %trader")
@@ -47,12 +45,12 @@
         this.trader = trader;
     }
 
-    @Given("some stocks of <prices> and a <threshold>")
-    public void pricesWithThreshold(@Named("prices") List<Double> prices, @Named("threshold") double threshold) {
-        stock = new Stock(prices, threshold);
+    @Given("a stock of <symbol> and a <threshold>")
+    public void aStock(@Named("symbol") String symbol, @Named("threshold") double threshold) {
+        stock = new Stock(symbol, threshold);
     }
 
-    @When("one of these stocks is traded at <price>")
+    @When("the stock is traded with <price>")
     public void theStockIsBoughtAt(@Named("price") double price) {
         stock.tradeAt(price);
     }
@@ -62,13 +60,13 @@
         ensureThat(stock.getStatus().name(), equalTo(status));
     }
 
-    @Given("a stock of prices %prices and a threshold of %threshold")
-    public void aStockOfPrice(@Named("prices") List<Double> prices, @Named("threshold") double threshold) {
-        stock = new Stock(prices, threshold);
+    @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")
-    @Aliases(values={"the stock is sold at %price"})
+    @When("the stock is traded at price %price")
+    @Aliases(values={"the stock is sold at price %price"})
     public void theStockIsTradedAt(@Named("price") double price) {
         stock.tradeAt(price);
     }
@@ -79,9 +77,13 @@
         ensureThat(stock.getStatus().name(), equalTo(status));
     }
 
-    @Then("the trader sells all stocks")
+    @When("the trader sells all stocks")
     public void theTraderSellsAllStocks() {
         trader.sellAllStocks();
+    }
+
+    @Then ("the trader is left with no stocks")
+    public void theTraderIsLeftWithNoStocks() {
         ensureThat(trader.getStocks().size(), equalTo(0));
     }
 

Modified: trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/model/Stock.java (1228 => 1229)

--- trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/model/Stock.java	2009-09-06 23:41:29 UTC (rev 1228)
+++ trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/model/Stock.java	2009-09-07 20:52:35 UTC (rev 1229)
@@ -3,6 +3,7 @@
 import static org.jbehave.examples.trader.model.Stock.AlertStatus.OFF;
 import static org.jbehave.examples.trader.model.Stock.AlertStatus.ON;
 
+import java.util.ArrayList;
 import java.util.List;
 
 public class Stock {
@@ -11,19 +12,20 @@
         ON, OFF
     };
 
-    private List<Double> prices;
+	private String symbol;
     private double alertPrice;
     private AlertStatus status = OFF;
+    private List<Double> prices = new ArrayList<Double>();
 
-    public Stock(List<Double> prices, double alertPrice) {
-        this.prices = prices;
+    public Stock(String symbol, double alertPrice) {
+        this.symbol = symbol;
         this.alertPrice = alertPrice;
     }
 
-    public List<Double> getPrices() {
-        return prices;
+    public String getSymbol(){
+    	return symbol;
     }
-
+    
     public void tradeAt(double price) {
         this.prices.add(price);
         if (price > alertPrice) {
@@ -31,6 +33,10 @@
         }
     }
 
+    public List<Double> getPrices() {
+        return prices;
+    }
+
     public void resetAlert() {
         status = OFF;
     }

Modified: trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/report_can_be_written_to_file.scenario (1228 => 1229)

--- trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/report_can_be_written_to_file.scenario	2009-09-06 23:41:29 UTC (rev 1228)
+++ trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/report_can_be_written_to_file.scenario	2009-09-07 20:52:35 UTC (rev 1229)
@@ -1,7 +1,7 @@
 Scenario: Status alert can be activated
 
-Given a stock of prices 0.5,1.0 and a threshold of 10.0
-When the stock is traded at 5.0
+Given a stock of symbol STK1 and a threshold of 10.0
+When the stock is traded at price 5.0
 Then the alert status should be OFF
 When the stock is sold at 11.0
 Then the alert status should be ON
@@ -9,7 +9,7 @@
 Scenario: Trader sells alls stocks
 
 Given a trader of name Mauro
-Given a stock of prices 0.5,1.0 and a threshold of 1.5
-When the stock is traded at 2.0
+Given a stock of symbol STK1 and a threshold of 1.5
+When the stock is traded at price 2.0
 Then the trader sells all stocks
 

Modified: trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/trader_is_alerted_of_status.scenario (1228 => 1229)

--- trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/trader_is_alerted_of_status.scenario	2009-09-06 23:41:29 UTC (rev 1228)
+++ trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/trader_is_alerted_of_status.scenario	2009-09-07 20:52:35 UTC (rev 1229)
@@ -3,12 +3,12 @@
 As a trader 
 I want to monitor stock prices 
 
-Given a stock of prices 0.5,1.0 and a threshold of 15.0
-When the stock is traded at 5.0
+Given a stock of symbol STK1 and a threshold of 15.0
+When the stock is traded at price 5.0
 Then the alert status should be OFF
-When the stock is sold at 11.0
+When the stock is sold at price 11.0
 Then the alert status is OFF
-When the stock is sold at 16.0
+When the stock is sold at price 16.0
 Then the alert status is ON
 
 Scenario:
@@ -16,12 +16,12 @@
 As a trader 
 I want to monitor stock prices 
 
-Given some stocks of <prices> and a <threshold>
-When one of these stocks is traded at <price>
+Given a stock of <symbol> and a <threshold>
+When the stock is traded with <price>
 Then the trader is alerted with <status>
 
 Examples:
-|prices|threshold|price|status|
-|0.5,1.0|15.0|5.0|OFF|
-|0.5,1.0|15.0|11.0|OFF|
-|0.5,1.0|15.0|16.0|ON|
\ No newline at end of file
+|symbol|threshold|price|status|
+|STK1|15.0|5.0|OFF|
+|STK1|15.0|11.0|OFF|
+|STK1|15.0|16.0|ON|
\ No newline at end of file

Modified: trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/trader_sells_all_stocks.scenario (1228 => 1229)

--- trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/trader_sells_all_stocks.scenario	2009-09-06 23:41:29 UTC (rev 1228)
+++ trunk/core/examples/trader/src/main/java/org/jbehave/examples/trader/scenarios/trader_sells_all_stocks.scenario	2009-09-07 20:52:35 UTC (rev 1229)
@@ -3,6 +3,8 @@
 GivenScenarios: org/jbehave/examples/trader/scenarios/trader_is_alerted_of_status.scenario
 
 Given a trader of name Mauro
-Given a stock of prices 0.5,1.0 and a threshold of 1.5
-When the stock is traded at 2.0
-Then the trader sells all stocks
+Given a stock of symbol STK1 and a threshold of 1.5
+When the stock is traded at price 2.0
+Then the alert status is ON
+When the trader sells all stocks
+Then the trader is left with no stocks


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to