use of org.apache.camel.converter.dozer.model.CustomerA in project camel by apache.
the class DozerBeanMappingTest method testBeanMapping.
@Test
public void testBeanMapping() throws Exception {
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").convertBodyTo(CustomerB.class);
}
});
DozerBeanMapperConfiguration mconfig = new DozerBeanMapperConfiguration();
mconfig.setMappingFiles(Arrays.asList("bean-to-bean-dozer-mappings.xml"));
new DozerTypeConverterLoader(context, mconfig);
CustomerA customerA = new CustomerA("Peter", "Post", "SomeStreet", "12345");
context.start();
try {
ProducerTemplate producer = context.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 {
context.stop();
}
}
Aggregations