@Given("with living cells at following positions : $table")
 public void givenInitialPositionTable(ExamplesTable table) {
   List<Map<String, String>> rows = table.getRows();
   for (Map<String, String> row : rows) {
     int x = Integer.valueOf(row.get("x"));
     int y = Integer.valueOf(row.get("y"));
     initialStates.add(new Coordinate(x, y));
   }
 }
  @Given("the following trades: $tradesTable")
  public void theTrades(ExamplesTable tradesTable) {

    for (Map<String, String> row : tradesTable.getRows()) {
      String symbol = row.get("symbol");
      String minsAgo = row.get("mins-ago");
      String tradedPrice = row.get("traded-price");
      String quantity = row.get("quantity");

      Stock stock = new Stock.Builder().symbol(symbol).type(TYPE.COMMON).build();

      StockTrade trade =
          new StockTrade.Builder()
              .stock(stock)
              .timestamp(
                  new Date(System.currentTimeMillis() - Integer.valueOf(minsAgo) * 60 * 1000))
              .quantity(Integer.valueOf(quantity))
              .tradedPrice(Double.valueOf(tradedPrice))
              .build();

      tradeRepository.captureTrade(trade);
    }
  }
Ejemplo n.º 3
0
 private void runScenariosParametrisedByExamples(
     RunContext context, Scenario scenario, Lifecycle lifecycle, Meta storyAndScenarioMeta)
     throws Throwable {
   ExamplesTable table = scenario.getExamplesTable();
   reporter.get().beforeExamples(scenario.getSteps(), table);
   Keywords keywords = context.configuration().keywords();
   for (Map<String, String> scenarioParameters : table.getRows()) {
     Meta parameterMeta = parameterMeta(keywords, scenarioParameters);
     if (!parameterMeta.isEmpty() && !context.filter.allow(parameterMeta)) {
       continue;
     }
     reporter.get().example(scenarioParameters);
     if (context.configuration().storyControls().resetStateBeforeScenario()) {
       context.resetState();
     }
     runBeforeOrAfterScenarioSteps(
         context, scenario, storyAndScenarioMeta, Stage.BEFORE, ScenarioType.EXAMPLE);
     runStepWithLifecycle(context, lifecycle, scenarioParameters, scenario, storyAndScenarioMeta);
     runBeforeOrAfterScenarioSteps(
         context, scenario, storyAndScenarioMeta, Stage.AFTER, ScenarioType.EXAMPLE);
   }
   reporter.get().afterExamples();
 }