Search in sources :

Example 6 with BaseFlatPrimitiveClass

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

Example 7 with BaseFlatPrimitiveClass

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);
}
Also used : TargetFlatPrimitive(io.atlasmap.json.test.TargetFlatPrimitive) TargetFlatPrimitiveClass(io.atlasmap.java.test.TargetFlatPrimitiveClass) 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) Test(org.junit.Test) AtlasMappingBaseTest(io.atlasmap.reference.AtlasMappingBaseTest)

Example 8 with BaseFlatPrimitiveClass

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

Example 9 with BaseFlatPrimitiveClass

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

Example 10 with BaseFlatPrimitiveClass

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;
}
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