Search in sources :

Example 11 with ExamplesTable

use of org.jbehave.core.model.ExamplesTable in project jbehave-core by jbehave.

the class ParameterConvertersBehaviour method shouldConvertParameterFromMethodReturningValue.

@Test
public void shouldConvertParameterFromMethodReturningValue() throws IntrospectionException {
    Method method = SomeSteps.methodFor("aMethodReturningExamplesTable");
    ParameterConverter converter = new MethodReturningConverter(method, new SomeSteps());
    assertThatTypesAreAccepted(converter, method.getReturnType());
    String value = "|col1|col2|\n|row11|row12|\n|row21|row22|\n";
    ExamplesTable table = (ExamplesTable) converter.convertValue(value, ExamplesTable.class);
    assertThat(table.getRowCount(), is(2));
    Map<String, String> row1 = table.getRow(0);
    assertThat(row1.get("col1"), is("row11"));
    assertThat(row1.get("col2"), is("row12"));
    Map<String, String> row2 = table.getRow(1);
    assertThat(row2.get("col1"), is("row21"));
    assertThat(row2.get("col2"), is("row22"));
}
Also used : AbstractParameterConverter(org.jbehave.core.steps.ParameterConverters.AbstractParameterConverter) ParameterConverter(org.jbehave.core.steps.ParameterConverters.ParameterConverter) ExamplesTable(org.jbehave.core.model.ExamplesTable) MethodReturningConverter(org.jbehave.core.steps.ParameterConverters.MethodReturningConverter) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 12 with ExamplesTable

use of org.jbehave.core.model.ExamplesTable in project jbehave-core by jbehave.

the class GuiceAnnotationBuilderBehaviour method assertThatExamplesTableIsConverted.

private void assertThatExamplesTableIsConverted(ParameterConverters parameterConverters) {
    String tableAsString = "||one||two||\n" + "|1|2|";
    ExamplesTable table = new ExamplesTable(tableAsString);
    assertThat(table.getHeaders(), hasItems("one", "two"));
}
Also used : ExamplesTable(org.jbehave.core.model.ExamplesTable)

Example 13 with ExamplesTable

use of org.jbehave.core.model.ExamplesTable in project jbehave-core by jbehave.

the class NeedleAnnotationBuilderBehaviour method assertThatExamplesTableIsConverted.

private void assertThatExamplesTableIsConverted(final ParameterConverters parameterConverters) {
    final String tableAsString = "||one||two||\n" + "|1|2|";
    final ExamplesTable table = new ExamplesTable(tableAsString);
    assertThat(table.getHeaders(), hasItems("one", "two"));
}
Also used : ExamplesTable(org.jbehave.core.model.ExamplesTable)

Aggregations

ExamplesTable (org.jbehave.core.model.ExamplesTable)13 Test (org.junit.Test)6 Scenario (org.jbehave.core.model.Scenario)5 Story (org.jbehave.core.model.Story)5 UUIDExceptionWrapper (org.jbehave.core.failures.UUIDExceptionWrapper)4 GivenStories (org.jbehave.core.model.GivenStories)4 Meta (org.jbehave.core.model.Meta)3 OutcomesTable (org.jbehave.core.model.OutcomesTable)3 InOrder (org.mockito.InOrder)3 HashMap (java.util.HashMap)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Method (java.lang.reflect.Method)1 Type (java.lang.reflect.Type)1 Then (org.jbehave.core.annotations.Then)1 Keywords (org.jbehave.core.configuration.Keywords)1 LoadFromClasspath (org.jbehave.core.io.LoadFromClasspath)1 Description (org.jbehave.core.model.Description)1 ExamplesTableFactory (org.jbehave.core.model.ExamplesTableFactory)1 ExamplesTableProperties (org.jbehave.core.model.ExamplesTableProperties)1 GivenStory (org.jbehave.core.model.GivenStory)1