use of org.jbehave.core.model.ExamplesTableFactory in project jbehave-core by jbehave.
the class CoreStories method configuration.
@Override
public Configuration configuration() {
// alternative use #useConfiguration() in the constructor
if (super.hasConfiguration()) {
return super.configuration();
}
Class<? extends Embeddable> embeddableClass = this.getClass();
Properties viewResources = new Properties();
viewResources.put("decorateNonHtml", "true");
viewResources.put("reports", "ftl/jbehave-reports.ftl");
LoadFromClasspath resourceLoader = new LoadFromClasspath(embeddableClass);
TableTransformers tableTransformers = new TableTransformers();
ParameterControls parameterControls = new ParameterControls();
// Start from default ParameterConverters instance
ParameterConverters parameterConverters = new ParameterConverters(resourceLoader, tableTransformers);
// factory to allow parameter conversion and loading from external
// resources (used by StoryParser too)
ExamplesTableFactory examplesTableFactory = new ExamplesTableFactory(new LocalizedKeywords(), resourceLoader, parameterConverters, parameterControls, tableTransformers);
// add custom converters
parameterConverters.addConverters(new DateConverter(new SimpleDateFormat("yyyy-MM-dd")), new ExamplesTableConverter(examplesTableFactory));
return new MostUsefulConfiguration().useStoryLoader(resourceLoader).useStoryParser(new RegexStoryParser(examplesTableFactory)).useStoryReporterBuilder(new StoryReporterBuilder().withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass)).withDefaultFormats().withViewResources(viewResources).withFormats(contextFormat, CONSOLE, TXT, HTML_TEMPLATE, XML_TEMPLATE).withFailureTrace(true).withFailureTraceCompression(true).withCrossReference(xref).withSurefireReporter(new SurefireReporter(embeddableClass))).useParameterConverters(parameterConverters).useParameterControls(parameterControls).useTableTransformers(tableTransformers);
}
use of org.jbehave.core.model.ExamplesTableFactory in project jbehave-core by jbehave.
the class ParameterConverters method defaultConverters.
protected ParameterConverter[] defaultConverters(ResourceLoader resourceLoader, ParameterControls parameterControls, TableTransformers tableTransformers, Locale locale, String collectionSeparator) {
this.escapedCollectionSeparator = escapeRegexPunctuation(collectionSeparator);
ExamplesTableFactory tableFactory = new ExamplesTableFactory(resourceLoader, this, parameterControls, tableTransformers);
JsonFactory jsonFactory = new JsonFactory();
return new ParameterConverter[] { new BooleanConverter(), new NumberConverter(NumberFormat.getInstance(locale)), new StringConverter(), new StringListConverter(escapedCollectionSeparator), new DateConverter(), new EnumConverter(), new ExamplesTableConverter(tableFactory), new ExamplesTableParametersConverter(tableFactory), new JsonConverter(jsonFactory) };
}
use of org.jbehave.core.model.ExamplesTableFactory 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.model.ExamplesTableFactory in project jbehave-core by jbehave.
the class CoreStoryMaps method configuration.
@Override
public Configuration configuration() {
TableTransformers tableTransformers = new TableTransformers();
ExamplesTableFactory tableFactory = new ExamplesTableFactory(new LoadFromClasspath(this.getClass()), tableTransformers);
return new MostUsefulConfiguration().useStoryParser(new RegexStoryParser(tableFactory)).useStoryReporterBuilder(new StoryReporterBuilder().withCodeLocation(CodeLocations.codeLocationFromClass(this.getClass()))).useTableTransformers(tableTransformers);
}
use of org.jbehave.core.model.ExamplesTableFactory in project jbehave-core by jbehave.
the class MyStories method configuration.
@Override
public Configuration configuration() {
Class<? extends Embeddable> embeddableClass = this.getClass();
LoadFromClasspath resourceLoader = new LoadFromClasspath(embeddableClass);
TableTransformers tableTransformers = new TableTransformers();
ParameterControls parameterControls = new ParameterControls();
// Start from default ParameterConverters instance
ParameterConverters parameterConverters = new ParameterConverters(resourceLoader, tableTransformers);
// factory to allow parameter conversion and loading from external resources (used by StoryParser too)
ExamplesTableFactory examplesTableFactory = new ExamplesTableFactory(new LocalizedKeywords(), resourceLoader, parameterConverters, parameterControls, tableTransformers);
// add custom converters
parameterConverters.addConverters(new DateConverter(new SimpleDateFormat("yyyy-MM-dd")), new ExamplesTableConverter(examplesTableFactory));
return new MostUsefulConfiguration().useStoryLoader(resourceLoader).useStoryParser(new RegexStoryParser(examplesTableFactory)).useStoryReporterBuilder(new StoryReporterBuilder().withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass)).withDefaultFormats().withFormats(CONSOLE, TXT, HTML, XML)).useParameterConverters(parameterConverters).useParameterControls(parameterControls).useTableTransformers(tableTransformers);
}
Aggregations