Search in sources :

Example 36 with AtlasSession

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

the class JavaJavaCombineTest method testProcessCombineSimple.

@Test
public void testProcessCombineSimple() throws Exception {
    AtlasSession session = processCombineMapping("src/test/resources/javaToJava/atlasmapping-combine-simple.xml", AtlasTestUtil.generateContact(SourceContact.class));
    TargetContact targetContact = (TargetContact) session.getDefaultTargetDocument();
    assertEquals("Ozzie    Smith   5551212                                                                                            81111", targetContact.getFirstName());
    assertNull(targetContact.getLastName());
    assertNull(targetContact.getPhoneNumber());
    assertNull(targetContact.getZipCode());
    assertFalse(session.hasErrors());
}
Also used : TargetContact(io.atlasmap.java.test.TargetContact) SourceContact(io.atlasmap.java.test.SourceContact) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 37 with AtlasSession

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

the class JavaJavaComplexListTest method testProcessJavaJavaComplexAutoDetectFullTest.

@Test
@Ignore("https://github.com/atlasmap/atlasmap-runtime/issues/229 - Allow default implementation for abstract target field")
public void testProcessJavaJavaComplexAutoDetectFullTest() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-complex-list-autodetect-full.xml"));
    AtlasSession session = context.createSession();
    BaseOrderList sourceOrderList = AtlasTestUtil.generateOrderListClass(SourceOrderList.class, SourceOrder.class, SourceAddress.class, SourceContact.class);
    session.setDefaultSourceDocument(sourceOrderList);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof TargetOrderList);
    AtlasTestUtil.validateOrderList((TargetOrderList) object);
}
Also used : AtlasContext(io.atlasmap.api.AtlasContext) NoAbstractTargetOrderList(io.atlasmap.reference.NoAbstractTargetOrderList) TargetOrderList(io.atlasmap.java.test.TargetOrderList) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) BaseOrderList(io.atlasmap.java.test.BaseOrderList) Ignore(org.junit.Ignore) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest) Test(org.junit.Test)

Example 38 with AtlasSession

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

the class JsonJavaFlatMappingTest method testProcessJsonJavaFlatPrimitiveRooted.

@Test
public void testProcessJsonJavaFlatPrimitiveRooted() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJava/atlasmapping-flatprimitive-rooted.xml"));
    AtlasSession session = context.createSession();
    String source = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJava/atlas-json-flatprimitive-rooted.json");
    session.setDefaultSourceDocument(source);
    context.process(session);
    Object object = session.getDefaultTargetDocument();
    assertNotNull(object);
    assertTrue(object instanceof TargetFlatPrimitiveClass);
    validateFlatPrimitiveClassPrimitiveFields((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)

Example 39 with AtlasSession

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

the class JsonJavaFlatMappingTest method testProcessJsonJavaBoxedFlatMappingPrimitiveRooted.

@Test
public void testProcessJsonJavaBoxedFlatMappingPrimitiveRooted() throws Exception {
    AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJava/atlasmapping-boxedflatprimitive-rooted.xml"));
    AtlasSession session = context.createSession();
    String source = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJava/atlas-json-boxedflatprimitive-rooted.json");
    session.setDefaultSourceDocument(source);
    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)

Example 40 with AtlasSession

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

the class JavaXmlCombineTest method testProcessCombineSimple.

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

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