use of io.atlasmap.java.test.TargetFlatPrimitiveClass in project atlasmap by atlasmap.
the class JavaJavaCollectionTest method testProcessCollectionPrimitive.
@Test
public void testProcessCollectionPrimitive() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-collection-flatprimitive.xml").toURI());
SourceFlatPrimitiveClass source = new SourceFlatPrimitiveClass();
source.setBoxedStringField("fuga");
source.setBoxedStringArrayField(new String[] { "foo", "bar", "hoge", "fuga" });
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(source);
context.process(session);
assertFalse(printAudit(session), session.hasErrors());
TargetFlatPrimitiveClass target = (TargetFlatPrimitiveClass) session.getDefaultTargetDocument();
assertEquals("fuga", target.getBoxedStringField());
assertEquals(1, target.getBoxedStringArrayField().length);
assertEquals("fuga", target.getBoxedStringArrayField()[0]);
}
use of io.atlasmap.java.test.TargetFlatPrimitiveClass 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);
}
use of io.atlasmap.java.test.TargetFlatPrimitiveClass 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);
}
use of io.atlasmap.java.test.TargetFlatPrimitiveClass in project atlasmap by atlasmap.
the class MultidocFlatMappingTest method testProcessJavaJavaFlatFieldMapping.
@Test
public void testProcessJavaJavaFlatFieldMapping() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/multidoc/atlasmapping-flatprimitive.xml").toURI());
AtlasSession session = context.createSession();
BaseFlatPrimitiveClass sourceJava = generateFlatPrimitiveClass(SourceFlatPrimitiveClass.class);
session.setSourceDocument("SourceJava", sourceJava);
String sourceJson = AtlasTestUtil.loadFileAsString("src/test/resources/multidoc/atlas-json-flatprimitive-unrooted.json");
session.setSourceDocument("SourceJson", sourceJson);
String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/multidoc/atlas-xml-flatprimitive-attribute.xml");
session.setSourceDocument("SourceXml", sourceXml);
context.process(session);
assertFalse(printAudit(session), session.hasErrors());
Object targetJava = session.getTargetDocument("TargetJava");
assertNotNull(targetJava);
assertTrue(targetJava instanceof TargetFlatPrimitiveClass);
validateFlatPrimitiveClassPrimitiveFields((TargetFlatPrimitiveClass) targetJava);
Object targetJson = session.getTargetDocument("TargetJson");
assertNotNull(targetJson);
assertTrue(targetJson instanceof String);
AtlasJsonTestUnrootedMapper testMapper = new AtlasJsonTestUnrootedMapper();
TargetFlatPrimitive targetObject = testMapper.readValue((String) targetJson, TargetFlatPrimitive.class);
AtlasTestUtil.validateJsonFlatPrimitivePrimitiveFields(targetObject);
Object targetXml = session.getTargetDocument("TargetXml");
assertNotNull(targetXml);
assertTrue(targetXml instanceof String);
assertEquals(targetXml.toString(), "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><XmlFPA booleanField=\"false\" byteField=\"99\" charField=\"a\" doubleField=\"5.0E7\" floatField=\"4.0E7\" intField=\"2\" longField=\"30000\" shortField=\"1\"/>", targetXml);
}
use of io.atlasmap.java.test.TargetFlatPrimitiveClass 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);
}
Aggregations