use of org.jbehave.core.model.TableTransformers.TableTransformer in project jbehave-core by jbehave.
the class TableTransformersBehaviour method shouldTransformTableWithCustomTransformer.
@Test
public void shouldTransformTableWithCustomTransformer() {
TableTransformers tableTransformers = new TableTransformers();
tableTransformers.useTransformer("myTransformer", new TableTransformer() {
@Override
public String transform(String tableAsString, ExamplesTableProperties properties) {
return myTransformedTableAsString;
}
});
String transformed = tableTransformers.transform("myTransformer", tableAsString, PROPERTIES);
assertThat(transformed, equalTo(myTransformedTableAsString));
}
use of org.jbehave.core.model.TableTransformers.TableTransformer in project jbehave-core by jbehave.
the class ExamplesTableBehaviour method shouldParseTableWithCustomTransformerSpecifiedViaProperties.
@Test
public void shouldParseTableWithCustomTransformerSpecifiedViaProperties() {
String tableWithProperties = "{transformer=myTransformer, trim=false}\n" + tableWithCommentsAsString;
TableTransformers tableTransformers = new TableTransformers();
tableTransformers.useTransformer("myTransformer", new TableTransformer() {
@Override
public String transform(String tableAsString, ExamplesTableProperties properties) {
return tableWithSpacesAsString;
}
});
ExamplesTable table = new ExamplesTableFactory(new LoadFromClasspath(), tableTransformers).createExamplesTable(tableWithProperties);
Properties properties = table.getProperties();
assertThat(properties.getProperty("transformer"), equalTo("myTransformer"));
ensureWhitespaceIsPreserved(table);
}
Aggregations