use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class JavaJsonFlatMappingTest method testProcessJavaJsonFlatPrimitiveUnrooted.
@Test
public void testProcessJavaJsonFlatPrimitiveUnrooted() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/atlasmapping-flatprimitive-unrooted.xml"));
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(generateFlatPrimitiveClass(SourceFlatPrimitiveClass.class));
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);
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class JavaJsonFlatMappingTest method testProcessJavaJsonFlatPrimitiveRooted.
@Test
public void testProcessJavaJsonFlatPrimitiveRooted() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/atlasmapping-flatprimitive-rooted.xml"));
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(generateFlatPrimitiveClass(SourceFlatPrimitiveClass.class));
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
AtlasJsonTestRootedMapper testMapper = new AtlasJsonTestRootedMapper();
TargetFlatPrimitive targetObject = testMapper.readValue((String) object, TargetFlatPrimitive.class);
AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFields(targetObject);
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class JavaJsonSeparateTest method testProcessSeparateSimple.
@Test
public void testProcessSeparateSimple() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/atlasmapping-separate-simple.xml").toURI());
AtlasSession session = context.createSession();
BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
sourceContact.setFirstName("Ozzie Smith");
sourceContact.setLastName(null);
session.setDefaultSourceDocument(sourceContact);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
AtlasJsonTestUnrootedMapper mapper = new AtlasJsonTestUnrootedMapper();
io.atlasmap.json.test.TargetContact targetContact = mapper.readValue((String) object, io.atlasmap.json.test.TargetContact.class);
AtlasTestUtil.validateJsonContact(targetContact);
assertFalse(session.hasErrors());
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class JavaJsonSeparateTest method testProcessSeparateNotEnoughSource.
@Test
public void testProcessSeparateNotEnoughSource() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/atlasmapping-separate-inputshort.xml").toURI());
AtlasSession session = context.createSession();
BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
sourceContact.setFirstName("Dr. Mr. Ozzie");
sourceContact.setLastName(null);
session.setDefaultSourceDocument(sourceContact);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
AtlasJsonTestUnrootedMapper mapper = new AtlasJsonTestUnrootedMapper();
io.atlasmap.json.test.TargetContact targetContact = mapper.readValue((String) object, io.atlasmap.json.test.TargetContact.class);
assertNotNull(targetContact);
assertEquals("Ozzie", targetContact.getFirstName());
assertEquals(null, targetContact.getLastName());
assertTrue(session.hasWarns());
assertEquals("Separate returned fewer segments count=3 when targetField.path=/lastName requested index=3", session.getAudits().getAudit().get(0).getMessage());
}
use of io.atlasmap.api.AtlasContext in project atlasmap by atlasmap.
the class JavaJsonSeparateTest method testProcessSeparateOutOfOrder.
@Test
public void testProcessSeparateOutOfOrder() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJson/atlasmapping-separate-outoforder.xml").toURI());
AtlasSession session = context.createSession();
BaseContact sourceContact = AtlasTestUtil.generateContact(SourceContact.class);
sourceContact.setFirstName("Dr. Mr. Ozzie L. Smith Jr.");
sourceContact.setLastName(null);
session.setDefaultSourceDocument(sourceContact);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof String);
AtlasJsonTestUnrootedMapper mapper = new AtlasJsonTestUnrootedMapper();
io.atlasmap.json.test.TargetContact targetContact = mapper.readValue((String) object, io.atlasmap.json.test.TargetContact.class);
AtlasTestUtil.validateJsonContact(targetContact);
assertFalse(session.hasErrors());
}
Aggregations