Search in sources :

Example 71 with AtlasSession

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

the class XmlXmlMultiSourceTest method testProcessBasic.

@Test
public void testProcessBasic() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToXml/atlasmapping-multisource-basic.xml").toURI());
    AtlasSession session = context.createSession();
    String sourceContact = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToXml/atlas-xml-contact-attribute.xml");
    String sourceAddress = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToXml/atlas-xml-address-attribute.xml");
    session.setSourceDocument("con", sourceContact);
    session.setSourceDocument("addr", sourceAddress);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><Contact firstName=\"Ozzie\" zipCode=\"90210\"/>", object);
}
Also used : AtlasContext(io.atlasmap.api.AtlasContext) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 72 with AtlasSession

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

the class JsonJsonMultiSourceTest method testProcessBasic.

@Test
public void testProcessBasic() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJson/atlasmapping-multisource-basic.xml").toURI());
    AtlasSession session = context.createSession();
    String sourceContact = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJson/atlas-json-contact-unrooted.json");
    String sourceAddress = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJson/atlas-json-address-unrooted.json");
    session.setSourceDocument("con", sourceContact);
    session.setSourceDocument("addr", sourceAddress);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    AtlasJsonTestUnrootedMapper testMapper = new AtlasJsonTestUnrootedMapper();
    TargetContact targetContact = testMapper.readValue((String) object, TargetContact.class);
    assertEquals("Ozzie", targetContact.getFirstName());
    assertNull(targetContact.getLastName());
    assertNull(targetContact.getPhoneNumber());
    assertEquals("90210", targetContact.getZipCode());
}
Also used : TargetContact(io.atlasmap.json.test.TargetContact) 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)

Example 73 with AtlasSession

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

the class JsonJsonMultiSourceTest method testProcessComplex.

@Test
public void testProcessComplex() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJson/atlasmapping-multisource-complex.xml").toURI());
    AtlasSession session = context.createSession();
    String sourceContact = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJson/atlas-json-contact-unrooted.json");
    String sourceAddress = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJson/atlas-json-address-unrooted.json");
    session.setSourceDocument("con", sourceContact);
    session.setSourceDocument("addr", sourceAddress);
    context.process(session);
    assertFalse(printAudit(session), session.hasErrors());
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    AtlasJsonTestUnrootedMapper testMapper = new AtlasJsonTestUnrootedMapper();
    TargetOrder targetOrder = testMapper.readValue((String) object, TargetOrder.class);
    AtlasTestUtil.validateJsonOrder(targetOrder);
}
Also used : AtlasContext(io.atlasmap.api.AtlasContext) AtlasJsonTestUnrootedMapper(io.atlasmap.json.test.AtlasJsonTestUnrootedMapper) TargetOrder(io.atlasmap.json.test.TargetOrder) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 74 with AtlasSession

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

the class XmlXmlComplexTest method testProcessXmlXmlComplexOrderAutodetectElementToAttribute.

@Test
public void testProcessXmlXmlComplexOrderAutodetectElementToAttribute() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToXml/atlasmapping-complex-order-autodetect-elementToAttribute.xml").toURI());
    AtlasSession session = context.createSession();
    String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToXml/atlas-xml-complex-order-autodetect-element.xml");
    session.setDefaultSourceDocument(sourceXml);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><XmlOA orderId=\"8765309\"><Contact firstName=\"Ozzie\" lastName=\"Smith\" phoneNumber=\"5551212\" zipCode=\"81111\"/><Address addressLine1=\"123 Main St\" addressLine2=\"Suite 42b\" city=\"Anytown\" state=\"NY\" zipCode=\"90210\"/></XmlOA>", object);
}
Also used : AtlasContext(io.atlasmap.api.AtlasContext) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 75 with AtlasSession

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

the class XmlXmlComplexTest method testProcessXmlXmlComplexOrderAutodetectAttributeToElementNS.

@Test
public void testProcessXmlXmlComplexOrderAutodetectAttributeToElementNS() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToXml/atlasmapping-complex-order-autodetect-attributeToElement-ns.xml").toURI());
    AtlasSession session = context.createSession();
    String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToXml/atlas-xml-complex-order-autodetect-attribute-ns.xml");
    session.setDefaultSourceDocument(sourceXml);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    JAXBElement<XmlOrderElement> xmlOE = AtlasXmlTestHelper.unmarshal((String) object, XmlOrderElement.class);
    AtlasTestUtil.validateXmlOrderElement(xmlOE.getValue());
}
Also used : AtlasContext(io.atlasmap.api.AtlasContext) XmlOrderElement(io.atlasmap.xml.test.v2.XmlOrderElement) File(java.io.File) 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