Search in sources :

Example 1 with TargetTestClass

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

the class DocumentJavaFieldWriterTest method testSimpleClassLookup.

@Test
public void testSimpleClassLookup() throws Exception {
    addClassForFieldPath("/", TargetTestClass.class);
    addClassForFieldPath("/address", TargetAddress.class);
    write("/address/addressLine1", "123 any street");
    TargetTestClass o = (TargetTestClass) writer.getRootObject();
    ensureNotNullAndClass(o, TargetTestClass.class);
    ensureNotNullAndClass(o.getAddress(), TargetAddress.class);
    assertEquals("123 any street", o.getAddress().getAddressLine1());
}
Also used : TargetTestClass(io.atlasmap.java.test.TargetTestClass) Test(org.junit.Test)

Example 2 with TargetTestClass

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

the class DocumentJavaFieldWriterTest method testClassLookupReflection.

@Test
public void testClassLookupReflection() throws Exception {
    addClassForFieldPath("/", TargetTestClass.class);
    write("/address/addressLine1", "123 any street");
    TargetTestClass o = (TargetTestClass) writer.getRootObject();
    ensureNotNullAndClass(o, TargetTestClass.class);
    ensureNotNullAndClass(o.getAddress(), TargetAddress.class);
    assertEquals("123 any street", o.getAddress().getAddressLine1());
}
Also used : TargetTestClass(io.atlasmap.java.test.TargetTestClass) Test(org.junit.Test)

Example 3 with TargetTestClass

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

the class JavaJavaComplexTest method testProcessComplexBasicNullContact.

@Test
public void testProcessComplexBasicNullContact() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-complex-simple.xml").toURI());
    AtlasSession session = context.createSession();
    BaseOrder sourceOrder = AtlasTestUtil.generateOrderClass(SourceOrder.class, SourceAddress.class, SourceContact.class);
    sourceOrder.setContact(null);
    session.setDefaultSourceDocument(sourceOrder);
    context.process(session);
    assertFalse(printAudit(session), session.hasErrors());
    TargetTestClass object = (TargetTestClass) session.getDefaultTargetDocument();
    assertEquals(TargetTestClass.class.getName(), object.getClass().getName());
    assertEquals(TargetContact.class.getName(), object.getContact().getClass().getName());
    assertNull(object.getContact().getFirstName());
}
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 4 with TargetTestClass

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

the class JavaJavaComplexTest method testProcessComplexBasic.

@Test
public void testProcessComplexBasic() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-complex-simple.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(TargetContact.class.getName(), object.getContact().getClass().getName());
    assertEquals("Ozzie", object.getContact().getFirstName());
}
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 5 with TargetTestClass

use of io.atlasmap.java.test.TargetTestClass 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)

Aggregations

TargetTestClass (io.atlasmap.java.test.TargetTestClass)46 Test (org.junit.jupiter.api.Test)28 AtlasContext (io.atlasmap.api.AtlasContext)26 AtlasSession (io.atlasmap.api.AtlasSession)26 TargetContact (io.atlasmap.java.test.TargetContact)24 File (java.io.File)24 BaseOrder (io.atlasmap.java.test.BaseOrder)15 Test (org.junit.Test)14 AtlasMappingBaseTest (io.atlasmap.itests.reference.AtlasMappingBaseTest)13 AtlasMappingBaseTest (io.atlasmap.reference.AtlasMappingBaseTest)11 TargetAddress (io.atlasmap.java.test.TargetAddress)10 TargetOrder (io.atlasmap.java.test.TargetOrder)7 TargetOrderArray (io.atlasmap.java.test.TargetOrderArray)5 JavaField (io.atlasmap.java.v2.JavaField)5 Field (io.atlasmap.v2.Field)5 TestListOrders (io.atlasmap.java.test.TestListOrders)4 AtlasJsonTestUnrootedMapper (io.atlasmap.json.test.AtlasJsonTestUnrootedMapper)4 AtlasException (io.atlasmap.api.AtlasException)3 TargetFlatPrimitiveClass (io.atlasmap.java.test.TargetFlatPrimitiveClass)3 FieldGroup (io.atlasmap.v2.FieldGroup)2