Search in sources :

Example 6 with TargetContact

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

the class JavaJavaCollectionTest method testProcessCollectionList.

@Test
public void testProcessCollectionList() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-collection-list.xml").toURI());
    AtlasSession session = context.createSession();
    BaseOrder sourceOrder = AtlasTestUtil.generateOrderClass(SourceOrder.class, SourceAddress.class, SourceContact.class);
    session.setDefaultSourceDocument(sourceOrder);
    context.process(session);
    assertFalse(printAudit(session), session.hasErrors());
    TargetTestClass object = (TargetTestClass) session.getDefaultTargetDocument();
    assertEquals(TargetTestClass.class.getName(), object.getClass().getName());
    assertEquals(20, object.getContactList().size());
    for (int i = 0; i < 20; i++) {
        TargetContact contact = object.getContactList().get(i);
        if (i == 4 || i == 19) {
            assertEquals("Ozzie", contact.getFirstName());
        } else {
            assertNull(contact);
        }
    }
}
Also used : BaseOrder(io.atlasmap.java.test.BaseOrder) TargetContact(io.atlasmap.java.test.TargetContact) AtlasContext(io.atlasmap.api.AtlasContext) TargetTestClass(io.atlasmap.java.test.TargetTestClass) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 7 with TargetContact

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

the class JavaJavaCollectionTest method testProcessCollectionListSimple.

@Test
public void testProcessCollectionListSimple() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-collection-list-simple.xml").toURI());
    TargetTestClass input = new TargetTestClass();
    input.setContactList(new LinkedList<>());
    for (int i = 0; i < 5; i++) {
        input.getContactList().add(new TargetContact());
        input.getContactList().get(i).setFirstName("fname" + i);
    }
    AtlasSession session = context.createSession();
    session.setSourceDocument("io.atlasmap.java.test.TargetTestClass", input);
    context.process(session);
    assertFalse(printAudit(session), session.hasErrors());
    TargetTestClass object = (TargetTestClass) session.getDefaultTargetDocument();
    assertEquals(5, object.getContactList().size());
    for (int i = 0; i < 5; i++) {
        assertEquals(input.getContactList().get(i).getFirstName(), object.getContactList().get(i).getFirstName());
    }
}
Also used : TargetContact(io.atlasmap.java.test.TargetContact) AtlasContext(io.atlasmap.api.AtlasContext) TargetTestClass(io.atlasmap.java.test.TargetTestClass) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 8 with TargetContact

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

the class JavaJavaCollectionTest method testProcessCollectionArray.

@Test
public void testProcessCollectionArray() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-collection-array.xml").toURI());
    AtlasSession session = context.createSession();
    BaseOrder sourceOrder = AtlasTestUtil.generateOrderClass(SourceOrder.class, SourceAddress.class, SourceContact.class);
    session.setDefaultSourceDocument(sourceOrder);
    context.process(session);
    assertFalse(printAudit(session), session.hasErrors());
    TargetTestClass object = (TargetTestClass) session.getDefaultTargetDocument();
    assertEquals(TargetTestClass.class.getName(), object.getClass().getName());
    assertEquals(20, object.getContactArray().length);
    for (int i = 0; i < 20; i++) {
        TargetContact contact = object.getContactArray()[i];
        if (i == 6 || i == 19) {
            assertEquals("Ozzie", contact.getFirstName());
        } else {
            assertNull(contact);
        }
    }
}
Also used : BaseOrder(io.atlasmap.java.test.BaseOrder) TargetContact(io.atlasmap.java.test.TargetContact) AtlasContext(io.atlasmap.api.AtlasContext) TargetTestClass(io.atlasmap.java.test.TargetTestClass) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 9 with TargetContact

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

the class JavaJavaCombineTest method testProcessCombineSimple.

@Test
public void testProcessCombineSimple() throws Exception {
    AtlasSession session = processCombineMapping("src/test/resources/javaToJava/atlasmapping-combine-simple.xml", AtlasTestUtil.generateContact(SourceContact.class));
    TargetContact targetContact = (TargetContact) session.getDefaultTargetDocument();
    assertEquals("Ozzie    Smith   5551212                                                                                            81111", targetContact.getFirstName());
    assertNull(targetContact.getLastName());
    assertNull(targetContact.getPhoneNumber());
    assertNull(targetContact.getZipCode());
    assertFalse(session.hasErrors());
}
Also used : TargetContact(io.atlasmap.java.test.TargetContact) SourceContact(io.atlasmap.java.test.SourceContact) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 10 with TargetContact

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

the class JsonJavaCombineTest method testProcessCombineSimple.

@Test
public void testProcessCombineSimple() throws Exception {
    AtlasSession session = processCombineMapping("src/test/resources/jsonToJava/atlasmapping-combine-simple.xml", new String(Files.readAllBytes(Paths.get("src/test/resources/jsonToJava/atlas-json-combine.json"))));
    TargetContact targetContact = (TargetContact) session.getDefaultTargetDocument();
    assertEquals("Ozzie    Smith   5551212                                                                                            81111", targetContact.getFirstName());
    assertNull(targetContact.getLastName());
    assertNull(targetContact.getPhoneNumber());
    assertNull(targetContact.getZipCode());
    assertFalse(session.hasErrors());
}
Also used : TargetContact(io.atlasmap.java.test.TargetContact) 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