use of io.atlasmap.v2.Mappings in project atlasmap by atlasmap.
the class JsonValidationServiceTest method testValidateMappingSourceToTargetFormatConcerns.
@Test
public void testValidateMappingSourceToTargetFormatConcerns() throws Exception {
AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/HappyPathMapping.xml");
assertNotNull(mapping);
Mapping fieldMapping = (Mapping) mapping.getMappings().getMapping().get(0);
JsonField in = (JsonField) fieldMapping.getInputField().get(0);
in.setFieldType(FieldType.STRING);
JsonField out = (JsonField) fieldMapping.getOutputField().get(0);
out.setFieldType(FieldType.LONG);
validations.addAll(sourceValidationService.validateMapping(mapping));
validations.addAll(targetValidationService.validateMapping(mapping));
if (LOG.isDebugEnabled()) {
debugErrors(validations);
}
assertFalse(validationHelper.hasErrors());
assertTrue(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
assertThat(2, is(validationHelper.getCount()));
assertTrue(validations.stream().anyMatch(atlasMappingError -> atlasMappingError.getMessage().contains("range")));
assertTrue(validations.stream().anyMatch(atlasMappingError -> atlasMappingError.getMessage().contains("format")));
}
use of io.atlasmap.v2.Mappings 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.Mappings in project atlasmap by atlasmap.
the class AtlasModuleSupportTest method testListTargetPathsListOfBaseMapping.
@Test
public void testListTargetPathsListOfBaseMapping() {
List<BaseMapping> mappings = null;
assertEquals(0, AtlasModuleSupport.listTargetPaths(mappings).size());
mappings = new ArrayList<>();
assertEquals(0, AtlasModuleSupport.listTargetPaths(mappings).size());
Mapping mapping = new Mapping();
Field field = new MockField();
field.setPath("MockPath");
mapping.getOutputField().add(field);
mappings.add(mapping);
assertEquals(1, AtlasModuleSupport.listTargetPaths(mappings).size());
Collection collection = null;
mappings.add(collection);
assertEquals(1, AtlasModuleSupport.listTargetPaths(mappings).size());
collection = new Collection();
mappings.add(collection);
assertEquals(1, AtlasModuleSupport.listTargetPaths(mappings).size());
Mappings mapings = new Mappings();
collection.setMappings(mapings);
assertEquals(1, AtlasModuleSupport.listTargetPaths(mappings).size());
}
use of io.atlasmap.v2.Mappings in project atlasmap by atlasmap.
the class AtlasModuleSupportTest method testListTargetPathsAtlasMapping.
@Test
public void testListTargetPathsAtlasMapping() {
AtlasMapping atlasMapping = null;
assertEquals(0, AtlasModuleSupport.listTargetPaths(atlasMapping).size());
atlasMapping = new AtlasMapping();
assertEquals(0, AtlasModuleSupport.listTargetPaths(atlasMapping).size());
Mappings mappings = new Mappings();
atlasMapping.setMappings(mappings);
assertEquals(0, AtlasModuleSupport.listTargetPaths(atlasMapping).size());
Mapping mapping = new Mapping();
mappings.getMapping().add(mapping);
assertEquals(0, AtlasModuleSupport.listTargetPaths(atlasMapping).size());
class MockMapping extends Mappings {
private static final long serialVersionUID = 1L;
@Override
public List<BaseMapping> getMapping() {
return null;
}
}
Mappings mockMapping = new MockMapping();
atlasMapping.setMappings(mockMapping);
assertEquals(0, AtlasModuleSupport.listTargetPaths(atlasMapping).size());
}
use of io.atlasmap.v2.Mappings in project atlasmap by atlasmap.
the class AtlasMappingServiceTest method setUpBeforeClass.
@BeforeClass
public static void setUpBeforeClass() {
atlasMappingService = new AtlasMappingService();
atlasMapping = new AtlasMapping();
atlasMapping.setName("testname");
Mappings mappings = new Mappings();
Mapping mapping = new Mapping();
mapping.setId("1");
mapping.setAlias("alias1");
mappings.getMapping().add(mapping);
mapping = new Mapping();
mapping.setId("2");
mapping.setAlias("alias2");
mappings.getMapping().add(mapping);
atlasMapping.setMappings(mappings);
}
Aggregations