Search in sources :

Example 1 with TargetContact

use of io.atlasmap.java.test.TargetContact in project atlasmap by atlasmap.

the class JavaConstructServiceComplexArrayTest method testConstructTargetOrderArray.

@Test
public void testConstructTargetOrderArray() throws Exception {
    Object targetObject = constructService.constructClass(generateOrderArray("Target"), null);
    assertNotNull(targetObject);
    assertTrue(targetObject instanceof TargetOrderArray);
    TargetOrderArray orderArray = (TargetOrderArray) targetObject;
    for (int i = 0; i < orderArray.getOrders().length; i++) {
        TargetOrder order = (TargetOrder) orderArray.getOrders()[i];
        assertNotNull(order);
        assertNotNull(order.getAddress());
        assertTrue(order.getAddress() instanceof TargetAddress);
        TargetAddress address = (TargetAddress) order.getAddress();
        assertNull(address.getAddressLine1());
        assertNull(address.getAddressLine2());
        assertNull(address.getCity());
        assertNull(address.getState());
        assertNull(address.getZipCode());
        assertNotNull(order.getContact());
        assertTrue(order.getContact() instanceof TargetContact);
        TargetContact contact = (TargetContact) order.getContact();
        assertNull(contact.getFirstName());
        assertNull(contact.getLastName());
        assertNull(contact.getPhoneNumber());
        assertNull(contact.getZipCode());
    }
}
Also used : TargetContact(io.atlasmap.java.test.TargetContact) TargetAddress(io.atlasmap.java.test.TargetAddress) TargetOrder(io.atlasmap.java.test.TargetOrder) TargetOrderArray(io.atlasmap.java.test.TargetOrderArray) Test(org.junit.Test)

Example 2 with TargetContact

use of io.atlasmap.java.test.TargetContact in project atlasmap by atlasmap.

the class JavaJavaMultiSourceTest method testProcessBasic.

@Test
public void testProcessBasic() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-multisource-basic.xml").toURI());
    AtlasSession session = context.createSession();
    BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
    BaseAddress sourceAddress = AtlasTestUtil.generateAddress(SourceAddress.class);
    session.setSourceDocument("con", sourceContact);
    session.setSourceDocument("addr", sourceAddress);
    context.process(session);
    assertFalse(printAudit(session), session.hasErrors());
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertEquals(TargetContact.class.getName(), object.getClass().getName());
    TargetContact targetContact = (TargetContact) object;
    assertEquals("Ozzie", targetContact.getFirstName());
    assertNull(targetContact.getLastName());
    assertNull(targetContact.getPhoneNumber());
    assertEquals("90210", targetContact.getZipCode());
}
Also used : BaseContact(io.atlasmap.java.test.BaseContact) TargetContact(io.atlasmap.java.test.TargetContact) AtlasContext(io.atlasmap.api.AtlasContext) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) BaseAddress(io.atlasmap.java.test.BaseAddress) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 3 with TargetContact

use of io.atlasmap.java.test.TargetContact in project atlasmap by atlasmap.

the class JavaJavaSeparateTest method testProcessSeparateSkip.

@Test
public void testProcessSeparateSkip() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-separate-skip.xml").toURI());
    AtlasSession session = context.createSession();
    BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
    sourceContact.setFirstName("Dr. Mr. Ozzie L. Smith Jr.");
    sourceContact.setLastName(null);
    session.setDefaultSourceDocument(sourceContact);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertEquals(TargetContact.class.getName(), object.getClass().getName());
    TargetContact targetContact = (TargetContact) object;
    AtlasTestUtil.validateContact(targetContact);
    assertFalse(session.hasErrors());
}
Also used : BaseContact(io.atlasmap.java.test.BaseContact) TargetContact(io.atlasmap.java.test.TargetContact) AtlasContext(io.atlasmap.api.AtlasContext) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 4 with TargetContact

use of io.atlasmap.java.test.TargetContact in project atlasmap by atlasmap.

the class JavaJavaSeparateTest method testProcessSeparateOutOfOrder.

@Test
public void testProcessSeparateOutOfOrder() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-separate-outoforder.xml").toURI());
    AtlasSession session = context.createSession();
    BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
    sourceContact.setFirstName("Dr. Mr. Ozzie L. Smith Jr.");
    sourceContact.setLastName(null);
    session.setDefaultSourceDocument(sourceContact);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertEquals(TargetContact.class.getName(), object.getClass().getName());
    TargetContact targetContact = (TargetContact) object;
    AtlasTestUtil.validateContact(targetContact);
    assertFalse(session.hasErrors());
}
Also used : BaseContact(io.atlasmap.java.test.BaseContact) TargetContact(io.atlasmap.java.test.TargetContact) AtlasContext(io.atlasmap.api.AtlasContext) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 5 with TargetContact

use of io.atlasmap.java.test.TargetContact in project atlasmap by atlasmap.

the class JavaJavaSeparateTest method testProcessSeparateNotEnoughSource.

@Test
public void testProcessSeparateNotEnoughSource() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-separate-inputshort.xml").toURI());
    AtlasSession session = context.createSession();
    BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
    sourceContact.setFirstName("Dr. Mr. Ozzie");
    sourceContact.setLastName(null);
    session.setDefaultSourceDocument(sourceContact);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertEquals(TargetContact.class.getName(), object.getClass().getName());
    TargetContact targetContact = (TargetContact) object;
    assertNotNull(targetContact);
    assertEquals("Ozzie", targetContact.getFirstName());
    assertEquals(null, targetContact.getLastName());
    assertTrue(session.hasWarns());
    assertEquals("Separate returned fewer segments count=3 when targetField.path=/lastName requested index=3", session.getAudits().getAudit().get(0).getMessage());
}
Also used : BaseContact(io.atlasmap.java.test.BaseContact) TargetContact(io.atlasmap.java.test.TargetContact) AtlasContext(io.atlasmap.api.AtlasContext) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Aggregations

TargetContact (io.atlasmap.java.test.TargetContact)32 Test (org.junit.Test)30 AtlasSession (io.atlasmap.api.AtlasSession)25 AtlasMappingBaseTest (io.atlasmap.reference.AtlasMappingBaseTest)25 AtlasContext (io.atlasmap.api.AtlasContext)13 File (java.io.File)13 TargetTestClass (io.atlasmap.java.test.TargetTestClass)8 BaseContact (io.atlasmap.java.test.BaseContact)7 TargetOrder (io.atlasmap.java.test.TargetOrder)7 TargetAddress (io.atlasmap.java.test.TargetAddress)6 BaseOrder (io.atlasmap.java.test.BaseOrder)4 SourceContact (io.atlasmap.java.test.SourceContact)4 TargetOrderArray (io.atlasmap.java.test.TargetOrderArray)3 AtlasException (io.atlasmap.api.AtlasException)2 TestListOrders (io.atlasmap.java.test.TestListOrders)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 BaseAddress (io.atlasmap.java.test.BaseAddress)1 StateEnumClassLong (io.atlasmap.java.test.StateEnumClassLong)1 TargetFlatPrimitiveClass (io.atlasmap.java.test.TargetFlatPrimitiveClass)1