Examples of convertValue()


Examples of org.jbehave.core.steps.ParameterConverters.ExamplesTableParametersConverter.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.ExamplesTableParametersConverter.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.MethodReturningConverter.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.MethodReturningConverter.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.NumberConverter.convertValue()

    public void shouldConvertValuesToNumbersWithFrenchNumberFormat() {
        Locale locale = Locale.FRENCH;
        ParameterConverter converter = new NumberConverter(NumberFormat.getInstance(locale));
        assertThatAllNumberTypesAreAccepted(converter);
        assertThatAllNumbersAreConverted(converter, locale);
        assertThat((Float) converter.convertValue("100000,01", Float.class), equalTo(100000.01f));
        assertThat((Double) converter.convertValue("100000,01", Double.class), equalTo(100000.01d));
    }

    @Test
    public void shouldConvertValuesToNumbersWithGermanNumberFormat() {
View Full Code Here

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

        Locale locale = Locale.FRENCH;
        ParameterConverter converter = new NumberConverter(NumberFormat.getInstance(locale));
        assertThatAllNumberTypesAreAccepted(converter);
        assertThatAllNumbersAreConverted(converter, locale);
        assertThat((Float) converter.convertValue("100000,01", Float.class), equalTo(100000.01f));
        assertThat((Double) converter.convertValue("100000,01", Double.class), equalTo(100000.01d));
    }

    @Test
    public void shouldConvertValuesToNumbersWithGermanNumberFormat() {
        Locale locale = Locale.GERMAN;
View Full Code Here

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

    public void shouldConvertValuesToNumbersWithGermanNumberFormat() {
        Locale locale = Locale.GERMAN;
        ParameterConverter converter = new NumberConverter(NumberFormat.getInstance(locale));       
        assertThatAllNumberTypesAreAccepted(converter);
        assertThatAllNumbersAreConverted(converter, locale);
        assertThat((BigDecimal) converter.convertValue("1.000.000,01", BigDecimal.class), equalTo(new BigDecimal("1000000.01")));
    }

    private void assertThatAllNumberTypesAreAccepted(ParameterConverter converter) {
        assertThat(converter.accept(Byte.class), equalTo(true));
        assertThat(converter.accept(byte.class), equalTo(true));
View Full Code Here

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

    @Test
    public void shouldFailToConvertInvalidNumbersWithNumberFormat() {
        NumberConverter converter = new NumberConverter();
        try {
            converter.convertValue("abc", Long.class);
        } catch (ParameterConvertionFailed e) {
            assertThat(e.getCause(), is(instanceOf(ParseException.class)));
        }
    }
View Full Code Here

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

    @Test
    public void shouldFailToConvertInvalidNumbersWithNumberFormat2()  {
        NumberConverter converter = new NumberConverter();
        try {
            converter.convertValue("12.34.56", BigDecimal.class);
        } catch (ParameterConvertionFailed e) {
            assertThat(e.getCause(), is(instanceOf(NumberFormatException.class)));
        }
    }
View Full Code Here

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

    }

    @Test
    public void shouldConvertNaNAndInfinityValuesToNumbers() {
        ParameterConverter converter = new NumberConverter();
        assertThat((Float) converter.convertValue(NAN, Float.class), equalTo(Float.NaN));
        assertThat((Float) converter.convertValue(INFINITY, Float.class), equalTo(Float.POSITIVE_INFINITY));
        assertThat((Float) converter.convertValue("-"+INFINITY, Float.class), equalTo(Float.NEGATIVE_INFINITY));
        assertThat((Double) converter.convertValue(NAN, Double.class), equalTo(Double.NaN));
        assertThat((Double) converter.convertValue(INFINITY, Double.class), equalTo(Double.POSITIVE_INFINITY));
        assertThat((Double) converter.convertValue("-"+INFINITY, Double.class), equalTo(Double.NEGATIVE_INFINITY));
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.