Package org.jbehave.core.steps

Examples of org.jbehave.core.steps.Parameters


  }

  @Then("the current trader activity is: %activityTable")
  public void theTradersActivityIs(ExamplesTable activityTable) {
    for (int i = 0; i < activityTable.getRowCount(); i++) {
      Parameters row = activityTable.withDefaults(this.ranksTable.getRowAsParameters(i)).getRowAsParameters(i);
      System.out.println(row.valueAs("name", Trader.class).getName() + " ("
          + row.valueAs("rank", String.class, "N/A") + ") has done " + row.valueAs("trades", Integer.class)
          + " trades");
    }
  }
View Full Code Here


    @Then("les valeurs multipliées par $multiplier sont: $table")
    public void theResultsMultipliedByAre(int multiplier, ExamplesTable results){
        OutcomesTable outcomes = new OutcomesTable(new LocalizedKeywords(new Locale("fr")));
        for (int row = 0; row < results.getRowCount(); row++) {
            Parameters expected = results.getRowAsParameters(row);
            Parameters original = table.getRowAsParameters(row);
            int one = original.valueAs("un", Integer.class);
            int two = original.valueAs("deux", Integer.class);
            outcomes.addOutcome("un", one*multiplier, Matchers.equalTo(expected.valueAs("un", Integer.class)));
            outcomes.addOutcome("deux", two*multiplier, Matchers.equalTo(expected.valueAs("deux", Integer.class)));
        }
        outcomes.verify();
    }
View Full Code Here

        // When
        String tableAsString = "|one|two|\n|11|22|\n|1/1/2010|2/2/2010|";
        ExamplesTable examplesTable = factory.createExamplesTable(tableAsString);

        // Then
        Parameters integers = examplesTable.getRowAsParameters(0);
        assertThat(integers.valueAs("one", Integer.class), equalTo(11));
        assertThat(integers.valueAs("two", Integer.class), equalTo(22));
        Parameters dates = examplesTable.getRowAsParameters(1);
        assertThat(dates.valueAs("one", Date.class), equalTo(convertDate("1/1/2010")));
        assertThat(dates.valueAs("two", Date.class), equalTo(convertDate("2/2/2010")));
    }
View Full Code Here

        // When
        String tableDefaultsAsString = "|three|\n|99|";
        ExamplesTable defaultsTable = factory.createExamplesTable(tableDefaultsAsString);

        Parameters defaults = defaultsTable.getRowAsParameters(0);
        String tableAsString = "|one|\n|11|\n|22|";
        ExamplesTable examplesTable = factory.createExamplesTable(tableAsString).withDefaults(defaults);

        // Then
        Parameters firstRow = examplesTable.getRowAsParameters(0);
        Map<String, String> firstRowValues = firstRow.values();
        assertThat(firstRowValues.containsKey("one"), is(true));
        assertThat(firstRow.valueAs("one", String.class), is("11"));
        assertThat(firstRow.valueAs("one", Integer.class), is(11));
        assertThat(firstRowValues.containsKey("three"), is(true));
        assertThat(firstRow.valueAs("three", String.class), is("99"));
        assertThat(firstRow.valueAs("three", Integer.class), is(99));
        assertThat(firstRowValues.containsKey("XX"), is(false));
        assertThat(firstRow.valueAs("XX", Integer.class, 13), is(13));

        Parameters secondRow = examplesTable.getRowAsParameters(1);
        Map<String, String> secondRowValues = secondRow.values();
        assertThat(secondRowValues.containsKey("one"), is(true));
        assertThat(secondRow.valueAs("one", String.class), is("22"));
        assertThat(secondRow.valueAs("one", Integer.class), is(22));
        assertThat(secondRowValues.containsKey("three"), is(true));
        assertThat(secondRow.valueAs("three", String.class), is("99"));
        assertThat(secondRow.valueAs("three", Integer.class), is(99));
        assertThat(secondRowValues.containsKey("XX"), is(false));
        assertThat(secondRow.valueAs("XX", Integer.class, 13), is(13));

    }
View Full Code Here

        Map<String, String> namedParameters = new HashMap<String, String>();
        namedParameters.put("<value>", "value1");
        ExamplesTable table = factory.createExamplesTable(tableAsString).withNamedParameters(namedParameters);

        // Then
        Parameters firstRow = table.getRowsAsParameters(true).get(0);
        Map<String, String> firstRowValues = firstRow.values();
        assertThat(firstRowValues.containsKey("Value"), is(true));
        assertThat(firstRow.valueAs("Value", String.class), is("value1"));

    }
View Full Code Here

        // When
        String tableAsString = "|one|two|\n|11|22|\n";
        ExamplesTable examplesTable = factory.createExamplesTable(tableAsString);

        // Then
        Parameters integers = examplesTable.getRowAsParameters(0);
        assertThat(integers.valueAs("one", Integer.class), equalTo(11));
        try {
            integers.valueAs("unknown", Integer.class);
        } catch (ValueNotFound e) {
            assertThat(e.getMessage(), equalTo("unknown"));
        }
        try {
            examplesTable.getRowAsParameters(1);
View Full Code Here

        Map<String, String> otherValues = new HashMap<String, String>();
        otherValues.put("two", "222");
        examplesTable.withRowValues(1, otherValues);

        // Then
        Parameters firstRow = examplesTable.getRowAsParameters(0);
        assertThat(firstRow.valueAs("one", Integer.class), equalTo(111));
        assertThat(firstRow.valueAs("two", Integer.class), equalTo(12));
        assertThat(firstRow.valueAs("three", Integer.class), equalTo(333));
        Parameters secondRow = examplesTable.getRowAsParameters(1);
        assertThat(secondRow.valueAs("one", Integer.class), equalTo(21));
        assertThat(secondRow.valueAs("two", Integer.class), equalTo(222));
        assertThat(secondRow.valueAs("three", String.class), equalTo(""));
        assertThat(examplesTable.asString(), equalTo("|one|two|three|\n|111|12|333|\n|21|222||\n"));
    }
View Full Code Here

    // Returns just the first row in the users' credentials table
    public static UserPassCredentials getDefaultCredentialsFromTable(
            ExamplesTable credentialsTable) {
        assert credentialsTable.getRowCount() > 0 : "user table must have at least 1 row";
        Parameters firstRow = credentialsTable.getRowAsParameters(0);
        String username = firstRow.valueAs("username", String.class);
        String password = firstRow.valueAs("password", String.class);

        return new UserPassCredentials(username, password);
    }
View Full Code Here

TOP

Related Classes of org.jbehave.core.steps.Parameters

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.