use of io.atlasmap.v2.AtlasMapping 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.AtlasMapping 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.AtlasMapping 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.v2.AtlasMapping in project atlasmap by atlasmap.
the class JavaJavaFlatMappingTest method testCreateJavaJavaFlatFieldMapping.
@Test
public void testCreateJavaJavaFlatFieldMapping() throws Exception {
AtlasMapping atlasMapping = generateJavaJavaFlatMapping();
AtlasMappingService atlasMappingService = new AtlasMappingService(Arrays.asList("io.atlasmap.v2", "io.atlasmap.java.v2"));
File path = new File("target/reference-mappings/javaToJava");
path.mkdirs();
atlasMappingService.saveMappingAsFile(atlasMapping, new File(path, "atlasmapping-flatprimitive.xml"));
}
use of io.atlasmap.v2.AtlasMapping 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