Search in sources :

Example 41 with TargetTestClass

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

the class MultiplicityTransformationTest method testConcatenateTypes.

@Test
public void testConcatenateTypes() throws Exception {
    URL url = Thread.currentThread().getContextClassLoader().getResource("mappings/atlasmapping-multiplicity-transformation-concatenate-types.json");
    AtlasContext context = DefaultAtlasContextFactory.getInstance().createContext(url.toURI());
    AtlasSession session = context.createSession();
    TargetTestClass source = new TargetTestClass();
    source.setCreated(new java.util.Date());
    TargetFlatPrimitiveClass primitives = new TargetFlatPrimitiveClass();
    primitives.setBoxedStringField("boxedString");
    primitives.setCharField('c');
    primitives.setIntField(1);
    primitives.setFloatField(1.3f);
    primitives.setLongField(2L);
    primitives.setShortField((short) 2);
    primitives.setDoubleField(3.1d);
    primitives.setBoxedCharField(Character.valueOf('c'));
    primitives.setBoxedIntField(Integer.valueOf(1));
    primitives.setBoxedFloatField(Float.valueOf(1.3f));
    primitives.setBoxedLongField(Long.valueOf(2L));
    primitives.setBoxedShortField(Short.valueOf((short) 2));
    primitives.setBoxedDoubleField(Double.valueOf(3.1d));
    source.setPrimitives(primitives);
    session.setSourceDocument("io.atlasmap.java.test.TargetTestClass", source);
    context.process(session);
    assertFalse(session.hasErrors(), TestHelper.printAudit(session));
    Object output = session.getTargetDocument("io.atlasmap.java.test.TargetTestClass");
    assertEquals(TargetTestClass.class, output.getClass());
    TargetTestClass target = TargetTestClass.class.cast(output);
    assertEquals(14, target.getFullAddress().split(" ").length, "[" + target.getFullAddress() + "]");
}
Also used : TargetFlatPrimitiveClass(io.atlasmap.java.test.TargetFlatPrimitiveClass) AtlasContext(io.atlasmap.api.AtlasContext) TargetTestClass(io.atlasmap.java.test.TargetTestClass) AtlasSession(io.atlasmap.api.AtlasSession) URL(java.net.URL) Test(org.junit.jupiter.api.Test)

Example 42 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.json").toURI());
    AtlasSession session = context.createSession();
    BaseOrder sourceOrder = AtlasTestUtil.generateOrderClass(SourceOrder.class, SourceAddress.class, SourceContact.class);
    session.setDefaultSourceDocument(sourceOrder);
    context.process(session);
    assertFalse(session.hasErrors(), printAudit(session));
    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) AtlasMappingBaseTest(io.atlasmap.itests.reference.AtlasMappingBaseTest) Test(org.junit.jupiter.api.Test)

Example 43 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.json").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(session.hasErrors(), printAudit(session));
    TargetTestClass object = (TargetTestClass) session.getDefaultTargetDocument();
    assertEquals(TargetTestClass.class.getName(), object.getClass().getName());
    // Lazy instantiation will not istantiate target class if source class is null (Java to Java)
    assertNull(object.getContact());
}
Also used : BaseOrder(io.atlasmap.java.test.BaseOrder) AtlasContext(io.atlasmap.api.AtlasContext) TargetTestClass(io.atlasmap.java.test.TargetTestClass) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) AtlasMappingBaseTest(io.atlasmap.itests.reference.AtlasMappingBaseTest) Test(org.junit.jupiter.api.Test)

Example 44 with TargetTestClass

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

the class JavaJavaCollectionTest method testProcessCollectionListEmpty.

@Test
public void testProcessCollectionListEmpty() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-collection-list-empty.json").toURI());
    AtlasSession session = context.createSession();
    TargetTestClass source = new TargetTestClass();
    session.setDefaultSourceDocument(source);
    context.process(session);
    assertFalse(session.hasErrors(), printAudit(session));
    TargetTestClass object = (TargetTestClass) session.getDefaultTargetDocument();
    assertEquals(TargetTestClass.class.getName(), object.getClass().getName());
    assertEquals(0, object.getContactList().size());
}
Also used : AtlasContext(io.atlasmap.api.AtlasContext) TargetTestClass(io.atlasmap.java.test.TargetTestClass) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) AtlasMappingBaseTest(io.atlasmap.itests.reference.AtlasMappingBaseTest) Test(org.junit.jupiter.api.Test)

Example 45 with TargetTestClass

use of io.atlasmap.java.test.TargetTestClass 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.json").toURI());
    AtlasSession session = context.createSession();
    BaseOrder sourceOrder = AtlasTestUtil.generateOrderClass(SourceOrder.class, SourceAddress.class, SourceContact.class);
    session.setDefaultSourceDocument(sourceOrder);
    context.process(session);
    assertFalse(session.hasErrors(), printAudit(session));
    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) AtlasMappingBaseTest(io.atlasmap.itests.reference.AtlasMappingBaseTest) Test(org.junit.jupiter.api.Test)

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