use of io.atlasmap.v2.AtlasMapping 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());
}
use of io.atlasmap.v2.AtlasMapping 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.AtlasMapping 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());
}
use of io.atlasmap.v2.AtlasMapping in project atlasmap by atlasmap.
the class JsonValidationServiceTest 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);
JsonField in = (JsonField) fieldMapping.getInputField().get(0);
in.setFieldType(FieldType.STRING);
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(2, is(validationHelper.getCount()));
assertTrue(validations.stream().anyMatch(atlasMappingError -> atlasMappingError.getMessage().contains("range")));
assertTrue(validations.stream().anyMatch(atlasMappingError -> atlasMappingError.getMessage().contains("format")));
}
use of io.atlasmap.v2.AtlasMapping in project atlasmap by atlasmap.
the class JsonModule method processPreValidation.
@Override
public void processPreValidation(AtlasInternalSession atlasSession) throws AtlasException {
if (atlasSession == null || atlasSession.getMapping() == null) {
throw new AtlasValidationException("Invalid session: Session and AtlasMapping must be specified");
}
Validations validations = atlasSession.getValidations();
JsonValidationService jsonValidationService = new JsonValidationService(getConversionService());
jsonValidationService.setDocId(getDocId());
List<Validation> jsonValidations = jsonValidationService.validateMapping(atlasSession.getMapping());
if (jsonValidations != null && !jsonValidations.isEmpty()) {
validations.getValidation().addAll(jsonValidations);
}
if (LOG.isDebugEnabled()) {
LOG.debug("Detected " + jsonValidations.size() + " json validation notices");
}
if (LOG.isDebugEnabled()) {
LOG.debug("{}: processPreValidation completed", getDocId());
}
}
Aggregations