Examples of coerce()


Examples of org.apache.tapestry.ioc.services.TypeCoercer.coerce()

    @Test
    public void string_to_select_model_type_coercion_integration()
    {
        TypeCoercer coercer = getService(TypeCoercer.class);

        SelectModel selectModel = coercer.coerce(" UK , USA , DE=Germany ", SelectModel.class);

        assertNull(selectModel.getOptionGroups());
        assertEquals(selectModel.getOptions().size(), 3);

        // Waste of effort to re-test each individual option model.
View Full Code Here

Examples of org.apache.tapestry.ioc.services.TypeCoercer.coerce()

    @Test
    public void string_to_select_model_type_coercion_integration()
    {
        TypeCoercer coercer = getService(TypeCoercer.class);

        SelectModel selectModel = coercer.coerce(" UK , USA , DE=Germany ", SelectModel.class);

        assertNull(selectModel.getOptionGroups());
        assertEquals(selectModel.getOptions().size(), 3);

        // Waste of effort to re-test each individual option model.
View Full Code Here

Examples of org.apache.tapestry.ioc.services.TypeCoercer.coerce()

    {
        TypeCoercer coercer = getObject(TypeCoercer.class, null);

        String input = "\\s+";

        Pattern pattern = coercer.coerce(input, Pattern.class);

        assertEquals(pattern.toString(), input);
    }

}
View Full Code Here

Examples of org.apache.tapestry.ioc.services.TypeCoercer.coerce()

    @Test
    public void string_to_select_model_type_coercion_integration()
    {
        TypeCoercer coercer = getService(TypeCoercer.class);

        SelectModel selectModel = coercer.coerce(" UK , USA , DE=Germany ", SelectModel.class);

        assertNull(selectModel.getOptionGroups());
        assertEquals(selectModel.getOptions().size(), 3);

        // Waste of effort to re-test each individual option model.
View Full Code Here

Examples of org.apache.tapestry5.ioc.services.Coercion.coerce()

            Coercion c = getCoercion(sourceType);

            try
            {
                return type.cast(c.coerce(input));
            } catch (Exception ex)
            {
                throw new RuntimeException(ServiceMessages.failedCoercion(input, type, c, ex), ex);
            }
        }
View Full Code Here

Examples of org.apache.tapestry5.ioc.services.Coercion.coerce()

        assertSame(coercer.coerce(input, Number.class), input);

        Coercion coercion = coercer.getCoercion(int.class, Number.class);

        assertSame(coercion.coerce(input), input);
    }

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

Examples of org.apache.tapestry5.ioc.services.Coercion.coerce()

        assertEquals(actual, expected);

        Coercion c = coercer.getCoercion(input == null ? void.class : input.getClass(), targetType);

        assertEquals(c.coerce(input), expected);
    }

    @SuppressWarnings("unchecked")
    @DataProvider
    public Object[][] coercions_inputs()
View Full Code Here

Examples of org.apache.tapestry5.ioc.services.Coercion.coerce()

            Coercion c = getCoercion(sourceType);

            try
            {
                return type.cast(c.coerce(input));
            } catch (Exception ex)
            {
                throw new RuntimeException(ServiceMessages.failedCoercion(input, type, c, ex), ex);
            }
        }
View Full Code Here

Examples of org.apache.tapestry5.ioc.services.Coercion.coerce()

        assertSame(coercer.coerce(input, Number.class), input);

        Coercion coercion = coercer.getCoercion(int.class, Number.class);

        assertSame(coercion.coerce(input), input);
    }

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

Examples of org.apache.tapestry5.ioc.services.Coercion.coerce()

        assertEquals(actual, expected);

        Coercion c = coercer.getCoercion(input == null ? void.class : input.getClass(), targetType);

        assertEquals(c.coerce(input), expected);
    }

    @SuppressWarnings("unchecked")
    @DataProvider
    public Object[][] coercions_inputs()
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.