use of io.atlasmap.v2.Validation in project atlasmap by atlasmap.
the class JavaValidationServiceTest method testValidateMappingInvalidSeparateSourceFieldType.
@Test
public void testValidateMappingInvalidSeparateSourceFieldType() {
AtlasMapping atlasMapping = getAtlasMappingFullValid();
Mapping separateFieldMapping = AtlasModelFactory.createMapping(MappingType.SEPARATE);
separateFieldMapping.setId("separate.firstName.lastName");
JavaField bIJavaField = javaModelFactory.createJavaField();
bIJavaField.setFieldType(FieldType.BOOLEAN);
bIJavaField.setValue(Boolean.TRUE);
bIJavaField.setPath("firstName");
separateFieldMapping.getInputField().add(bIJavaField);
JavaField sOJavaField = javaModelFactory.createJavaField();
sOJavaField.setFieldType(FieldType.STRING);
sOJavaField.setPath("lastName");
sOJavaField.setIndex(0);
separateFieldMapping.getOutputField().add(sOJavaField);
atlasMapping.getMappings().getMapping().add(separateFieldMapping);
validations.addAll(sourceValidationService.validateMapping(atlasMapping));
validations.addAll(targetValidationService.validateMapping(atlasMapping));
assertTrue(validationHelper.hasErrors());
assertFalse(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
assertEquals(new Integer(1), new Integer(validationHelper.getCount()));
Validation validation = validations.get(0);
assertNotNull(validation);
assertEquals(ValidationScope.MAPPING, validation.getScope());
assertEquals("separate.firstName.lastName", validation.getId());
assertEquals("Input field 'firstName' must be of type 'STRING' for a Separate Mapping", validation.getMessage());
assertEquals(ValidationStatus.ERROR, validation.getStatus());
}
use of io.atlasmap.v2.Validation in project atlasmap by atlasmap.
the class JavaValidationServiceTest method testValidateMappingInvalidCombineSourceFieldType.
@Test
public void testValidateMappingInvalidCombineSourceFieldType() {
AtlasMapping atlasMapping = getAtlasMappingFullValid();
Mapping combineFieldMapping = AtlasModelFactory.createMapping(MappingType.COMBINE);
combineFieldMapping.setId("combine.firstName.lastName");
JavaField bIJavaField = javaModelFactory.createJavaField();
bIJavaField.setFieldType(FieldType.STRING);
bIJavaField.setValue(Boolean.TRUE);
bIJavaField.setPath("firstName");
combineFieldMapping.getInputField().add(bIJavaField);
JavaField sOJavaField = javaModelFactory.createJavaField();
sOJavaField.setFieldType(FieldType.BOOLEAN);
sOJavaField.setPath("lastName");
sOJavaField.setIndex(0);
combineFieldMapping.getOutputField().add(sOJavaField);
atlasMapping.getMappings().getMapping().add(combineFieldMapping);
validations.addAll(sourceValidationService.validateMapping(atlasMapping));
validations.addAll(targetValidationService.validateMapping(atlasMapping));
assertTrue(validationHelper.hasErrors());
assertFalse(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
assertEquals(new Integer(1), new Integer(validationHelper.getCount()));
Validation validation = validations.get(0);
assertNotNull(validation);
assertEquals(ValidationScope.MAPPING, validation.getScope());
assertEquals("combine.firstName.lastName", validation.getId());
assertEquals("Output field 'lastName' must be of type 'STRING' for a Combine Mapping", validation.getMessage());
assertEquals(ValidationStatus.ERROR, validation.getStatus());
}
use of io.atlasmap.v2.Validation in project atlasmap by atlasmap.
the class JavaValidationServiceTest method testValidateMappingClassNotFound.
@Test
public void testValidateMappingClassNotFound() 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.setClassName("java.lang.String3");
validations.addAll(sourceValidationService.validateMapping(mapping));
validations.addAll(targetValidationService.validateMapping(mapping));
assertTrue(validationHelper.hasErrors());
assertFalse(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
assertEquals(1, validations.size());
Validation v = validations.get(0);
assertEquals(ValidationScope.MAPPING, v.getScope());
assertEquals("map.firstName.firstName", v.getId());
assertEquals(ValidationStatus.ERROR, v.getStatus());
}
use of io.atlasmap.v2.Validation in project atlasmap by atlasmap.
the class NonNullValidatorTest method testValidateInvalid.
@Test
public void testValidateInvalid() {
validator.validate(null, validations, null);
assertTrue(validationHelper.hasErrors());
assertEquals(new Integer(1), new Integer(validationHelper.getCount()));
Validation validation = validationHelper.getAllValidations().get(0);
assertNotNull(validation);
assertTrue("Cannot be null".equals(validation.getMessage()));
assertEquals(ValidationScope.MAPPING, validation.getScope());
assertNull(validation.getId());
String empty = "";
validationHelper.getAllValidations().clear();
validator.validate(empty, validations, "testValidateInvalid-2");
assertTrue(validationHelper.hasErrors());
assertEquals(new Integer(1), new Integer(validationHelper.getCount()));
assertEquals(ValidationScope.MAPPING, validationHelper.getValidation().get(0).getScope());
assertEquals("testValidateInvalid-2", validationHelper.getValidation().get(0).getId());
}
use of io.atlasmap.v2.Validation in project atlasmap by atlasmap.
the class AtlasValidationHelperTest method setUp.
@Before
public void setUp() {
validations = new DefaultAtlasValidationsHelper();
error = new Validation();
error.setScope(ValidationScope.ALL);
error.setMessage("Error message");
error.setStatus(ValidationStatus.ERROR);
validations.addValidation(error);
warning = new Validation();
warning.setScope(ValidationScope.DATA_SOURCE);
warning.setId("atlas:testDataSource");
warning.setMessage("Warning message");
warning.setStatus(ValidationStatus.WARN);
validations.addValidation(warning);
info = new Validation();
info.setScope(ValidationScope.MAPPING);
info.setId("0001");
info.setMessage("Information message");
info.setStatus(ValidationStatus.INFO);
validations.addValidation(info);
atlasValidationHelper = new DefaultAtlasValidationsHelper();
}
Aggregations