Search in sources :

Example 11 with TargetOrder

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

the class JavaConstructServiceComplexTest method testConstructTargetOrderFiltered.

@Test
public void testConstructTargetOrderFiltered() throws Exception {
    JavaClass javaClass = generateOrder("Target");
    Object targetObject = constructService.constructClass(javaClass, Arrays.asList("address"));
    assertNotNull(targetObject);
    assertTrue(targetObject instanceof TargetOrder);
    TargetOrder order = (TargetOrder) targetObject;
    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());
    assertNull(order.getContact());
}
Also used : JavaClass(io.atlasmap.java.v2.JavaClass) TargetAddress(io.atlasmap.java.test.TargetAddress) TargetOrder(io.atlasmap.java.test.TargetOrder) Test(org.junit.Test)

Example 12 with TargetOrder

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

the class XmlJavaComplexTest method testProcessXmlJavaComplexOrderAutodetectAttribute.

@Test
public void testProcessXmlJavaComplexOrderAutodetectAttribute() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToJava/atlasmapping-complex-order-autodetect-attribute.xml").toURI());
    AtlasSession session = context.createSession();
    String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToJava/atlas-xml-complex-order-autodetect-attribute.xml");
    session.setDefaultSourceDocument(sourceXml);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof TargetOrder);
    AtlasTestUtil.validateOrder((TargetOrder) object);
}
Also used : AtlasContext(io.atlasmap.api.AtlasContext) TargetOrder(io.atlasmap.java.test.TargetOrder) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 13 with TargetOrder

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

the class JavaJavaComplexTest method testProcessJavaJavaComplexAutoDetectFull.

@Test
public void testProcessJavaJavaComplexAutoDetectFull() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-complex-autodetect-full.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());
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof TargetOrder);
    AtlasTestUtil.validateOrder((TargetOrder) object);
}
Also used : BaseOrder(io.atlasmap.java.test.BaseOrder) AtlasContext(io.atlasmap.api.AtlasContext) TargetOrder(io.atlasmap.java.test.TargetOrder) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 14 with TargetOrder

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

the class JavaJavaComplexTest method testProcessJavaJavaComplexWithAbstractBasic.

@Test
public void testProcessJavaJavaComplexWithAbstractBasic() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-complex-abstract.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());
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof TargetOrder);
    TargetOrder targetOrder = (TargetOrder) object;
    assertNotNull(targetOrder.getOrderId());
    assertEquals(new Integer(8765309), targetOrder.getOrderId());
    // Address should _not_ be populated
    assertNull(targetOrder.getAddress());
    // Contact should only have firstName populated
    assertNotNull(targetOrder.getContact());
    assertTrue(targetOrder.getContact() instanceof TargetContact);
    TargetContact targetContact = (TargetContact) targetOrder.getContact();
    assertNotNull(targetContact.getFirstName());
    assertEquals("Ozzie", targetContact.getFirstName());
    assertNull(targetContact.getLastName());
    assertNull(targetContact.getPhoneNumber());
    assertNull(targetContact.getZipCode());
}
Also used : BaseOrder(io.atlasmap.java.test.BaseOrder) TargetContact(io.atlasmap.java.test.TargetContact) AtlasContext(io.atlasmap.api.AtlasContext) TargetOrder(io.atlasmap.java.test.TargetOrder) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 15 with TargetOrder

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

the class JavaJavaMultiSourceTest method testProcessComplex.

@Test
public void testProcessComplex() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-multisource-complex.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(TargetOrder.class.getName(), object.getClass().getName());
    TargetOrder targetOrder = (TargetOrder) object;
    AtlasTestUtil.validateOrder(targetOrder);
}
Also used : BaseContact(io.atlasmap.java.test.BaseContact) AtlasContext(io.atlasmap.api.AtlasContext) TargetOrder(io.atlasmap.java.test.TargetOrder) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) BaseAddress(io.atlasmap.java.test.BaseAddress) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Aggregations

TargetOrder (io.atlasmap.java.test.TargetOrder)24 Test (org.junit.Test)21 AtlasContext (io.atlasmap.api.AtlasContext)11 AtlasSession (io.atlasmap.api.AtlasSession)11 AtlasMappingBaseTest (io.atlasmap.reference.AtlasMappingBaseTest)11 File (java.io.File)11 TargetAddress (io.atlasmap.java.test.TargetAddress)10 TargetContact (io.atlasmap.java.test.TargetContact)7 TargetOrderArray (io.atlasmap.java.test.TargetOrderArray)7 BaseOrder (io.atlasmap.java.test.BaseOrder)6 TargetTestClass (io.atlasmap.java.test.TargetTestClass)4 TestListOrders (io.atlasmap.java.test.TestListOrders)4 AtlasException (io.atlasmap.api.AtlasException)3 TargetFlatPrimitiveClass (io.atlasmap.java.test.TargetFlatPrimitiveClass)2 JavaClass (io.atlasmap.java.v2.JavaClass)2 JavaField (io.atlasmap.java.v2.JavaField)2 BaseAddress (io.atlasmap.java.test.BaseAddress)1 BaseContact (io.atlasmap.java.test.BaseContact)1 StateEnumClassLong (io.atlasmap.java.test.StateEnumClassLong)1 TargetParentOrder (io.atlasmap.java.test.TargetParentOrder)1