Search in sources :

Example 36 with Validations

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());
}
Also used : Validation(io.atlasmap.v2.Validation) Test(org.junit.Test)

Example 37 with Validations

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();
}
Also used : Validation(io.atlasmap.v2.Validation) Before(org.junit.Before)

Example 38 with Validations

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);
}
Also used : LookupTables(io.atlasmap.v2.LookupTables) Test(org.junit.Test)

Example 39 with Validations

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);
}
Also used : Validation(io.atlasmap.v2.Validation) Validations(io.atlasmap.v2.Validations) Test(org.junit.Test)

Example 40 with Validations

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")));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) DefaultAtlasConversionService(io.atlasmap.core.DefaultAtlasConversionService) AtlasValidationTestHelper(io.atlasmap.validators.AtlasValidationTestHelper) ValidationScope(io.atlasmap.v2.ValidationScope) LoggerFactory(org.slf4j.LoggerFactory) DataSource(io.atlasmap.v2.DataSource) MappingType(io.atlasmap.v2.MappingType) AtlasXmlModelFactory(io.atlasmap.xml.v2.AtlasXmlModelFactory) FieldType(io.atlasmap.v2.FieldType) Validation(io.atlasmap.v2.Validation) Assert.assertThat(org.junit.Assert.assertThat) AtlasModelFactory(io.atlasmap.v2.AtlasModelFactory) After(org.junit.After) AtlasModuleMode(io.atlasmap.spi.AtlasModuleMode) Collector(java.util.stream.Collector) XmlField(io.atlasmap.xml.v2.XmlField) Before(org.junit.Before) Logger(org.slf4j.Logger) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) ValidationStatus(io.atlasmap.v2.ValidationStatus) Collectors(java.util.stream.Collectors) DataSourceType(io.atlasmap.v2.DataSourceType) AtlasMappingUtil(io.atlasmap.core.AtlasMappingUtil) Mapping(io.atlasmap.v2.Mapping) List(java.util.List) MockField(io.atlasmap.v2.MockField) AtlasModuleDetail(io.atlasmap.spi.AtlasModuleDetail) Assert.assertFalse(org.junit.Assert.assertFalse) AtlasMapping(io.atlasmap.v2.AtlasMapping) Assert.assertEquals(org.junit.Assert.assertEquals) AtlasMapping(io.atlasmap.v2.AtlasMapping) XmlField(io.atlasmap.xml.v2.XmlField) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) Test(org.junit.Test)

Aggregations

Validation (io.atlasmap.v2.Validation)36 Test (org.junit.Test)26 AtlasMapping (io.atlasmap.v2.AtlasMapping)17 Mapping (io.atlasmap.v2.Mapping)17 Validations (io.atlasmap.v2.Validations)15 DataSource (io.atlasmap.v2.DataSource)10 AtlasModuleDetail (io.atlasmap.spi.AtlasModuleDetail)9 FieldType (io.atlasmap.v2.FieldType)9 ValidationScope (io.atlasmap.v2.ValidationScope)9 ValidationStatus (io.atlasmap.v2.ValidationStatus)9 List (java.util.List)9 Before (org.junit.Before)9 AtlasModuleMode (io.atlasmap.spi.AtlasModuleMode)8 Field (io.atlasmap.v2.Field)8 MappingType (io.atlasmap.v2.MappingType)8 AtlasMappingBaseTest (io.atlasmap.validation.AtlasMappingBaseTest)8 Logger (org.slf4j.Logger)8 LoggerFactory (org.slf4j.LoggerFactory)8 AtlasMappingUtil (io.atlasmap.core.AtlasMappingUtil)7 DefaultAtlasConversionService (io.atlasmap.core.DefaultAtlasConversionService)7