use of io.atlasmap.v2.Validations 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.Validations 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();
}
use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class LookupTableNameValidatorTest method testValidateDuplicatedNames.
@Test
public void testValidateDuplicatedNames() {
LookupTables lookupTables = makeLookupTables();
validator.validate(lookupTables, validations, null);
assertTrue(validationHelper.hasErrors());
assertEquals(ValidationScope.LOOKUP_TABLE, validationHelper.getValidation().get(0).getScope());
assertNull(validationHelper.getValidation().get(0).getId());
debugErrors(validationHelper);
}
use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class DefaultAtlasSessionTest method testGetSetValidations.
@Test
public void testGetSetValidations() {
assertNotNull(session.getValidations());
assertNotNull(session.getValidations().getValidation());
assertTrue(session.getValidations().getValidation().size() == 0);
Validations validations = new Validations();
Validation validation = new Validation();
validation.setScope(ValidationScope.MAPPING);
validation.setId("bar");
validations.getValidation().add(validation);
session.setValidations(validations);
assertNotNull(session.getValidations());
assertNotNull(session.getValidations().getValidation());
assertTrue(session.getValidations().getValidation().size() == 1);
}
use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class XmlValidationServiceTest 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);
XmlField in = (XmlField) fieldMapping.getInputField().get(0);
in.setFieldType(FieldType.STRING);
XmlField out = (XmlField) 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")));
}
Aggregations