Search in sources :

Example 1 with TableTransformer

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));
}
Also used : TableTransformer(org.jbehave.core.model.TableTransformers.TableTransformer) Test(org.junit.Test)

Example 2 with TableTransformer

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);
}
Also used : TableTransformer(org.jbehave.core.model.TableTransformers.TableTransformer) LoadFromClasspath(org.jbehave.core.io.LoadFromClasspath) Test(org.junit.Test)

Aggregations

TableTransformer (org.jbehave.core.model.TableTransformers.TableTransformer)2 Test (org.junit.Test)2 LoadFromClasspath (org.jbehave.core.io.LoadFromClasspath)1