Search in sources :

Example 16 with Validations

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

Example 17 with Validations

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

Example 18 with Validations

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

Example 19 with Validations

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")));
}
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) 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) 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) AtlasJsonModelFactory(io.atlasmap.json.v2.AtlasJsonModelFactory) AtlasMapping(io.atlasmap.v2.AtlasMapping) JsonField(io.atlasmap.json.v2.JsonField) Assert.assertEquals(org.junit.Assert.assertEquals) JsonField(io.atlasmap.json.v2.JsonField) AtlasMapping(io.atlasmap.v2.AtlasMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) Test(org.junit.Test)

Example 20 with Validations

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());
}
Also used : JsonField(io.atlasmap.json.v2.JsonField) AtlasMapping(io.atlasmap.v2.AtlasMapping) 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