use of io.atlasmap.v2.Validation in project atlasmap by atlasmap.
the class XmlValidationServiceTest method testValidateMappingInvalidSeparateInputFieldType.
@Test
public void testValidateMappingInvalidSeparateInputFieldType() {
AtlasMapping atlasMapping = getAtlasMappingFullValid();
Mapping separateFieldMapping = AtlasModelFactory.createMapping(MappingType.SEPARATE);
separateFieldMapping.setId("separate.firstName.lastName");
XmlField bIJavaField = xmlModelFactory.createXmlField();
bIJavaField.setFieldType(FieldType.BOOLEAN);
bIJavaField.setValue(Boolean.TRUE);
bIJavaField.setPath("firstName");
separateFieldMapping.getInputField().add(bIJavaField);
XmlField sOJavaField = xmlModelFactory.createXmlField();
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 XmlValidationService method validateModuleField.
@Override
protected void validateModuleField(String mappingId, XmlField field, FieldDirection direction, List<Validation> validations) {
// TODO check that it is a valid type on the AtlasContext
validatorMap.get("xml.field.type.not.null").validate(field, validations, mappingId, ValidationStatus.WARN);
if (direction == FieldDirection.SOURCE) {
if (field != null) {
validatorMap.get("input.field.type.not.null").validate(field.getFieldType(), validations, mappingId, ValidationStatus.WARN);
}
} else {
if (field != null) {
validatorMap.get("output.field.type.not.null").validate(field.getFieldType(), validations, mappingId, ValidationStatus.WARN);
}
}
if (field != null) {
if ((field.getName() == null && field.getPath() == null)) {
Validation validation = new Validation();
validation.setScope(ValidationScope.MAPPING);
validation.setId(mappingId);
validation.setMessage("One of path or name must be specified");
validation.setStatus(ValidationStatus.ERROR);
validations.add(validation);
} else if (field.getName() != null && field.getPath() == null) {
validatorMap.get("xml.field.name.not.null").validate(field.getName(), validations, mappingId);
} else if (field.getName() == null && field.getPath() != null) {
validatorMap.get("xml.field.path.not.null").validate(field.getPath(), validations, mappingId);
}
}
}
use of io.atlasmap.v2.Validation in project atlasmap by atlasmap.
the class AtlasValidationTestHelperTest method setUp.
@Before
public void setUp() {
validations = new AtlasValidationTestHelper();
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);
}
use of io.atlasmap.v2.Validation in project atlasmap by atlasmap.
the class DefaultAtlasValidationServiceTest method testValidateAtlasMappingFileHappyPath.
@Test
public void testValidateAtlasMappingFileHappyPath() {
AtlasMapping mapping = getAtlasMappingFullValid();
assertNotNull(mapping);
// validation
validations.addAll(validationService.validateMapping(mapping));
assertFalse(validationHelper.hasErrors());
assertFalse(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
}
use of io.atlasmap.v2.Validation in project atlasmap by atlasmap.
the class DefaultAtlasValidationServiceTest method testValidateAtlasMappingFileHappyPath2.
@Test
public void testValidateAtlasMappingFileHappyPath2() {
AtlasMapping mapping = getAtlasMappingFullValid();
assertNotNull(mapping);
// validation
validations.addAll(validationService.validateMapping(mapping));
assertFalse(validationHelper.hasErrors());
assertFalse(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
}
Aggregations