use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.
the class BaseMappingTest method getAtlasMappingFullValid.
protected AtlasMapping getAtlasMappingFullValid() {
AtlasMapping mapping = AtlasModelFactory.createAtlasMapping();
mapping.setName("thisis_a_valid.name");
DataSource src = new DataSource();
src.setDataSourceType(DataSourceType.SOURCE);
src.setUri("atlas:java?2");
DataSource tgt = new DataSource();
tgt.setDataSourceType(DataSourceType.TARGET);
tgt.setUri("atlas:java?3");
mapping.getDataSource().add(src);
mapping.getDataSource().add(tgt);
Mapping mapFieldMapping = AtlasModelFactory.createMapping(MappingType.MAP);
MockField inputField = AtlasModelFactory.createMockField();
inputField.setFieldType(FieldType.STRING);
inputField.setCustom("java.lang.String");
inputField.setName("inputName");
mapFieldMapping.getInputField().add(inputField);
MockField outputField = AtlasModelFactory.createMockField();
outputField.setFieldType(FieldType.STRING);
outputField.setCustom("java.lang.String");
outputField.setName("outputName");
mapFieldMapping.getOutputField().add(outputField);
Mapping separateMapping = AtlasModelFactory.createMapping(MappingType.SEPARATE);
MockField sIJavaField = AtlasModelFactory.createMockField();
sIJavaField.setFieldType(FieldType.STRING);
sIJavaField.setCustom("java.lang.String");
sIJavaField.setName("inputName");
separateMapping.getInputField().add(sIJavaField);
MockField sOJavaField = AtlasModelFactory.createMockField();
sOJavaField.setFieldType(FieldType.STRING);
sOJavaField.setCustom("java.lang.String");
sOJavaField.setName("outputName");
sOJavaField.setIndex(0);
separateMapping.getOutputField().add(sOJavaField);
mapping.getMappings().getMapping().add(mapFieldMapping);
mapping.getMappings().getMapping().add(separateMapping);
return mapping;
}
use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.
the class BaseMappingTest method getAtlasMappingWithLookupTables.
protected AtlasMapping getAtlasMappingWithLookupTables(String... names) {
AtlasMapping mapping = this.getAtlasMappingFullValid();
LookupTables lookupTables = new LookupTables();
mapping.setLookupTables(lookupTables);
for (String name : names) {
LookupTable lookupTable = new LookupTable();
lookupTable.setName(name);
lookupTable.setDescription("desc_".concat(name));
lookupTables.getLookupTable().add(lookupTable);
Mapping lookupFieldMapping = AtlasModelFactory.createMapping(MappingType.LOOKUP);
lookupFieldMapping.setDescription("field_desc_".concat(name));
lookupFieldMapping.setLookupTableName(name);
Field inputField = createInputJavaField("inputName");
Field outputField = createInputJavaField("outputName");
lookupFieldMapping.getInputField().add(inputField);
lookupFieldMapping.getOutputField().add(outputField);
mapping.getMappings().getMapping().add(lookupFieldMapping);
}
return mapping;
}
use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.
the class BaseValidatorTest method createMockMappedFields.
protected void createMockMappedFields(AtlasMapping mapping, Mapping mapFieldMapping) {
// Mock MappedField
MockField inputField = new MockField();
inputField.setName("input.name");
MockField outputField = new MockField();
outputField.setName("out.name");
mapFieldMapping.getInputField().add(inputField);
mapFieldMapping.getOutputField().add(outputField);
mapping.getMappings().getMapping().add(mapFieldMapping);
}
use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.
the class DefaultAtlasContextTest method testSeparate.
@Test
public void testSeparate() throws Exception {
Mapping m = (Mapping) AtlasModelFactory.createMapping(MappingType.SEPARATE);
mapping.getMappings().getMapping().add(m);
m.setDelimiter(StringDelimiter.SEMICOLON.getName());
populateSourceField(m, FieldType.STRING, new Date(0).toString() + ";1;2.0;3.0;true;5;6;string;8;9;10");
prepareTargetField(m, "/target1", 1);
prepareTargetField(m, "/target0", 0);
prepareTargetField(m, "/target10", 10);
prepareTargetField(m, "/target9", 9);
prepareTargetField(m, "/target8", 8);
prepareTargetField(m, "/target7", 7);
prepareTargetField(m, "/target6", 6);
prepareTargetField(m, "/target5", 5);
prepareTargetField(m, "/target4", 4);
prepareTargetField(m, "/target3", 3);
prepareTargetField(m, "/target2", 2);
context.process(session);
Assert.assertFalse(printAudit(session), session.hasErrors());
Assert.assertEquals(new Date(0).toString(), writer.targets.get("/target0"));
Assert.assertEquals("1", writer.targets.get("/target1"));
Assert.assertEquals("2.0", writer.targets.get("/target2"));
Assert.assertEquals("3.0", writer.targets.get("/target3"));
Assert.assertEquals("true", writer.targets.get("/target4"));
Assert.assertEquals("5", writer.targets.get("/target5"));
Assert.assertEquals("6", writer.targets.get("/target6"));
Assert.assertEquals("string", writer.targets.get("/target7"));
Assert.assertEquals("8", writer.targets.get("/target8"));
Assert.assertEquals("9", writer.targets.get("/target9"));
Assert.assertEquals("10", writer.targets.get("/target10"));
}
use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.
the class DefaultAtlasContextTest method testMap.
@Test
public void testMap() throws AtlasException {
Mapping m = (Mapping) AtlasModelFactory.createMapping(MappingType.MAP);
mapping.getMappings().getMapping().add(m);
populateSourceField(m, FieldType.STRING, "foo");
prepareTargetField(m, "/target");
context.process(session);
assertFalse(printAudit(session), session.hasErrors());
assertEquals("foo", writer.targets.get("/target"));
}
Aggregations