use of io.atlasmap.v2.Mappings in project atlasmap by atlasmap.
the class JsonValidationServiceTest method testValidateMappingPathNull.
@Test
public void testValidateMappingPathNull() throws Exception {
AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/HappyPathMapping.json");
assertNotNull(mapping);
Mapping fieldMapping = (Mapping) mapping.getMappings().getMapping().get(0);
JsonField in = (JsonField) fieldMapping.getInputField().get(0);
in.setPath(null);
validations.addAll(sourceValidationService.validateMapping(mapping));
validations.addAll(targetValidationService.validateMapping(mapping));
assertTrue(validationHelper.hasErrors());
assertFalse(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
}
use of io.atlasmap.v2.Mappings in project atlasmap by atlasmap.
the class JavaJavaComplexListTest method testGenerateListMappingBasic.
@Test
public void testGenerateListMappingBasic() throws Exception {
AtlasMapping a = AtlasModelFactory.createAtlasMapping();
a.setName("JavaJavaComplexListBase");
DataSource s = new DataSource();
s.setDataSourceType(DataSourceType.SOURCE);
s.setUri("atlas:java?className=io.atlasmap.java.test.SourceOrderList");
DataSource t = new DataSource();
t.setDataSourceType(DataSourceType.TARGET);
t.setUri("atlas:java?className=io.atlasmap.java.test.TargetOrderList");
JavaField f1 = AtlasJavaModelFactory.createJavaField();
f1.setPath("/numberOrders");
f1.setModifiers(null);
JavaField f2 = AtlasJavaModelFactory.createJavaField();
f2.setPath("/orderBatchNumber");
f2.setModifiers(null);
Mapping m1 = AtlasModelFactory.createMapping(MappingType.MAP);
m1.getInputField().add(f1);
m1.getOutputField().add(f1);
Mapping m2 = AtlasModelFactory.createMapping(MappingType.MAP);
m2.getInputField().add(f2);
m2.getOutputField().add(f2);
JavaCollection cm = new JavaCollection();
cm.setMappingType(MappingType.COLLECTION);
cm.setCollectionType(CollectionType.LIST);
JavaField f3 = AtlasJavaModelFactory.createJavaField();
f3.setPath("/orders<>/orderId");
f3.setModifiers(null);
Mapping m3 = AtlasModelFactory.createMapping(MappingType.MAP);
m3.getInputField().add(f3);
m3.getOutputField().add(f3);
if (cm.getMappings() == null) {
cm.setMappings(new Mappings());
}
cm.getMappings().getMapping().add(m3);
a.getDataSource().addAll(Arrays.asList(s, t));
a.getMappings().getMapping().addAll(Arrays.asList(m1, m2, cm));
File path = new File("target/reference-mappings/javaToJava");
path.mkdirs();
Json.mapper().writeValue(new File(path, "atlasmapping-complex-list-autodetect-base.xml"), a);
}
use of io.atlasmap.v2.Mappings in project atlasmap by atlasmap.
the class JavaJavaFlatMappingTest method testCreateJavaJavaFlatFieldMapping.
@Test
public void testCreateJavaJavaFlatFieldMapping() throws Exception {
AtlasMapping atlasMapping = generateJavaJavaFlatMapping();
File path = new File("target/reference-mappings/javaToJava");
path.mkdirs();
Json.mapper().writeValue(new File(path, "atlasmapping-flatprimitive.json"), atlasMapping);
}
use of io.atlasmap.v2.Mappings in project atlasmap by atlasmap.
the class JsonJavaFlatMappingTest method testCreateJsonJavaFlatFieldMappings.
@Test
public void testCreateJsonJavaFlatFieldMappings() throws Exception {
AtlasMapping atlasMapping = generateJsonJavaFlatMapping();
File path = new File("target/reference-mappings/jsonToJava");
path.mkdirs();
Json.mapper().writeValue(new File(path, "atlasmapping-flatprimitive.xml"), atlasMapping);
}
use of io.atlasmap.v2.Mappings in project atlasmap by atlasmap.
the class JsonJavaFlatMappingTest method generateJsonJavaFlatMapping.
protected AtlasMapping generateJsonJavaFlatMapping() {
AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
atlasMapping.setName("JsonJavaFlatMapping");
atlasMapping.getDataSource().add(generateDataSource("atlas:json", 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(generateJsonField("/" + fieldName));
mfm.getOutputField().add(generateJavaField("/" + fieldName));
mappings.add(mfm);
}
return atlasMapping;
}
Aggregations