use of org.jbehave.core.steps.Parameters in project jbehave-core by jbehave.
the class ExamplesTableBehaviour method shouldReplaceNamedParameterValues.
@Test
public void shouldReplaceNamedParameterValues() throws Exception {
// Given
ExamplesTableFactory factory = createFactory();
// When
String tableAsString = "|Name|Value|\n|name1|<value>|";
Map<String, String> namedParameters = new HashMap<>();
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.<String>valueAs("Value", String.class), is("value1"));
}
use of org.jbehave.core.steps.Parameters in project jbehave-core by jbehave.
the class ExamplesTableBehaviour method shouldKeepExactValueInReplacedNamedParameterValues.
/**
* The values given named parameter values as strings should not suffer any modification after are replaced in table.
*
* @see {@link String#replaceAll(String, String)} to see why are not present in values the '\' and '$' characters.
*/
@Test
public void shouldKeepExactValueInReplacedNamedParameterValues() throws Exception {
// Given
ExamplesTableFactory factory = createFactory();
String problematicNamedParameterValueCharacters = "value having the \\ backslash and the $ dollar character";
// When
String tableAsString = "|Name|Value|\n|name|<value>|";
Map<String, String> namedParameters = new HashMap<>();
namedParameters.put("value", problematicNamedParameterValueCharacters);
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.<String>valueAs("Value", String.class), is(problematicNamedParameterValueCharacters));
}
Aggregations