use of io.atlasmap.java.test.BaseFlatPrimitiveClass in project atlasmap by atlasmap.
the class JavaJsonFlatMappingTest method generateFlatPrimitiveClassPrimitiveFieldsBoxedValues.
protected BaseFlatPrimitiveClass generateFlatPrimitiveClassPrimitiveFieldsBoxedValues(Class<? extends BaseFlatPrimitiveClass> clazz) throws Exception {
Class<?> targetClazz = this.getClass().getClassLoader().loadClass(clazz.getName());
BaseFlatPrimitiveClass newObject = (BaseFlatPrimitiveClass) targetClazz.newInstance();
newObject.setBooleanField(Boolean.FALSE);
newObject.setByteField(new Byte((byte) 99));
newObject.setCharField(new Character('a'));
newObject.setDoubleField(new Double(50000000d));
newObject.setFloatField(new Float(40000000f));
newObject.setIntField(new Integer(2));
newObject.setLongField(new Long(30000L));
newObject.setShortField(new Short((short) 1));
return newObject;
}
use of io.atlasmap.java.test.BaseFlatPrimitiveClass 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.BaseFlatPrimitiveClass in project atlasmap by atlasmap.
the class XmlJavaFlatMappingTest method generateFlatPrimitiveClassBoxedPrimitiveFieldsBoxedValues.
protected BaseFlatPrimitiveClass generateFlatPrimitiveClassBoxedPrimitiveFieldsBoxedValues(Class<? extends BaseFlatPrimitiveClass> clazz) throws Exception {
Class<?> targetClazz = this.getClass().getClassLoader().loadClass(clazz.getName());
BaseFlatPrimitiveClass newObject = (BaseFlatPrimitiveClass) targetClazz.newInstance();
newObject.setBoxedBooleanField(Boolean.valueOf(Boolean.TRUE));
newObject.setBoxedByteField(new Byte((byte) 87));
newObject.setBoxedCharField(new Character('z'));
newObject.setBoxedDoubleField(new Double(90000000d));
newObject.setBoxedFloatField(new Float(70000000f));
newObject.setBoxedIntField(new Integer(5));
newObject.setBoxedLongField(new Long(20000L));
newObject.setBoxedShortField(new Short((short) 5));
return newObject;
}
use of io.atlasmap.java.test.BaseFlatPrimitiveClass in project atlasmap by atlasmap.
the class XmlJavaFlatMappingTest method generateFlatPrimitiveClassPrimitiveFieldsBoxedValues.
protected BaseFlatPrimitiveClass generateFlatPrimitiveClassPrimitiveFieldsBoxedValues(Class<? extends BaseFlatPrimitiveClass> clazz) throws Exception {
Class<?> targetClazz = this.getClass().getClassLoader().loadClass(clazz.getName());
BaseFlatPrimitiveClass newObject = (BaseFlatPrimitiveClass) targetClazz.newInstance();
newObject.setBooleanField(Boolean.valueOf(Boolean.FALSE));
newObject.setByteField(new Byte((byte) 99));
newObject.setCharField(new Character('a'));
newObject.setDoubleField(new Double(50000000d));
newObject.setFloatField(new Float(40000000f));
newObject.setIntField(new Integer(2));
newObject.setLongField(new Long(30000L));
newObject.setShortField(new Short((short) 1));
return newObject;
}
use of io.atlasmap.java.test.BaseFlatPrimitiveClass in project atlasmap by atlasmap.
the class AtlasTestUtil method generateFlatPrimitiveClass.
public static BaseFlatPrimitiveClass generateFlatPrimitiveClass(Class<? extends BaseFlatPrimitiveClass> clazz) throws Exception {
Class<?> targetClazz = AtlasTestUtil.class.getClassLoader().loadClass(clazz.getName());
BaseFlatPrimitiveClass newObject = (BaseFlatPrimitiveClass) targetClazz.newInstance();
newObject.setBooleanField(false);
newObject.setByteField((byte) 99);
newObject.setCharField('a');
newObject.setDoubleField(50000000d);
newObject.setFloatField(40000000f);
newObject.setIntField(2);
newObject.setLongField(30000L);
newObject.setShortField((short) 1);
return newObject;
}
Aggregations