Search in sources :

Example 1 with ExamplesTableParametersConverter

use of org.jbehave.core.steps.ParameterConverters.ExamplesTableParametersConverter in project jbehave-core by jbehave.

the class ParameterConvertersBehaviour method shouldConvertMultilineTableToParameters.

@Test
public void shouldConvertMultilineTableToParameters() {
    ParameterConverter converter = new ExamplesTableParametersConverter(new ExamplesTableFactory(new LoadFromClasspath(), new TableTransformers()));
    Type type = new TypeLiteral<List<MyParameters>>() {
    }.getType();
    assertThatTypesAreAccepted(converter, type);
    String value = "|col1|col2|\n|row11|row12|\n|row21|row22|\n";
    @SuppressWarnings("unchecked") List<MyParameters> parameters = (List<MyParameters>) converter.convertValue(value, type);
    assertThat(parameters.size(), is(2));
    MyParameters row1 = parameters.get(0);
    assertThat(row1.col1, is("row11"));
    assertThat(row1.col2, is("row12"));
    MyParameters row2 = parameters.get(1);
    assertThat(row2.col1, is("row21"));
    assertThat(row2.col2, is("row22"));
}
Also used : Type(java.lang.reflect.Type) AbstractParameterConverter(org.jbehave.core.steps.ParameterConverters.AbstractParameterConverter) ParameterConverter(org.jbehave.core.steps.ParameterConverters.ParameterConverter) ExamplesTableParametersConverter(org.jbehave.core.steps.ParameterConverters.ExamplesTableParametersConverter) LoadFromClasspath(org.jbehave.core.io.LoadFromClasspath) MyParameters(org.jbehave.core.steps.SomeSteps.MyParameters) ExamplesTableFactory(org.jbehave.core.model.ExamplesTableFactory) Arrays.asList(java.util.Arrays.asList) TableTransformers(org.jbehave.core.model.TableTransformers) Test(org.junit.Test)

Example 2 with ExamplesTableParametersConverter

use of org.jbehave.core.steps.ParameterConverters.ExamplesTableParametersConverter in project jbehave-core by jbehave.

the class ParameterConvertersBehaviour method shouldConvertSinglelineTableToParameters.

@Test
public void shouldConvertSinglelineTableToParameters() {
    ParameterConverter converter = new ExamplesTableParametersConverter(new ExamplesTableFactory(new LoadFromClasspath(), new TableTransformers()));
    Type type = MyParameters.class;
    assertThatTypesAreAccepted(converter, type);
    String value = "|col1|col2|\n|row11|row12|\n";
    MyParameters parameters = (MyParameters) converter.convertValue(value, type);
    assertThat(parameters.col1, is("row11"));
    assertThat(parameters.col2, is("row12"));
}
Also used : Type(java.lang.reflect.Type) AbstractParameterConverter(org.jbehave.core.steps.ParameterConverters.AbstractParameterConverter) ParameterConverter(org.jbehave.core.steps.ParameterConverters.ParameterConverter) ExamplesTableParametersConverter(org.jbehave.core.steps.ParameterConverters.ExamplesTableParametersConverter) LoadFromClasspath(org.jbehave.core.io.LoadFromClasspath) MyParameters(org.jbehave.core.steps.SomeSteps.MyParameters) ExamplesTableFactory(org.jbehave.core.model.ExamplesTableFactory) TableTransformers(org.jbehave.core.model.TableTransformers) Test(org.junit.Test)

Aggregations

Type (java.lang.reflect.Type)2 LoadFromClasspath (org.jbehave.core.io.LoadFromClasspath)2 ExamplesTableFactory (org.jbehave.core.model.ExamplesTableFactory)2 TableTransformers (org.jbehave.core.model.TableTransformers)2 AbstractParameterConverter (org.jbehave.core.steps.ParameterConverters.AbstractParameterConverter)2 ExamplesTableParametersConverter (org.jbehave.core.steps.ParameterConverters.ExamplesTableParametersConverter)2 ParameterConverter (org.jbehave.core.steps.ParameterConverters.ParameterConverter)2 MyParameters (org.jbehave.core.steps.SomeSteps.MyParameters)2 Test (org.junit.Test)2 Arrays.asList (java.util.Arrays.asList)1