use of io.atlasmap.v2.AtlasMapping in project atlasmap by atlasmap.
the class JsonValidationServiceTest method getAtlasMappingFullValid.
protected AtlasMapping getAtlasMappingFullValid() {
AtlasMapping mapping = AtlasModelFactory.createAtlasMapping();
mapping.setName("thisis_a_valid.name");
mapping.getDataSource().add(generateDataSource("atlas:json:MockJson", DataSourceType.SOURCE));
mapping.getDataSource().add(generateDataSource("atlas:json:MockJson", DataSourceType.TARGET));
Mapping mapMapping = AtlasModelFactory.createMapping(MappingType.MAP);
Mapping sepMapping = AtlasModelFactory.createMapping(MappingType.SEPARATE);
Mapping combineMapping = AtlasModelFactory.createMapping(MappingType.COMBINE);
// MappedField
JsonField inputField = AtlasJsonModelFactory.createJsonField();
inputField.setFieldType(FieldType.STRING);
inputField.setPath("firstName");
JsonField outputField = AtlasJsonModelFactory.createJsonField();
outputField.setFieldType(FieldType.STRING);
outputField.setPath("firstName");
mapMapping.getInputField().add(inputField);
mapMapping.getOutputField().add(outputField);
JsonField sIJavaField = AtlasJsonModelFactory.createJsonField();
sIJavaField.setFieldType(FieldType.STRING);
sIJavaField.setPath("displayName");
sepMapping.getInputField().add(sIJavaField);
JsonField sOJavaField = AtlasJsonModelFactory.createJsonField();
sOJavaField.setFieldType(FieldType.STRING);
sOJavaField.setPath("lastName");
sOJavaField.setIndex(1);
sepMapping.getOutputField().add(sOJavaField);
JsonField cIJavaField = AtlasJsonModelFactory.createJsonField();
cIJavaField.setFieldType(FieldType.STRING);
cIJavaField.setPath("displayName");
combineMapping.getInputField().add(cIJavaField);
JsonField cOJavaField = AtlasJsonModelFactory.createJsonField();
cOJavaField.setFieldType(FieldType.STRING);
cOJavaField.setPath("lastName");
cOJavaField.setIndex(1);
combineMapping.getOutputField().add(cOJavaField);
mapping.getMappings().getMapping().add(mapMapping);
mapping.getMappings().getMapping().add(sepMapping);
mapping.getMappings().getMapping().add(combineMapping);
return mapping;
}
use of io.atlasmap.v2.AtlasMapping in project atlasmap by atlasmap.
the class JsonValidationServiceTest method testValidateMappingHappyPath.
// @Test
// @Ignore // Note: manual utility to assist in creating files
// public void saveSampleFile() throws Exception {
// AtlasMappingUtil util = new
// AtlasMappingUtil("io.atlasmap.v2:io.atlasmap.java.v2");
//
// AtlasMapping mapping = getAtlasMappingFullValid();
// util.marshallMapping(mapping,
// "src/test/resources/mappings/HappyPathMapping.xml");
//
// mapping = getAtlasMappingFullValid();
// mapping.getMappings().getMapping().clear();
// mapping.getMappings().getMapping().add(createMockMapping());
// mappingUtil.marshallMapping(mapping,
// "src/test/resources/mappings/MisMatchedFieldTypes.xml");
//
// }
@Test
public void testValidateMappingHappyPath() {
AtlasMapping mapping = getAtlasMappingFullValid();
assertNotNull(mapping);
validations.addAll(sourceValidationService.validateMapping(mapping));
validations.addAll(targetValidationService.validateMapping(mapping));
assertFalse(validationHelper.hasErrors());
assertFalse(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
}
use of io.atlasmap.v2.AtlasMapping in project atlasmap by atlasmap.
the class JsonValidationServiceTest method testValidateMappingInvalidModuleType.
@Test
public void testValidateMappingInvalidModuleType() {
AtlasMapping mapping = AtlasModelFactory.createAtlasMapping();
mapping.setName("thisis_a_valid.name");
mapping.getDataSource().add(generateDataSource("atlas:xml", DataSourceType.SOURCE));
mapping.getDataSource().add(generateDataSource("atlas:xml", DataSourceType.TARGET));
validations.addAll(sourceValidationService.validateMapping(mapping));
validations.addAll(targetValidationService.validateMapping(mapping));
assertTrue(validationHelper.hasErrors());
assertFalse(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
}
use of io.atlasmap.v2.AtlasMapping in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateAtlasMapping.
protected AtlasMapping generateAtlasMapping() {
AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
atlasMapping.setName("junit");
generateDataSource(atlasMapping);
generateLookupTables(atlasMapping);
generateMapping(atlasMapping);
generateProperties(atlasMapping);
return atlasMapping;
}
use of io.atlasmap.v2.AtlasMapping in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateProperties.
private void generateProperties(AtlasMapping atlasMapping) {
Property p = new Property();
p.setName("foo");
p.setValue("bar");
p.setFieldType(FieldType.INTEGER);
atlasMapping.setProperties(new Properties());
atlasMapping.getProperties().getProperty().add(p);
}
Aggregations