use of io.atlasmap.v2.Mappings in project atlasmap by atlasmap.
the class JavaValidationServiceTest method testValidateAtlasMappingFileConversionRequired.
@Test
public void testValidateAtlasMappingFileConversionRequired() throws Exception {
AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/HappyPathMapping.xml");
assertNotNull(mapping);
Mapping fieldMapping = (Mapping) mapping.getMappings().getMapping().get(0);
JavaField in = (JavaField) fieldMapping.getInputField().get(0);
in.setFieldType(FieldType.COMPLEX);
in.setClassName("io.atlasmap.java.module.MockJavaClass");
JavaField out = (JavaField) fieldMapping.getOutputField().get(0);
out.setFieldType(FieldType.STRING);
validations.addAll(sourceValidationService.validateMapping(mapping));
validations.addAll(targetValidationService.validateMapping(mapping));
assertFalse(validationHelper.hasErrors());
assertTrue(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
assertThat(1, is(validationHelper.getCount()));
Validation v = validations.get(0);
assertEquals(ValidationScope.MAPPING, v.getScope());
assertEquals("map.firstName.firstName", v.getId());
assertEquals(ValidationStatus.WARN, v.getStatus());
}
use of io.atlasmap.v2.Mappings in project atlasmap by atlasmap.
the class JavaValidationServiceTest method testValidateMappingPathNull.
@Test
public void testValidateMappingPathNull() throws Exception {
AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/HappyPathMapping.xml");
assertNotNull(mapping);
Mapping fieldMapping = (Mapping) mapping.getMappings().getMapping().get(0);
JavaField in = (JavaField) 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 JavaValidationServiceTest method testIssue127.
@Test
public void testIssue127() throws Exception {
AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/Issue127Mapping.xml");
assertNotNull(mapping);
validations.addAll(sourceValidationService.validateMapping(mapping));
validations.addAll(targetValidationService.validateMapping(mapping));
assertFalse(validationHelper.hasErrors());
assertTrue(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
assertEquals(2, validations.size());
Validation v = validations.get(0);
assertEquals(ValidationScope.MAPPING, v.getScope());
assertEquals("issue127-1", v.getId());
assertEquals("Conversion from 'STRING' to 'INTEGER' can cause numeric format exceptions", v.getMessage());
assertEquals(ValidationStatus.WARN, v.getStatus());
v = validations.get(1);
assertEquals(ValidationScope.MAPPING, v.getScope());
assertEquals("issue127-1", v.getId());
assertEquals("Conversion from 'STRING' to 'INTEGER' can cause out of range exceptions", v.getMessage());
assertEquals(ValidationStatus.WARN, v.getStatus());
}
use of io.atlasmap.v2.Mappings in project atlasmap by atlasmap.
the class JavaValidationServiceTest method testValidateMappingHappyPathFromFile.
@Test
public void testValidateMappingHappyPathFromFile() throws Exception {
AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/HappyPathMapping.xml");
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 JavaValidationServiceTest method testValidateMappingSourceToTargetRangeConcerns.
@Test
public void testValidateMappingSourceToTargetRangeConcerns() throws Exception {
AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/HappyPathMapping.xml");
assertNotNull(mapping);
Mapping fieldMapping = (Mapping) mapping.getMappings().getMapping().get(0);
JavaField in = (JavaField) fieldMapping.getInputField().get(0);
in.setFieldType(FieldType.DOUBLE);
in.setClassName("java.lang.Double");
JavaField out = (JavaField) fieldMapping.getOutputField().get(0);
out.setFieldType(FieldType.LONG);
out.setClassName("java.lang.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(1, is(validationHelper.getCount()));
assertTrue(validations.stream().anyMatch(atlasMappingError -> atlasMappingError.getMessage().contains("range")));
}
Aggregations