use of org.jbehave.core.io.LoadFromClasspath in project jbehave-core by jbehave.
the class ParameterConvertersBehaviour method shouldConvertToLinkedListOfCustomObjectsUsingCustomConverter.
@SuppressWarnings("unchecked")
@Test
public void shouldConvertToLinkedListOfCustomObjectsUsingCustomConverter() {
ParameterConverters parameterConverters = new ParameterConverters(new LoadFromClasspath());
parameterConverters.addConverters(new FooToBarParameterConverter());
Type type = new TypeLiteral<LinkedList<Bar>>() {
}.getType();
assertThatCollectionIs((LinkedList<Bar>) parameterConverters.convert("foo", type), Bar.INSTANCE);
}
use of org.jbehave.core.io.LoadFromClasspath in project jbehave-core by jbehave.
the class ParameterConvertersBehaviour method shouldConvertToListOfCustomObjectsUsingCustomConverter.
@Test
public void shouldConvertToListOfCustomObjectsUsingCustomConverter() {
ParameterConverters parameterConverters = new ParameterConverters(new LoadFromClasspath());
parameterConverters.addConverters(new FooToBarParameterConverter());
Type type = new TypeLiteral<List<Bar>>() {
}.getType();
List<Bar> list = (List<Bar>) parameterConverters.convert("foo", type);
assertThatCollectionIs(list, Bar.INSTANCE);
}
use of org.jbehave.core.io.LoadFromClasspath in project jbehave-core by jbehave.
the class ParameterConvertersBehaviour method shouldConvertToNavigableSetOfCustomObjectsUsingCustomConverter.
@SuppressWarnings("unchecked")
@Test
public void shouldConvertToNavigableSetOfCustomObjectsUsingCustomConverter() {
ParameterConverters parameterConverters = new ParameterConverters(new LoadFromClasspath());
parameterConverters.addConverters(new FooToBarParameterConverter());
Type type = new TypeLiteral<NavigableSet<Bar>>() {
}.getType();
Set<Bar> set = (Set<Bar>) parameterConverters.convert("foo", type);
assertThatCollectionIs(set, Bar.INSTANCE);
}
use of org.jbehave.core.io.LoadFromClasspath in project jbehave-core by jbehave.
the class ParameterConvertersBehaviour method shouldConvertMultilineTable.
@Test
public void shouldConvertMultilineTable() {
ParameterConverter<ExamplesTable> converter = new ExamplesTableConverter(new ExamplesTableFactory(new LoadFromClasspath(), new TableTransformers()));
Type type = ExamplesTable.class;
assertThatTypesAreAccepted(converter, type);
String value = "|col1|col2|\n|row11|row12|\n|row21|row22|\n";
ExamplesTable table = converter.convertValue(value, type);
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"));
}
use of org.jbehave.core.io.LoadFromClasspath in project jbehave-core by jbehave.
the class ParameterConvertersBehaviour method shouldConvertToCustomObjectUsingCustomConverter.
@Test
public void shouldConvertToCustomObjectUsingCustomConverter() {
ParameterConverters parameterConverters = new ParameterConverters(new LoadFromClasspath());
parameterConverters.addConverters(new FooToBarParameterConverter());
assertThat((Bar) parameterConverters.convert("foo", Bar.class), is(Bar.INSTANCE));
}
Aggregations