Search in sources :

Example 1 with BaseFlatPrimitiveClass

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);
    }
}
Also used : Validation(io.atlasmap.v2.Validation) Validations(io.atlasmap.v2.Validations) TargetFlatPrimitiveClass(io.atlasmap.java.test.TargetFlatPrimitiveClass) AtlasContext(io.atlasmap.api.AtlasContext) BaseFlatPrimitiveClass(io.atlasmap.java.test.BaseFlatPrimitiveClass) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest) Test(org.junit.Test)

Example 2 with BaseFlatPrimitiveClass

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;
}
Also used : BaseFlatPrimitiveClass(io.atlasmap.java.test.BaseFlatPrimitiveClass)

Example 3 with BaseFlatPrimitiveClass

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;
}
Also used : BaseFlatPrimitiveClass(io.atlasmap.java.test.BaseFlatPrimitiveClass)

Example 4 with BaseFlatPrimitiveClass

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;
}
Also used : TargetFlatPrimitive(io.atlasmap.json.test.TargetFlatPrimitive) AtlasContext(io.atlasmap.api.AtlasContext) AtlasJsonTestUnrootedMapper(io.atlasmap.json.test.AtlasJsonTestUnrootedMapper) BaseFlatPrimitiveClass(io.atlasmap.java.test.BaseFlatPrimitiveClass) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession)

Example 5 with BaseFlatPrimitiveClass

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;
}
Also used : BaseFlatPrimitiveClass(io.atlasmap.java.test.BaseFlatPrimitiveClass)

Aggregations

BaseFlatPrimitiveClass (io.atlasmap.java.test.BaseFlatPrimitiveClass)22 AtlasContext (io.atlasmap.api.AtlasContext)7 AtlasSession (io.atlasmap.api.AtlasSession)7 File (java.io.File)7 TargetFlatPrimitiveClass (io.atlasmap.java.test.TargetFlatPrimitiveClass)6 AtlasMappingBaseTest (io.atlasmap.reference.AtlasMappingBaseTest)4 Test (org.junit.Test)4 AtlasJsonTestUnrootedMapper (io.atlasmap.json.test.AtlasJsonTestUnrootedMapper)2 TargetFlatPrimitive (io.atlasmap.json.test.TargetFlatPrimitive)2 Validation (io.atlasmap.v2.Validation)1 Validations (io.atlasmap.v2.Validations)1