Search in sources :

Example 36 with LoadFromClasspath

use of org.jbehave.core.io.LoadFromClasspath 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"));
}
Also used : Type(java.lang.reflect.Type) AbstractParameterConverter(org.jbehave.core.steps.ParameterConverters.AbstractParameterConverter) ParameterConverter(org.jbehave.core.steps.ParameterConverters.ParameterConverter) ExamplesTableParametersConverter(org.jbehave.core.steps.ParameterConverters.ExamplesTableParametersConverter) LoadFromClasspath(org.jbehave.core.io.LoadFromClasspath) MyParameters(org.jbehave.core.steps.SomeSteps.MyParameters) ExamplesTableFactory(org.jbehave.core.model.ExamplesTableFactory) TableTransformers(org.jbehave.core.model.TableTransformers) Test(org.junit.Test)

Example 37 with LoadFromClasspath

use of org.jbehave.core.io.LoadFromClasspath in project jbehave-core by jbehave.

the class ParameterConvertersBehaviour method shouldConvertToSortedSetOfCustomObjectsUsingCustomConverter.

@SuppressWarnings("unchecked")
@Test
public void shouldConvertToSortedSetOfCustomObjectsUsingCustomConverter() {
    ParameterConverters parameterConverters = new ParameterConverters(new LoadFromClasspath());
    parameterConverters.addConverters(new FooToBarParameterConverter());
    Type type = new TypeLiteral<SortedSet<Bar>>() {
    }.getType();
    Set<Bar> set = (Set<Bar>) parameterConverters.convert("foo", type);
    assertThatCollectionIs(set, Bar.INSTANCE);
}
Also used : Type(java.lang.reflect.Type) LoadFromClasspath(org.jbehave.core.io.LoadFromClasspath) Test(org.junit.Test)

Example 38 with LoadFromClasspath

use of org.jbehave.core.io.LoadFromClasspath 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"));
}
Also used : HashMap(java.util.HashMap) LoadFromClasspath(org.jbehave.core.io.LoadFromClasspath) TableTransformers(org.jbehave.core.model.TableTransformers) Test(org.junit.Test)

Example 39 with LoadFromClasspath

use of org.jbehave.core.io.LoadFromClasspath in project jbehave-core by jbehave.

the class OdtLoaderBehaviour method shouldLoadOdtResourceFromClasspath.

@Test
public void shouldLoadOdtResourceFromClasspath() {
    String resourceFromOdtWithTable = new LoadOdtFromClasspath(this.getClass()).loadResourceAsText("org/jbehave/core/io/odf/stories/a_story.odt");
    String resourceFromTxt = new LoadFromClasspath(this.getClass()).loadResourceAsText("org/jbehave/core/io/odf/stories/a_story.txt");
    assertThatOutputIs(resourceFromOdtWithTable.trim(), resourceFromTxt.trim());
}
Also used : LoadFromClasspath(org.jbehave.core.io.LoadFromClasspath) Test(org.junit.Test)

Aggregations

LoadFromClasspath (org.jbehave.core.io.LoadFromClasspath)39 Test (org.junit.Test)27 TableTransformers (org.jbehave.core.model.TableTransformers)22 MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)9 ParameterConverters (org.jbehave.core.steps.ParameterConverters)9 Type (java.lang.reflect.Type)8 StoryReporterBuilder (org.jbehave.core.reporters.StoryReporterBuilder)8 ExamplesTableFactory (org.jbehave.core.model.ExamplesTableFactory)7 RegexStoryParser (org.jbehave.core.parsers.RegexStoryParser)7 ParameterControls (org.jbehave.core.steps.ParameterControls)7 LocalizedKeywords (org.jbehave.core.i18n.LocalizedKeywords)6 SimpleDateFormat (java.text.SimpleDateFormat)5 RegexStepMatcher (org.jbehave.core.parsers.RegexStepMatcher)5 StepMatcher (org.jbehave.core.parsers.StepMatcher)5 DateConverter (org.jbehave.core.steps.ParameterConverters.DateConverter)5 ParametrisedStep (org.jbehave.core.steps.StepCreator.ParametrisedStep)5 ExamplesTableConverter (org.jbehave.core.steps.ParameterConverters.ExamplesTableConverter)4 ParameterConverter (org.jbehave.core.steps.ParameterConverters.ParameterConverter)4 HashMap (java.util.HashMap)3 Properties (java.util.Properties)3