use of org.jbehave.core.model.TableTransformers in project jbehave-core by jbehave.
the class ParameterConvertersBehaviour method shouldDefineDefaultConverters.
@SuppressWarnings("unchecked")
@Test
public void shouldDefineDefaultConverters() {
LoadFromClasspath resourceLoader = new LoadFromClasspath();
TableTransformers tableTransformers = new TableTransformers();
ParameterControls parameterControls = new ParameterControls();
ParameterConverters converters = new ParameterConverters(resourceLoader, parameterControls, tableTransformers, true);
ParameterConverter<?>[] defaultConverters = converters.defaultConverters(resourceLoader, parameterControls, tableTransformers, Locale.ENGLISH, ",");
assertThatDefaultConvertersInclude(defaultConverters, BooleanConverter.class, NumberConverter.class, StringListConverter.class, DateConverter.class, EnumConverter.class, ExamplesTableConverter.class, ExamplesTableParametersConverter.class);
}
use of org.jbehave.core.model.TableTransformers 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"));
}
use of org.jbehave.core.model.TableTransformers in project jbehave-core by jbehave.
the class ParameterConvertersBehaviour method shouldNotConvertToListOfCustomObjectsWhenElementConverterIsNotAdded.
@Test
public void shouldNotConvertToListOfCustomObjectsWhenElementConverterIsNotAdded() {
expectedException.expect(ParameterConvertionFailed.class);
expectedException.expectMessage("No parameter converter for java.util.List<org.jbehave.core.steps.ParameterConvertersBehaviour$Bar>");
ParameterConverters parameterConverters = new ParameterConverters(new TableTransformers());
Type type = new TypeLiteral<List<Bar>>() {
}.getType();
parameterConverters.convert("foo", type);
}
use of org.jbehave.core.model.TableTransformers in project jbehave-core by jbehave.
the class ChainedRowBehaviour method shouldChainRowValuesWithoutOverwritingAlreadyExisting.
@Test
public void shouldChainRowValuesWithoutOverwritingAlreadyExisting() throws Exception {
Map<String, String> map1 = new HashMap<>();
map1.put("one", "11");
Map<String, String> map2 = new HashMap<>();
map2.put("one", "21");
map2.put("two", "22");
ParameterConverters parameterConverters = new ParameterConverters(new LoadFromClasspath(), new TableTransformers());
Map<String, String> chainedValues = new ChainedRow(new ConvertedParameters(map1, parameterConverters), new ConvertedParameters(map2, parameterConverters)).values();
assertThat(chainedValues.get("one"), equalTo("11"));
assertThat(chainedValues.get("two"), equalTo("22"));
}
use of org.jbehave.core.model.TableTransformers in project jbehave-core by jbehave.
the class ConfigurationProducer method getConfiguration.
@Produces
@WeldConfiguration
Configuration getConfiguration() {
Properties viewResources = new Properties();
viewResources.setProperty("index", "my-reports-index.ftl");
viewResources.setProperty("decorateNonHtml", "true");
TableTransformers tableTransformers = new TableTransformers();
LoadFromURL resourceLoader = new LoadFromURL();
return new MostUsefulConfiguration().useStoryControls(new StoryControls().doDryRun(true).doSkipScenariosAfterFailure(true)).useFailureStrategy(new SilentlyAbsorbingFailure()).useStoryLoader(resourceLoader).useStepPatternParser(new RegexPrefixCapturingPatternParser("MyPrefix")).useStoryReporterBuilder(new StoryReporterBuilder().withDefaultFormats().withFormats(CONSOLE, HTML, TXT, XML).withKeywords(new LocalizedKeywords(Locale.ITALIAN)).withRelativeDirectory("my-output-directory").withViewResources(viewResources).withFailureTrace(true)).useParameterConverters(new ParameterConverters(resourceLoader, tableTransformers).addConverters(new CustomConverter(), new MyDateConverter())).useTableTransformers(tableTransformers);
}
Aggregations