Search in sources :

Example 41 with AtlasSession

use of io.atlasmap.api.AtlasSession 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 42 with AtlasSession

use of io.atlasmap.api.AtlasSession 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 43 with AtlasSession

use of io.atlasmap.api.AtlasSession 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 44 with AtlasSession

use of io.atlasmap.api.AtlasSession in project atlasmap by atlasmap.

the class JsonJavaCombineTest method testProcessCombineSimple.

@Test
public void testProcessCombineSimple() throws Exception {
    AtlasSession session = processCombineMapping("src/test/resources/jsonToJava/atlasmapping-combine-simple.xml", new String(Files.readAllBytes(Paths.get("src/test/resources/jsonToJava/atlas-json-combine.json"))));
    TargetContact targetContact = (TargetContact) session.getDefaultTargetDocument();
    assertEquals("Ozzie    Smith   5551212                                                                                            81111", targetContact.getFirstName());
    assertNull(targetContact.getLastName());
    assertNull(targetContact.getPhoneNumber());
    assertNull(targetContact.getZipCode());
    assertFalse(session.hasErrors());
}
Also used : TargetContact(io.atlasmap.java.test.TargetContact) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 45 with AtlasSession

use of io.atlasmap.api.AtlasSession in project atlasmap by atlasmap.

the class JsonJavaCombineTest method testProcessCombineSkip.

@Test
public void testProcessCombineSkip() throws Exception {
    AtlasSession session = processCombineMapping("src/test/resources/jsonToJava/atlasmapping-combine-skip.xml", new String(Files.readAllBytes(Paths.get("src/test/resources/jsonToJava/atlas-json-combine.json"))));
    TargetContact targetContact = (TargetContact) session.getDefaultTargetDocument();
    assertEquals("Ozzie Smith 5551212 81111", targetContact.getFirstName());
    assertNull(targetContact.getLastName());
    assertNull(targetContact.getPhoneNumber());
    assertNull(targetContact.getZipCode());
    assertFalse(session.hasErrors());
}
Also used : TargetContact(io.atlasmap.java.test.TargetContact) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Aggregations

AtlasSession (io.atlasmap.api.AtlasSession)157 AtlasContext (io.atlasmap.api.AtlasContext)140 Test (org.junit.Test)134 File (java.io.File)129 AtlasMappingBaseTest (io.atlasmap.reference.AtlasMappingBaseTest)123 TargetContact (io.atlasmap.java.test.TargetContact)31 BaseContact (io.atlasmap.java.test.BaseContact)26 AtlasJsonTestUnrootedMapper (io.atlasmap.json.test.AtlasJsonTestUnrootedMapper)25 TargetFlatPrimitiveClass (io.atlasmap.java.test.TargetFlatPrimitiveClass)24 TargetFlatPrimitive (io.atlasmap.json.test.TargetFlatPrimitive)13 BaseOrder (io.atlasmap.java.test.BaseOrder)12 TargetOrder (io.atlasmap.java.test.TargetOrder)11 TargetTestClass (io.atlasmap.java.test.TargetTestClass)11 AtlasMapping (io.atlasmap.v2.AtlasMapping)9 XmlContactAttribute (io.atlasmap.xml.test.v2.XmlContactAttribute)9 AtlasJsonTestRootedMapper (io.atlasmap.json.test.AtlasJsonTestRootedMapper)8 BaseFlatPrimitiveClass (io.atlasmap.java.test.BaseFlatPrimitiveClass)7 SourceFlatPrimitiveClass (io.atlasmap.java.test.SourceFlatPrimitiveClass)7 URL (java.net.URL)4 Message (org.apache.camel.Message)4