use of io.atlasmap.java.test.SourceContact in project atlasmap by atlasmap.
the class JavaConstructServiceSimpleTest method testConstructSourceContact.
@Test
public void testConstructSourceContact() throws Exception {
Object targetObject = constructService.constructClass(generateJavaClass("io.atlasmap.java.test.SourceContact"), null);
assertNotNull(targetObject);
assertTrue(targetObject instanceof io.atlasmap.java.test.SourceContact);
SourceContact source = (SourceContact) targetObject;
assertNull(source.getFirstName());
assertNull(source.getLastName());
assertNull(source.getPhoneNumber());
assertNull(source.getZipCode());
}
use of io.atlasmap.java.test.SourceContact in project atlasmap by atlasmap.
the class JavaConstructServiceComplexArrayTest method testConstructSourceOrderArray.
@Test
public void testConstructSourceOrderArray() throws Exception {
Object targetObject = constructService.constructClass(generateOrderArray("Source"), null);
assertNotNull(targetObject);
assertTrue(targetObject instanceof SourceOrderArray);
SourceOrderArray orderArray = (SourceOrderArray) targetObject;
assertNotNull(orderArray.getOrders());
assertTrue(orderArray.getOrders().length > 0);
for (int i = 0; i < orderArray.getOrders().length; i++) {
SourceOrder order = (SourceOrder) orderArray.getOrders()[i];
assertNotNull(order.getAddress());
assertTrue(order.getAddress() instanceof SourceAddress);
SourceAddress address = (SourceAddress) order.getAddress();
assertNull(address.getAddressLine1());
assertNull(address.getAddressLine2());
assertNull(address.getCity());
assertNull(address.getState());
assertNull(address.getZipCode());
assertNotNull(order.getContact());
assertTrue(order.getContact() instanceof SourceContact);
SourceContact contact = (SourceContact) order.getContact();
assertNull(contact.getFirstName());
assertNull(contact.getLastName());
assertNull(contact.getPhoneNumber());
assertNull(contact.getZipCode());
}
}
use of io.atlasmap.java.test.SourceContact in project atlasmap by atlasmap.
the class JavaConstructServiceComplexTest method testConstructSourceParentOrder.
@Test
public void testConstructSourceParentOrder() throws Exception {
JavaClass javaClass = generateParentOrder("Source");
Object targetObject = constructService.constructClass(javaClass, null);
assertNotNull(targetObject);
assertTrue(targetObject instanceof SourceParentOrder);
SourceParentOrder parentOrder = (SourceParentOrder) targetObject;
assertNotNull(parentOrder.getOrder());
SourceOrder order = (SourceOrder) parentOrder.getOrder();
assertNotNull(order.getAddress());
assertTrue(order.getAddress() instanceof SourceAddress);
SourceAddress address = (SourceAddress) order.getAddress();
assertNull(address.getAddressLine1());
assertNull(address.getAddressLine2());
assertNull(address.getCity());
assertNull(address.getState());
assertNull(address.getZipCode());
assertNotNull(order.getContact());
assertTrue(order.getContact() instanceof SourceContact);
SourceContact contact = (SourceContact) order.getContact();
assertNull(contact.getFirstName());
assertNull(contact.getLastName());
assertNull(contact.getPhoneNumber());
assertNull(contact.getZipCode());
}
use of io.atlasmap.java.test.SourceContact in project atlasmap by atlasmap.
the class JavaConstructServiceComplexTest method testConstructSourceOrder.
@Test
public void testConstructSourceOrder() throws Exception {
Object targetObject = constructService.constructClass(generateOrder("Source"), null);
assertNotNull(targetObject);
assertTrue(targetObject instanceof SourceOrder);
SourceOrder order = (SourceOrder) targetObject;
assertNotNull(order.getAddress());
assertTrue(order.getAddress() instanceof SourceAddress);
SourceAddress address = (SourceAddress) order.getAddress();
assertNull(address.getAddressLine1());
assertNull(address.getAddressLine2());
assertNull(address.getCity());
assertNull(address.getState());
assertNull(address.getZipCode());
assertNotNull(order.getContact());
assertTrue(order.getContact() instanceof SourceContact);
SourceContact contact = (SourceContact) order.getContact();
assertNull(contact.getFirstName());
assertNull(contact.getLastName());
assertNull(contact.getPhoneNumber());
assertNull(contact.getZipCode());
}
use of io.atlasmap.java.test.SourceContact in project atlasmap by atlasmap.
the class AtlasMapMultiDocsTest method test.
@Test
@DirtiesContext
public void test() throws Exception {
result.setExpectedCount(1);
Map<String, Message> sourceMap = new HashMap<>();
SourceContact javaSource = new SourceContact();
javaSource.setFirstName("JavaFirstName");
javaSource.setLastName("JavaLastName");
javaSource.setPhoneNumber("JavaPhoneNumber");
javaSource.setZipCode("JavaZipCode");
Message msg = new DefaultMessage(camelContext);
msg.setBody(javaSource);
sourceMap.put("DOCID:JAVA:CONTACT:S", msg);
msg = new DefaultMessage(camelContext);
msg.setBody(JSON_SOURCE);
sourceMap.put("DOCID:JSON:CONTACT:S", msg);
msg = new DefaultMessage(camelContext);
msg.setBody(XML_SOURCE);
sourceMap.put("DOCID:XML:CONTACT:S", msg);
ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
producerTemplate.sendBodyAndProperty("direct:start", null, "CAPTURED_OUT_MESSAGES_MAP", sourceMap);
MockEndpoint.assertIsSatisfied(camelContext);
Exchange exchange = result.getExchanges().get(0);
Map<?, ?> targetMap = exchange.getProperty(AtlasConstants.ATLAS_TARGET_MAP, Map.class);
TargetContact javaTarget = (TargetContact) targetMap.get("DOCID:JAVA:CONTACT:T");
assertEquals("JavaFirstName", javaTarget.getFirstName());
assertEquals("XmlLastName", javaTarget.getLastName());
assertEquals("JsonPhoneNumber", javaTarget.getPhoneNumber());
String jsonTarget = (String) targetMap.get("DOCID:JSON:CONTACT:T");
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonTargetNode = mapper.readTree(jsonTarget);
assertEquals("JsonFirstName", jsonTargetNode.get("firstName").asText());
assertEquals("JavaLastName", jsonTargetNode.get("lastName").asText());
assertEquals("XmlPhoneNumber", jsonTargetNode.get("phoneNumber").asText());
String xmlTarget = (String) targetMap.get("DOCID:XML:CONTACT:T");
JAXBElement<XmlContactAttribute> xmlTargetJaxb = AtlasXmlTestHelper.unmarshal(xmlTarget, XmlContactAttribute.class);
XmlContactAttribute xmlTargetObj = xmlTargetJaxb.getValue();
assertEquals("XmlFirstName", xmlTargetObj.getFirstName());
assertEquals("JsonLastName", xmlTargetObj.getLastName());
assertEquals("JavaPhoneNumber", xmlTargetObj.getPhoneNumber());
}
Aggregations