Search in sources :

Example 6 with XmlContactAttribute

use of io.atlasmap.xml.test.v2.XmlContactAttribute in project atlasmap by atlasmap.

the class JavaXmlCombineTest method testProcessCombineNullInput.

@Test
public void testProcessCombineNullInput() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToXml/atlasmapping-combine-inputnull.xml").toURI());
    AtlasSession session = context.createSession();
    BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
    sourceContact.setLastName(null);
    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);
    assertNotNull(targetContact);
    assertEquals("Ozzie  5551212 81111", targetContact.getValue().getFirstName());
    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 7 with XmlContactAttribute

use of io.atlasmap.xml.test.v2.XmlContactAttribute in project atlasmap by atlasmap.

the class JavaXmlCombineTest method testProcessCombineSkip.

@Test
public void testProcessCombineSkip() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToXml/atlasmapping-combine-skip.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 8 with XmlContactAttribute

use of io.atlasmap.xml.test.v2.XmlContactAttribute in project atlasmap by atlasmap.

the class JavaXmlSeparateTest method testProcessSeparateSimple.

@Test
public void testProcessSeparateSimple() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToXml/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);
    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 9 with XmlContactAttribute

use of io.atlasmap.xml.test.v2.XmlContactAttribute in project atlasmap by atlasmap.

the class JavaXmlSeparateTest method testProcessSeparateNotEnoughSource.

@Test
public void testProcessSeparateNotEnoughSource() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToXml/atlasmapping-separate-inputshort.xml").toURI());
    AtlasSession session = context.createSession();
    BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
    sourceContact.setFirstName("Dr. Mr. Ozzie");
    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);
    assertNotNull(targetContact.getValue());
    assertEquals("Ozzie", targetContact.getValue().getFirstName());
    assertEquals(null, targetContact.getValue().getLastName());
    assertTrue(session.hasWarns());
    assertEquals("Separate returned fewer segments count=3 when targetField.path=/Contact/@lastName requested index=3", session.getAudits().getAudit().get(0).getMessage());
}
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 10 with XmlContactAttribute

use of io.atlasmap.xml.test.v2.XmlContactAttribute in project atlasmap by atlasmap.

the class JavaXmlSeparateTest method testProcessSeparateNullSource.

@Test
public void testProcessSeparateNullSource() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToXml/atlasmapping-separate-inputnull.xml").toURI());
    AtlasSession session = context.createSession();
    BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
    sourceContact.setFirstName(null);
    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);
    assertFalse(session.hasErrors());
    assertEquals(null, targetContact.getValue().getFirstName());
    assertEquals(null, targetContact.getValue().getLastName());
    assertEquals("5551212", targetContact.getValue().getPhoneNumber());
    assertEquals("81111", 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)

Aggregations

XmlContactAttribute (io.atlasmap.xml.test.v2.XmlContactAttribute)10 Test (org.junit.Test)10 AtlasContext (io.atlasmap.api.AtlasContext)9 AtlasSession (io.atlasmap.api.AtlasSession)9 BaseContact (io.atlasmap.java.test.BaseContact)9 AtlasMappingBaseTest (io.atlasmap.reference.AtlasMappingBaseTest)9 File (java.io.File)9 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 SourceContact (io.atlasmap.java.test.SourceContact)1 TargetContact (io.atlasmap.java.test.TargetContact)1 HashMap (java.util.HashMap)1 Exchange (org.apache.camel.Exchange)1 Message (org.apache.camel.Message)1 ProducerTemplate (org.apache.camel.ProducerTemplate)1 DefaultMessage (org.apache.camel.impl.DefaultMessage)1 DirtiesContext (org.springframework.test.annotation.DirtiesContext)1