Examples of convertValue()


Examples of org.jbehave.core.steps.ParameterConverters.NumberListConverter.convertValue()

        assertThat(longs.get(0), equalTo(3L));
        assertThat(longs.get(1), equalTo(0L));
        assertThat(longs.get(2), equalTo(8L));

        Type intsType = SomeSteps.methodFor("aMethodWithListOfIntegers").getGenericParameterTypes()[0];
        List<Integer> ints = (List<Integer>) converter.convertValue("3, 0, 8", intsType);
        assertThat(ints.get(0), equalTo(3));
        assertThat(ints.get(1), equalTo(0));
        assertThat(ints.get(2), equalTo(8));
    }
View Full Code Here

Examples of org.jbehave.core.steps.ParameterConverters.NumberListConverter.convertValue()

    @Test(expected = ParameterConvertionFailed.class)
    public void shouldFailToConvertCommaSeparatedValuesOfInvalidNumbers() throws ParseException, IntrospectionException {
        ParameterConverter converter = new NumberListConverter();
        Type type = SomeSteps.methodFor("aMethodWithListOfNumbers").getGenericParameterTypes()[0];
        converter.convertValue("3x, x.5", type);
    }

    @Test
    public void shouldConvertCommaSeparatedValuesToListOfStrings() throws IntrospectionException {
        ParameterConverter converter = new StringListConverter();
View Full Code Here

Examples of org.jbehave.core.steps.ParameterConverters.ParameterConverter.convertValue()

        assertThat(converter.accept(type), is(true));
        assertThat(converter.accept(WrongType.class), is(false));
        assertThat(converter.accept(mock(Type.class)), is(false));
        String value = "|col1|col2|\n|row11|row12|\n|row21|row22|\n";
        @SuppressWarnings("unchecked")
        List<MyParameters> parameters = (List<MyParameters>) converter.convertValue(value, type);
        assertThat(parameters.size(), equalTo(2));
        MyParameters row1 = parameters.get(0);
        assertThat(row1.col1, equalTo("row11"));
        assertThat(row1.col2, equalTo("row12"));
        MyParameters row2 = parameters.get(1);
View Full Code Here

Examples of org.jbehave.core.steps.ParameterConverters.ParameterConverter.convertValue()

        Type type = SomeSteps.methodFor("aMethodWithExamplesTableParameter").getGenericParameterTypes()[0];
        assertThat(converter.accept(type), is(true));
        assertThat(converter.accept(WrongType.class), is(false));
        assertThat(converter.accept(mock(Type.class)), is(false));
        String value = "|col1|col2|\n|row11|row12|\n";
        MyParameters parameters = (MyParameters) converter.convertValue(value, type);
        assertThat(parameters.col1, equalTo("row11"));
        assertThat(parameters.col2, equalTo("row12"));
    }

    @Test
View Full Code Here

Examples of org.jbehave.core.steps.ParameterConverters.ParameterConverter.convertValue()

        ParameterConverter converter = new MethodReturningConverter(method, new SomeSteps());
        assertThat(converter.accept(method.getReturnType()), is(true));
        assertThat(converter.accept(WrongType.class), is(false));
        assertThat(converter.accept(mock(Type.class)), is(false));
        String value = "|col1|col2|\n|row11|row12|\n|row21|row22|\n";
        ExamplesTable table = (ExamplesTable) converter.convertValue(value, ExamplesTable.class);
        assertThat(table.getRowCount(), equalTo(2));
        Map<String, String> row1 = table.getRow(0);
        assertThat(row1.get("col1"), equalTo("row11"));
        assertThat(row1.get("col2"), equalTo("row12"));
        Map<String, String> row2 = table.getRow(1);
View Full Code Here

Examples of org.jbehave.core.steps.ParameterConverters.ParameterConverter.convertValue()

    public void shouldFailToConvertParameterFromFailingMethodReturningValue() throws ParseException,
            IntrospectionException {
        Method method = SomeSteps.methodFor("aFailingMethodReturningExamplesTable");
        ParameterConverter converter = new MethodReturningConverter(method, new SomeSteps());
        String value = "|col1|col2|\n|row11|row12|\n|row21|row22|\n";
        converter.convertValue(value, ExamplesTable.class);
    }

    @Test(expected = ParameterConvertionFailed.class)
    public void shouldFailToConvertToUnknownType() throws ParseException, IntrospectionException {
        new ParameterConverters().convert("abc", WrongType.class);
View Full Code Here

Examples of org.jbehave.core.steps.ParameterConverters.ParameterConverter.convertValue()

        ParameterConverter converter = new EnumConverter();
        assertThat(converter.accept(SomeEnum.class), equalTo(true));
        assertThat(converter.accept(WrongType.class), is(false));
        assertThat(converter.accept(mock(Type.class)), is(false));
        Type type = SomeSteps.methodFor("aMethodWithEnum").getGenericParameterTypes()[0];
        assertThat((SomeEnum) converter.convertValue("ONE", type), equalTo(SomeEnum.ONE));
    }
   
   
    @Test(expected = ParameterConvertionFailed.class)
    public void shouldFailToConvertEnumForValueNotDefined() throws IntrospectionException {
View Full Code Here

Examples of org.jbehave.core.steps.ParameterConverters.ParameterConverter.convertValue()

   
    @Test(expected = ParameterConvertionFailed.class)
    public void shouldFailToConvertEnumForValueNotDefined() throws IntrospectionException {
        ParameterConverter converter = new EnumConverter();
        Type type = SomeSteps.methodFor("aMethodWithEnum").getGenericParameterTypes()[0];
        converter.convertValue("FOUR", type);
    }

    @SuppressWarnings("unchecked")
    @Test
    public void shouldConvertEnumList() throws IntrospectionException {
View Full Code Here

Examples of org.jbehave.core.steps.ParameterConverters.ParameterConverter.convertValue()

    @Test
    public void shouldConvertEnumList() throws IntrospectionException {
        ParameterConverter converter = new EnumListConverter();
        Type type = SomeSteps.methodFor("aMethodWithEnumList").getGenericParameterTypes()[0];
        assertThat(converter.accept(type), equalTo(true));
        List<SomeEnum> list = (List<SomeEnum>)converter.convertValue("ONE,TWO,THREE", type);
        assertThat(list.get(0), equalTo(SomeEnum.ONE));
        assertThat(list.get(1), equalTo(SomeEnum.TWO));
        assertThat(list.get(2), equalTo(SomeEnum.THREE));
    }
View Full Code Here

Examples of org.jbehave.core.steps.ParameterConverters.ParameterConverter.convertValue()

        assertThat(converter.accept(Boolean.TYPE), equalTo(true));
        assertThat(converter.accept(Boolean.class), equalTo(true));
        assertThat(converter.accept(WrongType.class), is(false));
        assertThat(converter.accept(mock(Type.class)), is(false));
        Type type = SomeSteps.methodFor("aMethodWithBoolean").getGenericParameterTypes()[0];
        assertThat((Boolean) converter.convertValue("true", type), is(true));
        assertThat((Boolean) converter.convertValue("false", type), is(false));
        assertThat((Boolean) converter.convertValue("whatever", type), is(false));
    }

    @Test
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.