Search in sources :

Example 76 with AtlasContext

use of io.atlasmap.api.AtlasContext 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 77 with AtlasContext

use of io.atlasmap.api.AtlasContext 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 78 with AtlasContext

use of io.atlasmap.api.AtlasContext 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)

Example 79 with AtlasContext

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

the class XmlXmlFlatMappingTest method testProcessXmlXmlFlatPrimitiveElementToAttributeNS.

@Test
public void testProcessXmlXmlFlatPrimitiveElementToAttributeNS() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToXml/atlasmapping-flatprimitive-elementToAttribute-ns.xml"));
    AtlasSession session = context.createSession();
    String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToXml/atlas-xml-flatprimitive-element-ns.xml");
    session.setDefaultSourceDocument(sourceXml);
    context.process(session);
    assertFalse(printAudit(session), session.hasErrors());
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    JAXBElement<XmlFlatPrimitiveAttribute> xmlFPA = AtlasXmlTestHelper.unmarshal((String) object, XmlFlatPrimitiveAttribute.class);
    AtlasTestUtil.validateXmlFlatPrimitiveAttribute(xmlFPA.getValue());
}
Also used : AtlasContext(io.atlasmap.api.AtlasContext) XmlFlatPrimitiveAttribute(io.atlasmap.xml.test.v2.XmlFlatPrimitiveAttribute) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 80 with AtlasContext

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

the class JsonJsonFlatMappingTest method testProcessJsonJsonFlatPrimitiveUnrooted.

@Test
public void testProcessJsonJsonFlatPrimitiveUnrooted() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJson/atlasmapping-flatprimitive-unrooted.xml"));
    AtlasSession session = context.createSession();
    String source = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJson/atlas-json-flatprimitive-unrooted.json");
    session.setDefaultSourceDocument(source);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    AtlasJsonTestUnrootedMapper testMapper = new AtlasJsonTestUnrootedMapper();
    TargetFlatPrimitive targetObject = testMapper.readValue((String) object, TargetFlatPrimitive.class);
    AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFields(targetObject);
}
Also used : TargetFlatPrimitive(io.atlasmap.json.test.TargetFlatPrimitive) AtlasContext(io.atlasmap.api.AtlasContext) AtlasJsonTestUnrootedMapper(io.atlasmap.json.test.AtlasJsonTestUnrootedMapper) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest) Test(org.junit.Test)

Aggregations

AtlasContext (io.atlasmap.api.AtlasContext)138 AtlasSession (io.atlasmap.api.AtlasSession)138 File (java.io.File)128 Test (org.junit.Test)119 AtlasMappingBaseTest (io.atlasmap.reference.AtlasMappingBaseTest)111 BaseContact (io.atlasmap.java.test.BaseContact)25 AtlasJsonTestUnrootedMapper (io.atlasmap.json.test.AtlasJsonTestUnrootedMapper)25 TargetFlatPrimitiveClass (io.atlasmap.java.test.TargetFlatPrimitiveClass)24 TargetContact (io.atlasmap.java.test.TargetContact)19 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 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 AtlasMapping (io.atlasmap.v2.AtlasMapping)7 TargetOrder (io.atlasmap.json.test.TargetOrder)4 XmlFlatPrimitiveElement (io.atlasmap.xml.test.v2.XmlFlatPrimitiveElement)4