use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateConstantMapping.
protected AtlasMapping generateConstantMapping() {
AtlasMapping mapping = generateAtlasMapping();
ConstantField inputField = new ConstantField();
Actions actions = new Actions();
actions.getActions().add(new Trim());
populateFieldComplexObject(inputField, actions, CollectionType.ARRAY, FieldStatus.SUPPORTED, FieldType.INTEGER);
populateFieldSimpleObject(inputField, 3, "docid", "/path", false, "bar");
Mapping fm = (Mapping) mapping.getMappings().getMapping().get(0);
fm.getInputField().add(inputField);
fm.getOutputField().add(inputField);
populateMapping(fm, MappingType.MAP, "MapPropertyFieldAlias", ",", ",");
populateMappingString(fm, "description", "id", "lookupTableName", "strategy", "strategyClassName");
return mapping;
}
use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.
the class BaseMarshallerTest method validateAtlasMapping.
protected void validateAtlasMapping(AtlasMapping atlasMapping) {
assertNotNull(atlasMapping);
assertEquals("junit", atlasMapping.getName());
assertEquals(2, atlasMapping.getDataSource().size());
valiateDataSource(atlasMapping.getDataSource().get(0), DataSourceType.SOURCE, "srcId", "srcUri");
valiateDataSource(atlasMapping.getDataSource().get(1), DataSourceType.TARGET, "tgtId", "tgtUri");
assertNotNull(atlasMapping.getLookupTables());
assertEquals(1, atlasMapping.getLookupTables().getLookupTable().size());
validateLookupTable(atlasMapping.getLookupTables().getLookupTable().get(0));
assertNotNull(atlasMapping.getMappings());
assertEquals(1, atlasMapping.getMappings().getMapping().size());
Mapping mapping = (Mapping) atlasMapping.getMappings().getMapping().get(0);
assertEquals(1, mapping.getInputField().size());
validateJavaField((JavaField) mapping.getInputField().get(0));
assertEquals(1, mapping.getOutputField().size());
validateJavaField((JavaField) mapping.getOutputField().get(0));
validateMapping(mapping, MappingType.MAP, generateMappingParams());
assertNotNull(atlasMapping.getProperties());
assertEquals(1, atlasMapping.getProperties().getProperty().size());
validateProperty(atlasMapping.getProperties().getProperty().get(0));
}
use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateSeparateAtlasMapping.
protected AtlasMapping generateSeparateAtlasMapping() {
Actions actions = generateActions();
StringList annotations = generateAnnotations();
ModifierList modifierList = generateModifierList();
StringList parameterizedTypes = generateParameterizedTypes();
JavaField inputJavaField = generateJavaField(actions, annotations, modifierList, parameterizedTypes);
JavaField outputJavaFieldA = generateJavaField(actions, annotations, modifierList, parameterizedTypes);
JavaField outputJavaFieldB = generateJavaField(actions, annotations, modifierList, parameterizedTypes);
Mapping fm = (Mapping) AtlasModelFactory.createMapping(MappingType.SEPARATE);
fm.getInputField().add(inputJavaField);
fm.getOutputField().add(outputJavaFieldA);
fm.getOutputField().add(outputJavaFieldB);
populateMapping(fm, MappingType.SEPARATE, "MapPropertyFieldAlias", ",", ",");
populateMappingString(fm, "description", "id", "lookupTableName", "strategy", "strategyClassName");
AtlasMapping mapping = generateAtlasMapping();
mapping.getMappings().getMapping().clear();
mapping.getMappings().getMapping().add(fm);
return mapping;
}
use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.
the class JavaJavaFlatMappingTest method generateJavaJavaFlatMapping.
protected AtlasMapping generateJavaJavaFlatMapping() {
AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
atlasMapping.setName("JavaJavaFlatMapping");
atlasMapping.getDataSource().add(generateDataSource("atlas:java?className=io.atlasmap.java.test.SourceFlatPrimitiveClass", DataSourceType.SOURCE));
atlasMapping.getDataSource().add(generateDataSource("atlas:java?className=io.atlasmap.java.test.TargetFlatPrimitiveClass", DataSourceType.TARGET));
List<BaseMapping> mappings = atlasMapping.getMappings().getMapping();
// Add fieldMappings
for (String fieldName : FLAT_FIELDS) {
Mapping mfm = AtlasModelFactory.createMapping(MappingType.MAP);
mfm.getInputField().add(generateJavaField(fieldName));
mfm.getOutputField().add(generateJavaField(fieldName));
mappings.add(mfm);
}
return atlasMapping;
}
use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.
the class JavaJavaDateTimeMappingTest method doTest.
private void doTest(int offset) throws Exception {
AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
atlasMapping.setName("JavaJavaDateTimeMapping");
addDataSource(atlasMapping, "atlas:java?className=io.atlasmap.java.test.DateTimeClass", DataSourceType.SOURCE);
addDataSource(atlasMapping, "atlas:java?className=io.atlasmap.java.test.DateTimeClass", DataSourceType.TARGET);
List<BaseMapping> mappings = atlasMapping.getMappings().getMapping();
for (int i = 0; i < DATE_TIME_FIELDS.length; i++) {
int targetIndex = offset + i < DATE_TIME_FIELDS.length ? offset + i : offset + i - DATE_TIME_FIELDS.length;
JavaField sourceField = copyJavaField(DATE_TIME_FIELDS[i]);
JavaField targetField = copyJavaField(DATE_TIME_FIELDS[targetIndex]);
if (UNSUPPORTED.containsKey(sourceField.getFieldType()) && UNSUPPORTED.get(sourceField.getFieldType()).equals(targetField.getFieldType())) {
sourceField = copyJavaField(targetField);
}
Mapping mfm = AtlasModelFactory.createMapping(MappingType.MAP);
mfm.getInputField().add(sourceField);
mfm.getOutputField().add(targetField);
mappings.add(mfm);
}
AtlasContext context = ((DefaultAtlasContextFactory) atlasContextFactory).createContext(atlasMapping);
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(createSource());
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof DateTimeClass);
validateTarget((DateTimeClass) object);
}
Aggregations