use of io.atlasmap.java.test.BaseFlatPrimitiveClass in project atlasmap by atlasmap.
the class JavaJavaFlatMappingTest method testProcessJavaJavaFlatFieldMappingPrimitivesBoxedValues.
@Test
public void testProcessJavaJavaFlatFieldMappingPrimitivesBoxedValues() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-flatprimitive.xml").toURI());
AtlasSession session = context.createSession();
BaseFlatPrimitiveClass sourceClass = generateFlatPrimitiveClassPrimitiveFieldsBoxedValues(SourceFlatPrimitiveClass.class);
session.setDefaultSourceDocument(sourceClass);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof TargetFlatPrimitiveClass);
validateFlatPrimitiveClassPrimitiveFields((TargetFlatPrimitiveClass) object);
Validations validations = session.getValidations();
for (Validation v : validations.getValidation()) {
printValidation(v);
}
}
use of io.atlasmap.java.test.BaseFlatPrimitiveClass in project atlasmap by atlasmap.
the class JavaJavaFlatMappingTest 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 JavaJavaFlatMappingTest 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 JavaJsonAutoConversionTest method executeMapping.
protected Object executeMapping(String fileName) throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File(fileName).toURI());
AtlasSession session = context.createSession();
BaseFlatPrimitiveClass source = AtlasTestUtil.generateFlatPrimitiveClass(SourceFlatPrimitiveClass.class);
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);
return targetObject;
}
use of io.atlasmap.java.test.BaseFlatPrimitiveClass in project atlasmap by atlasmap.
the class JavaJsonFlatMappingTest 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));
newObject.setBoxedStringField("boxedStringValue");
return newObject;
}
Aggregations