use of org.jbehave.core.steps.Parameters in project javaparser by javaparser.
the class CommentParsingSteps method thenTheBlockCommentsHaveTheFollowingPositions.
@Then("the block comments have the following positions: $table")
public void thenTheBlockCommentsHaveTheFollowingPositions(ExamplesTable examplesTable) {
int index = 0;
for (Parameters exampleRow : examplesTable.getRowsAsParameters()) {
Comment expectedLineComment = toComment(exampleRow, new BlockComment());
Comment lineCommentUnderTest = getCommentAt(commentsCollection.getBlockComments(), index);
Range underTestRange = lineCommentUnderTest.getRange().get();
Range expectedRange = expectedLineComment.getRange().get();
assertThat(underTestRange.begin.line, is(expectedRange.begin.line));
assertThat(underTestRange.begin.column, is(expectedRange.begin.column));
assertThat(underTestRange.end.line, is(expectedRange.end.line));
assertThat(underTestRange.end.column, is(expectedRange.end.column));
index++;
}
}
use of org.jbehave.core.steps.Parameters in project jbehave-core by jbehave.
the class TraderSteps method theTradersActivityIs.
@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) + " (" + row.valueAs("rank", String.class, "N/A") + ") has done " + row.valueAs("trades", Integer.class) + " trades");
}
}
use of org.jbehave.core.steps.Parameters in project jbehave-core by jbehave.
the class ExamplesTableBehaviour method shouldThrowExceptionIfValuesOrRowsAreNotFound.
@Test
public void shouldThrowExceptionIfValuesOrRowsAreNotFound() throws Exception {
// Given
ExamplesTableFactory factory = createFactory();
// When
String tableAsString = "|one|two|\n|11|22|\n";
ExamplesTable examplesTable = factory.createExamplesTable(tableAsString);
// Then
Parameters integers = examplesTable.getRowAsParameters(0);
assertThat(integers.<Integer>valueAs("one", Integer.class), equalTo(11));
try {
integers.valueAs("unknown", Integer.class);
throw new AssertionError("Exception was not thrown");
} catch (ValueNotFound e) {
assertThat(e.getMessage(), equalTo("unknown"));
}
try {
examplesTable.getRowAsParameters(1);
throw new AssertionError("Exception was not thrown");
} catch (RowNotFound e) {
assertThat(e.getMessage(), equalTo("1"));
}
}
use of org.jbehave.core.steps.Parameters in project jbehave-core by jbehave.
the class ExamplesTableBehaviour method shouldReplaceNamedParameterValuesInValuePart.
@Test
public void shouldReplaceNamedParameterValuesInValuePart() throws Exception {
// Given
ExamplesTableFactory factory = createFactory();
// When
String tableAsString = "|Name|Value|\n|name1|foo-<value>-bar|";
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("foo-value1-bar"));
}
use of org.jbehave.core.steps.Parameters in project jbehave-core by jbehave.
the class ExamplesTableBehaviour method shouldParseTableWithUntrimmedCommentsInValues.
@Test
public void shouldParseTableWithUntrimmedCommentsInValues() {
String tableWithEmptyValues = "{commentSeparator=#, trim=false}\n|one #comment|two|\n |11 #comment|12 #comment|\n |21|22|\n";
ExamplesTable table = new ExamplesTable(tableWithEmptyValues);
assertThat(table.getRowCount(), equalTo(2));
for (Parameters row : table.getRowsAsParameters()) {
Map<String, String> values = row.values();
assertThat(values.size(), equalTo(2));
for (String column : values.keySet()) {
assertThat(values.get(column), not(containsString("#comment")));
}
}
assertThat(table.asString(), equalTo("{commentSeparator=#, trim=false}\n|one |two|\n|11 |12 |\n|21|22|\n"));
}
Aggregations