Search in sources :

Example 1 with SourceContact

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());
}
Also used : SourceContact(io.atlasmap.java.test.SourceContact) SourceContact(io.atlasmap.java.test.SourceContact) Test(org.junit.Test)

Example 2 with SourceContact

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());
    }
}
Also used : SourceAddress(io.atlasmap.java.test.SourceAddress) SourceOrderArray(io.atlasmap.java.test.SourceOrderArray) SourceOrder(io.atlasmap.java.test.SourceOrder) SourceContact(io.atlasmap.java.test.SourceContact) Test(org.junit.Test)

Example 3 with SourceContact

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());
}
Also used : SourceParentOrder(io.atlasmap.java.test.SourceParentOrder) SourceAddress(io.atlasmap.java.test.SourceAddress) JavaClass(io.atlasmap.java.v2.JavaClass) SourceOrder(io.atlasmap.java.test.SourceOrder) SourceContact(io.atlasmap.java.test.SourceContact) Test(org.junit.Test)

Example 4 with SourceContact

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());
}
Also used : SourceAddress(io.atlasmap.java.test.SourceAddress) SourceOrder(io.atlasmap.java.test.SourceOrder) SourceContact(io.atlasmap.java.test.SourceContact) Test(org.junit.Test)

Example 5 with SourceContact

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());
}
Also used : DefaultMessage(org.apache.camel.impl.DefaultMessage) ProducerTemplate(org.apache.camel.ProducerTemplate) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) HashMap(java.util.HashMap) XmlContactAttribute(io.atlasmap.xml.test.v2.XmlContactAttribute) TargetContact(io.atlasmap.java.test.TargetContact) JsonNode(com.fasterxml.jackson.databind.JsonNode) Exchange(org.apache.camel.Exchange) SourceContact(io.atlasmap.java.test.SourceContact) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Aggregations

SourceContact (io.atlasmap.java.test.SourceContact)7 Test (org.junit.Test)7 SourceAddress (io.atlasmap.java.test.SourceAddress)3 SourceOrder (io.atlasmap.java.test.SourceOrder)3 Message (org.apache.camel.Message)2 ProducerTemplate (org.apache.camel.ProducerTemplate)2 DirtiesContext (org.springframework.test.annotation.DirtiesContext)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 AtlasPath (io.atlasmap.core.AtlasPath)1 SourceOrderArray (io.atlasmap.java.test.SourceOrderArray)1 SourceParentOrder (io.atlasmap.java.test.SourceParentOrder)1 TargetContact (io.atlasmap.java.test.TargetContact)1 JavaClass (io.atlasmap.java.v2.JavaClass)1 XmlContactAttribute (io.atlasmap.xml.test.v2.XmlContactAttribute)1 HashMap (java.util.HashMap)1 Exchange (org.apache.camel.Exchange)1 DefaultMessage (org.apache.camel.impl.DefaultMessage)1 Diff (org.xmlunit.diff.Diff)1