Search in sources :

Example 86 with AtlasSession

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

the class XmlXmlCollectionConverstionTest method testProcessCollectionFromNonCollection.

@Test
public void testProcessCollectionFromNonCollection() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToXml/atlasmapping-collection-from-noncollection.xml").toURI());
    // contact.firstName -> contact<>.name
    String input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    input += "<XmlOA>";
    input += "<contact><firstName>name76</firstName></contact>";
    input += "</XmlOA>";
    AtlasSession session = context.createSession();
    session.setDefaultSourceDocument(input);
    context.process(session);
    String output = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>";
    output += "<XmlOA>";
    output += "<contact><name>name76</name></contact>";
    output += "</XmlOA>";
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    assertEquals(output, 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 87 with AtlasSession

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

the class XmlXmlCollectionConverstionTest method testProcessCollectionArraySimple.

@Test
public void testProcessCollectionArraySimple() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToXml/atlasmapping-collection-array-simple.xml").toURI());
    // contact[].firstName -> contact[].name
    String input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    input += "<XmlOA>";
    for (int i = 0; i < 3; i++) {
        input += "<contact><firstName>name" + i + "</firstName></contact>";
    }
    input += "</XmlOA>";
    AtlasSession session = context.createSession();
    session.setDefaultSourceDocument(input);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    String output = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>";
    output += "<XmlOA>";
    for (int i = 0; i < 3; i++) {
        output += "<contact><name>name" + i + "</name></contact>";
    }
    output += "</XmlOA>";
    assertEquals(output, 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 88 with AtlasSession

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

the class XmlXmlCollectionConverstionTest method testProcessCollectionToNonCollection.

@Test
public void testProcessCollectionToNonCollection() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToXml/atlasmapping-collection-to-noncollection.xml").toURI());
    // contact<>.firstName -> contact.name
    String input = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    input += "<XmlOA>";
    for (int i = 0; i < 3; i++) {
        input += "<contact><firstName>name" + i + "</firstName></contact>";
    }
    input += "</XmlOA>";
    AtlasSession session = context.createSession();
    session.setDefaultSourceDocument(input);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    String output = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>";
    output += "<XmlOA>";
    output += "<contact><name>name2</name></contact>";
    output += "</XmlOA>";
    assertEquals(output, 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 89 with AtlasSession

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

the class XmlXmlComplexTest method testProcessXmlXmlComplexOrderAutodetectAttributeToElement.

@Test
public void testProcessXmlXmlComplexOrderAutodetectAttributeToElement() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToXml/atlasmapping-complex-order-autodetect-attributeToElement.xml").toURI());
    AtlasSession session = context.createSession();
    String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToXml/atlas-xml-complex-order-autodetect-attribute.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\"?><XmlOE><orderId>8765309</orderId><Contact><firstName>Ozzie</firstName><lastName>Smith</lastName><phoneNumber>5551212</phoneNumber><zipCode>81111</zipCode></Contact><Address><addressLine1>123 Main St</addressLine1><addressLine2>Suite 42b</addressLine2><city>Anytown</city><state>NY</state><zipCode>90210</zipCode></Address></XmlOE>", 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 90 with AtlasSession

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

the class XmlXmlComplexTest method testProcessXmlXmlComplexOrderAutodetectElementToAttributeNS.

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