Search in sources :

Example 1 with CustomerA

use of org.wildfly.camel.test.dozer.subA.CustomerA in project wildfly-camel by wildfly-extras.

the class DozerIntegrationTest method testBeanMapping.

@Test
public void testBeanMapping() throws Exception {
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").convertBodyTo(CustomerB.class);
        }
    });
    DozerBeanMapperConfiguration mconfig = new DozerBeanMapperConfiguration();
    mconfig.setMappingFiles(Arrays.asList(new String[] { DOZER_MAPPINGS_XML }));
    new DozerTypeConverterLoader(camelctx, mconfig);
    CustomerA customerA = new CustomerA("Peter", "Post", "Street", "12345");
    camelctx.start();
    try {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        CustomerB result = producer.requestBody("direct:start", customerA, CustomerB.class);
        Assert.assertEquals(customerA.getFirstName(), result.getFirstName());
        Assert.assertEquals(customerA.getLastName(), result.getLastName());
        Assert.assertEquals(customerA.getStreet(), result.getAddress().getStreet());
        Assert.assertEquals(customerA.getZip(), result.getAddress().getZip());
    } finally {
        camelctx.stop();
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) DozerBeanMapperConfiguration(org.apache.camel.converter.dozer.DozerBeanMapperConfiguration) ProducerTemplate(org.apache.camel.ProducerTemplate) CustomerA(org.wildfly.camel.test.dozer.subA.CustomerA) RouteBuilder(org.apache.camel.builder.RouteBuilder) CustomerB(org.wildfly.camel.test.dozer.subA.CustomerB) DozerTypeConverterLoader(org.apache.camel.converter.dozer.DozerTypeConverterLoader) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Aggregations

CamelContext (org.apache.camel.CamelContext)1 ProducerTemplate (org.apache.camel.ProducerTemplate)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 DozerBeanMapperConfiguration (org.apache.camel.converter.dozer.DozerBeanMapperConfiguration)1 DozerTypeConverterLoader (org.apache.camel.converter.dozer.DozerTypeConverterLoader)1 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)1 Test (org.junit.Test)1 CustomerA (org.wildfly.camel.test.dozer.subA.CustomerA)1 CustomerB (org.wildfly.camel.test.dozer.subA.CustomerB)1