Search in sources :

Example 56 with AtlasSession

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

the class XmlJavaComplexTest method testProcessXmlJavaComplexOrderAutodetectElementNS.

@Test
public void testProcessXmlJavaComplexOrderAutodetectElementNS() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToJava/atlasmapping-complex-order-autodetect-element-ns.xml").toURI());
    AtlasSession session = context.createSession();
    String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToJava/atlas-xml-complex-order-autodetect-element-ns.xml");
    session.setDefaultSourceDocument(sourceXml);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof TargetOrder);
    AtlasTestUtil.validateOrder((TargetOrder) object);
}
Also used : AtlasContext(io.atlasmap.api.AtlasContext) TargetOrder(io.atlasmap.java.test.TargetOrder) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 57 with AtlasSession

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

the class XmlJsonAutoConversionTest method processXmlJsonFlatMappingAutoConversion.

protected void processXmlJsonFlatMappingAutoConversion(String mappingFile, String inputFile, int num) throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File(mappingFile).toURI());
    AtlasSession session = context.createSession();
    String source = AtlasTestUtil.loadFileAsString(inputFile);
    session.setDefaultSourceDocument(source);
    context.process(session);
    assertFalse(printAudit(session), session.hasErrors());
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    AtlasJsonTestUnrootedMapper testMapper = new AtlasJsonTestUnrootedMapper();
    TargetFlatPrimitive targetObject = testMapper.readValue((String) object, TargetFlatPrimitive.class);
    switch(num) {
        case 1:
            AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFieldAutoConversion1(targetObject);
            break;
        case 2:
            AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFieldAutoConversion2(targetObject);
            break;
        case 3:
            AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFieldAutoConversion3(targetObject);
            break;
        case 4:
            AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFieldAutoConversion4(targetObject);
            break;
        case 5:
            AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFieldAutoConversion5(targetObject);
            break;
        case 6:
            AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFieldAutoConversion6(targetObject);
            break;
        case 7:
            AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFieldAutoConversion7(targetObject);
            break;
        default:
            fail("Unexpected number: " + num);
    }
}
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)

Example 58 with AtlasSession

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

the class XmlJsonComplexTest method processXmlToJsonOrder.

protected void processXmlToJsonOrder(String mappingFile, String inputFile, boolean rooted) throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File(mappingFile).toURI());
    AtlasSession session = context.createSession();
    String sourceXml = AtlasTestUtil.loadFileAsString(inputFile);
    session.setDefaultSourceDocument(sourceXml);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof String);
    TargetOrder targetObject = null;
    if (rooted) {
        AtlasJsonTestRootedMapper testMapper = new AtlasJsonTestRootedMapper();
        targetObject = testMapper.readValue((String) object, TargetOrder.class);
    } else {
        AtlasJsonTestUnrootedMapper testMapper = new AtlasJsonTestUnrootedMapper();
        targetObject = testMapper.readValue((String) object, TargetOrder.class);
    }
    AtlasTestUtil.validateJsonOrder(targetObject);
}
Also used : AtlasJsonTestRootedMapper(io.atlasmap.json.test.AtlasJsonTestRootedMapper) AtlasContext(io.atlasmap.api.AtlasContext) TargetOrder(io.atlasmap.json.test.TargetOrder) AtlasJsonTestUnrootedMapper(io.atlasmap.json.test.AtlasJsonTestUnrootedMapper) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession)

Example 59 with AtlasSession

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

the class XmlJsonFlatMappingTest method testProcessXmlJavaBoxedFlatMappingPrimitiveAttributeNS.

@Test
public void testProcessXmlJavaBoxedFlatMappingPrimitiveAttributeNS() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToJava/atlasmapping-boxedflatprimitive-attribute-ns.xml"));
    AtlasSession session = context.createSession();
    String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToJava/atlas-xml-boxedflatprimitive-attribute-ns.xml");
    session.setDefaultSourceDocument(sourceXml);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
// validateFlatPrimitiveClassBoxedPrimitiveFields((TargetFlatPrimitiveClass)object);
}
Also used : AtlasContext(io.atlasmap.api.AtlasContext) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest) Test(org.junit.Test)

Example 60 with AtlasSession

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

the class XmlJavaFlatMappingTest method testProcessXmlJavaBoxedFlatMappingPrimitiveAttributeNS.

@Test
public void testProcessXmlJavaBoxedFlatMappingPrimitiveAttributeNS() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToJava/atlasmapping-boxedflatprimitive-attribute-ns.xml"));
    AtlasSession session = context.createSession();
    String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToJava/atlas-xml-boxedflatprimitive-attribute-ns.xml");
    session.setDefaultSourceDocument(sourceXml);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof TargetFlatPrimitiveClass);
    validateFlatPrimitiveClassBoxedPrimitiveFields((TargetFlatPrimitiveClass) object);
}
Also used : TargetFlatPrimitiveClass(io.atlasmap.java.test.TargetFlatPrimitiveClass) AtlasContext(io.atlasmap.api.AtlasContext) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest) Test(org.junit.Test)

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