Search in sources :

Example 1 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 2 with BaseContact

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

the class JavaJavaMultiSourceTest method testProcessBasic.

@Test
public void testProcessBasic() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-multisource-basic.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(TargetContact.class.getName(), object.getClass().getName());
    TargetContact targetContact = (TargetContact) object;
    assertEquals("Ozzie", targetContact.getFirstName());
    assertNull(targetContact.getLastName());
    assertNull(targetContact.getPhoneNumber());
    assertEquals("90210", targetContact.getZipCode());
}
Also used : BaseContact(io.atlasmap.java.test.BaseContact) TargetContact(io.atlasmap.java.test.TargetContact) AtlasContext(io.atlasmap.api.AtlasContext) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) BaseAddress(io.atlasmap.java.test.BaseAddress) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 3 with BaseContact

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

the class JavaJavaSeparateTest method testProcessSeparateSkip.

@Test
public void testProcessSeparateSkip() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/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);
    assertEquals(TargetContact.class.getName(), object.getClass().getName());
    TargetContact targetContact = (TargetContact) object;
    AtlasTestUtil.validateContact(targetContact);
    assertFalse(session.hasErrors());
}
Also used : BaseContact(io.atlasmap.java.test.BaseContact) TargetContact(io.atlasmap.java.test.TargetContact) AtlasContext(io.atlasmap.api.AtlasContext) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 4 with BaseContact

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

the class JavaJavaSeparateTest method testProcessSeparateOutOfOrder.

@Test
public void testProcessSeparateOutOfOrder() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/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);
    assertEquals(TargetContact.class.getName(), object.getClass().getName());
    TargetContact targetContact = (TargetContact) object;
    AtlasTestUtil.validateContact(targetContact);
    assertFalse(session.hasErrors());
}
Also used : BaseContact(io.atlasmap.java.test.BaseContact) TargetContact(io.atlasmap.java.test.TargetContact) AtlasContext(io.atlasmap.api.AtlasContext) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 5 with BaseContact

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

the class JavaJsonSeparateTest method testProcessSeparateSimple.

@Test
public void testProcessSeparateSimple() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/atlasmapping-separate-simple.xml").toURI());
    AtlasSession session = context.createSession();
    BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
    sourceContact.setFirstName("Ozzie Smith");
    sourceContact.setLastName(null);
    session.setDefaultSourceDocument(sourceContact);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    AtlasJsonTestUnrootedMapper mapper = new AtlasJsonTestUnrootedMapper();
    io.atlasmap.json.test.TargetContact targetContact = mapper.readValue((String) object, io.atlasmap.json.test.TargetContact.class);
    AtlasTestUtil.validateJsonContact(targetContact);
    assertFalse(session.hasErrors());
}
Also used : BaseContact(io.atlasmap.java.test.BaseContact) AtlasContext(io.atlasmap.api.AtlasContext) AtlasJsonTestUnrootedMapper(io.atlasmap.json.test.AtlasJsonTestUnrootedMapper) File(java.io.File) 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