Examples of convertValue()


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

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

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

    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));
    }

    @SuppressWarnings("unchecked")
View Full Code Here

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

        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));
    }

    @SuppressWarnings("unchecked")
    @Test
View Full Code Here

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

        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));
    }

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

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

        ParameterConverter converter = new NumberListConverter();
        Type listOfNumbers = SomeSteps.methodFor("aMethodWithListOfNumbers").getGenericParameterTypes()[0];
        Type setOfNumbers = SomeSteps.methodFor("aMethodWithSetOfNumbers").getGenericParameterTypes()[0];
        assertThat(converter.accept(listOfNumbers), is(true));
        assertThat(converter.accept(setOfNumbers), is(false));
        List<Number> list = (List<Number>) converter.convertValue("3, 0.5, 6.1f, 8.00", listOfNumbers);
        NumberFormat numberFormat = NumberFormat.getInstance(ParameterConverters.DEFAULT_NUMBER_FORMAT_LOCAL);
        assertThat(list.get(0), equalTo(numberFormat.parse("3")));
        assertThat(list.get(1), equalTo(numberFormat.parse("0.5")));
        assertThat(list.get(2), equalTo(numberFormat.parse("6.1f")));
        assertThat(list.get(3), equalTo(numberFormat.parse("8.00")));
View Full Code Here

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

    public void shouldConvertCommaSeparatedValuesToListOfNumbersWithCustomFormat() throws ParseException,
            IntrospectionException {
        NumberFormat numberFormat = new DecimalFormat("#,####");
        ParameterConverter converter = new NumberListConverter(numberFormat, " ");
        Type type = SomeSteps.methodFor("aMethodWithListOfNumbers").getGenericParameterTypes()[0];
        List<Number> list = (List<Number>) converter.convertValue("3,000 0.5 6.1f 8.00", type);
        assertThat(list.get(0), equalTo(numberFormat.parse("3,000")));
        assertThat(list.get(1), equalTo(numberFormat.parse("0.5")));
        assertThat(list.get(2), equalTo(numberFormat.parse("6.1f")));
        assertThat(list.get(3), equalTo(numberFormat.parse("8.00")));
    }
View Full Code Here

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

    @Test
    public void shouldConvertCommaSeparatedValuesOfSpecificNumberTypes() throws ParseException, IntrospectionException {
        ParameterConverter converter = new NumberListConverter(NumberFormat.getInstance(Locale.ENGLISH), ",");
        Type doublesType = SomeSteps.methodFor("aMethodWithListOfDoubles").getGenericParameterTypes()[0];
       
        List<Double> doubles = (List<Double>) converter.convertValue("3, 0.5, 0.0, 8.00, "+NAN+","+INFINITY, doublesType);
        assertThat(doubles.get(0), equalTo(3.0d));
        assertThat(doubles.get(1), equalTo(0.5d));
        assertThat(doubles.get(2), equalTo(0.0d));
        assertThat(doubles.get(3), equalTo(8.00d));
        assertThat(doubles.get(4), equalTo(Double.NaN));
View Full Code Here

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

        assertThat(doubles.get(3), equalTo(8.00d));
        assertThat(doubles.get(4), equalTo(Double.NaN));
        assertThat(doubles.get(5), equalTo(Double.POSITIVE_INFINITY));
       
        Type floatsType = SomeSteps.methodFor("aMethodWithListOfFloats").getGenericParameterTypes()[0];
        List<Float> floats = (List<Float>) converter.convertValue("3, 0.5, 0.0, 8.00, "+NAN+", -"+INFINITY, floatsType);
        assertThat(floats.get(0), equalTo(3.0f));
        assertThat(floats.get(1), equalTo(0.5f));
        assertThat(floats.get(2), equalTo(0.0f));
        assertThat(floats.get(3), equalTo(8.00f));
        assertThat(floats.get(4), equalTo(Float.NaN));
View Full Code Here

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

        assertThat(floats.get(3), equalTo(8.00f));
        assertThat(floats.get(4), equalTo(Float.NaN));
        assertThat(floats.get(5), equalTo(Float.NEGATIVE_INFINITY));

        Type longsType = SomeSteps.methodFor("aMethodWithListOfLongs").getGenericParameterTypes()[0];
        List<Long> longs = (List<Long>) converter.convertValue("3, 0, 8", longsType);
        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];
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.