Search in sources :

Example 11 with BaseContact

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

the class JavaXmlCombineTest method testProcessCombineOutOfOrder.

@Test
public void testProcessCombineOutOfOrder() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToXml/atlasmapping-combine-outoforder.xml").toURI());
    AtlasSession session = context.createSession();
    BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
    session.setDefaultSourceDocument(sourceContact);
    context.process(session);
    assertFalse(printAudit(session), session.hasErrors());
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    JAXBElement<XmlContactAttribute> targetContact = AtlasXmlTestHelper.unmarshal((String) object, XmlContactAttribute.class);
    assertEquals("Ozzie Smith 5551212 81111", targetContact.getValue().getFirstName());
    assertNull(targetContact.getValue().getLastName());
    assertNull(targetContact.getValue().getPhoneNumber());
    assertNull(targetContact.getValue().getZipCode());
    assertFalse(session.hasErrors());
}
Also used : BaseContact(io.atlasmap.java.test.BaseContact) XmlContactAttribute(io.atlasmap.xml.test.v2.XmlContactAttribute) AtlasContext(io.atlasmap.api.AtlasContext) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 12 with BaseContact

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

the class JavaXmlSeparateTest method testProcessSeparateSkip.

@Test
public void testProcessSeparateSkip() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToXml/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);
    assertTrue(object instanceof String);
    JAXBElement<XmlContactAttribute> targetContact = AtlasXmlTestHelper.unmarshal((String) object, XmlContactAttribute.class);
    AtlasTestUtil.validateXmlContactAttribute(targetContact.getValue());
    assertFalse(session.hasErrors());
}
Also used : BaseContact(io.atlasmap.java.test.BaseContact) XmlContactAttribute(io.atlasmap.xml.test.v2.XmlContactAttribute) AtlasContext(io.atlasmap.api.AtlasContext) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 13 with BaseContact

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

the class JavaXmlSeparateTest method testProcessSeparateOutOfOrder.

@Test
public void testProcessSeparateOutOfOrder() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToXml/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);
    assertTrue(object instanceof String);
    JAXBElement<XmlContactAttribute> targetContact = AtlasXmlTestHelper.unmarshal((String) object, XmlContactAttribute.class);
    AtlasTestUtil.validateXmlContactAttribute(targetContact.getValue());
    assertFalse(session.hasErrors());
}
Also used : BaseContact(io.atlasmap.java.test.BaseContact) XmlContactAttribute(io.atlasmap.xml.test.v2.XmlContactAttribute) AtlasContext(io.atlasmap.api.AtlasContext) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 14 with BaseContact

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

the class AtlasTestUtil method generateContact.

public static BaseContact generateContact(Class<? extends BaseContact> contactClass) throws Exception {
    Class<?> targetClazz = AtlasTestUtil.class.getClassLoader().loadClass(contactClass.getName());
    BaseContact newObject = (BaseContact) targetClazz.newInstance();
    newObject.setFirstName("Ozzie");
    newObject.setLastName("Smith");
    newObject.setPhoneNumber("5551212");
    newObject.setZipCode("81111");
    return newObject;
}
Also used : BaseContact(io.atlasmap.java.test.BaseContact)

Example 15 with BaseContact

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

the class JavaJavaCombineTest method testProcessCombineNullInput.

@Test
public void testProcessCombineNullInput() throws Exception {
    BaseContact source = AtlasTestUtil.generateContact(SourceContact.class);
    source.setLastName(null);
    AtlasSession session = processCombineMapping("src/test/resources/javaToJava/atlasmapping-combine-inputnull.xml", source);
    TargetContact targetContact = (TargetContact) session.getDefaultTargetDocument();
    assertNotNull(targetContact);
    assertEquals("Ozzie  5551212 81111", targetContact.getFirstName());
    assertFalse(session.hasErrors());
}
Also used : BaseContact(io.atlasmap.java.test.BaseContact) TargetContact(io.atlasmap.java.test.TargetContact) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Aggregations

BaseContact (io.atlasmap.java.test.BaseContact)28 AtlasSession (io.atlasmap.api.AtlasSession)26 AtlasMappingBaseTest (io.atlasmap.reference.AtlasMappingBaseTest)26 Test (org.junit.Test)26 AtlasContext (io.atlasmap.api.AtlasContext)25 File (java.io.File)25 AtlasJsonTestUnrootedMapper (io.atlasmap.json.test.AtlasJsonTestUnrootedMapper)9 XmlContactAttribute (io.atlasmap.xml.test.v2.XmlContactAttribute)9 TargetContact (io.atlasmap.java.test.TargetContact)7 BaseAddress (io.atlasmap.java.test.BaseAddress)2 TargetOrder (io.atlasmap.java.test.TargetOrder)1