use of io.atlasmap.v2.Validations 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.Validations in project atlasmap by atlasmap.
the class LookupTableNameValidatorTest method testValidateNoDuplicateNames.
@Test
public void testValidateNoDuplicateNames() {
LookupTables lookupTables = makeLookupTables();
lookupTables.getLookupTable().remove(2);
validator.validate(lookupTables, validations, null);
assertFalse(validationHelper.hasErrors());
}
use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class StringLengthValidatorTest method testValidateInvalid.
@Test
public void testValidateInvalid() {
String pass = "";
validator.validate(pass, validations, "testValidateInvalid");
assertTrue(validationHelper.hasErrors());
assertEquals(new Integer(1), new Integer(validationHelper.getAllValidations().size()));
Validation validation = validations.get(0);
assertNotNull(validation);
assertEquals(ValidationScope.MAPPING, validation.getScope());
assertEquals("testValidateInvalid", validation.getId());
assertTrue("Must be of this length".equals(validation.getMessage()));
}
use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class JsonValidationServiceTest 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);
JsonField in = (JsonField) fieldMapping.getInputField().get(0);
in.setFieldType(FieldType.DOUBLE);
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(1, is(validationHelper.getCount()));
assertTrue(validations.stream().anyMatch(atlasMappingError -> atlasMappingError.getMessage().contains("range")));
}
use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class JsonValidationServiceTest method testValidateMappingSupportedSourceToTargetConversion.
@Test
public void testValidateMappingSupportedSourceToTargetConversion() 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.CHAR);
validations.addAll(sourceValidationService.validateMapping(mapping));
validations.addAll(targetValidationService.validateMapping(mapping));
if (LOG.isDebugEnabled()) {
debugErrors(validations);
}
assertFalse(validationHelper.hasErrors());
assertFalse(validationHelper.hasWarnings());
assertTrue(validationHelper.hasInfos());
}
Aggregations