use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class BaseModuleValidationService method validateMapping.
@Override
public List<Validation> validateMapping(AtlasMapping mapping) {
List<Validation> validations = new ArrayList<>();
if (getMode() == AtlasModuleMode.UNSET) {
Validation validation = new Validation();
validation.setMessage(String.format("No mode specified for %s/%s, skipping module validations", this.getModuleDetail().name(), this.getClass().getSimpleName()));
}
if (mapping != null && mapping.getMappings() != null && mapping.getMappings().getMapping() != null && !mapping.getMappings().getMapping().isEmpty()) {
validateMappingEntries(mapping.getMappings().getMapping(), validations);
}
boolean found = false;
for (DataSource ds : mapping.getDataSource()) {
if (ds.getUri() != null && ds.getUri().startsWith(getModuleDetail().uri())) {
found = true;
break;
}
}
if (!found) {
Validation validation = new Validation();
validation.setScope(ValidationScope.DATA_SOURCE);
validation.setMessage(String.format("No DataSource with '%s' uri specified", getModuleDetail().uri()));
validation.setStatus(ValidationStatus.ERROR);
validations.add(validation);
}
return validations;
}
use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class BaseModuleValidationService method validateMapMapping.
protected void validateMapMapping(Mapping mapping, List<Validation> validations) {
Field sourceField = null;
Field targetField = null;
String mappingId = mapping.getId();
if (mapping != null && mapping.getInputField() != null && mapping.getInputField().size() > 0) {
sourceField = mapping.getInputField().get(0);
if (getMode() == AtlasModuleMode.SOURCE && matchDocIdOrNull(sourceField.getDocId())) {
validateField(mappingId, sourceField, FieldDirection.SOURCE, validations);
}
}
if (mapping != null && mapping.getOutputField() != null && mapping.getOutputField().size() > 0) {
targetField = mapping.getOutputField().get(0);
if (getMode() == AtlasModuleMode.TARGET && matchDocIdOrNull(targetField.getDocId())) {
validateField(mappingId, targetField, FieldDirection.TARGET, validations);
}
}
if (sourceField != null && targetField != null && getMode() == AtlasModuleMode.SOURCE && matchDocIdOrNull(sourceField.getDocId())) {
// FIXME Run only for SOURCE to avoid duplicate validation...
// we should convert per module validations to plugin style
validateSourceAndTargetTypes(mappingId, sourceField, targetField, validations);
}
}
use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class AtlasCoreValidationTest method testJavaToXml.
@Test
public void testJavaToXml() throws AtlasException {
assertNotNull(context);
assertNotNull(session);
context.processValidation(session);
Validations validations = session.getValidations();
assertNotNull(validations);
assertNotNull(validations.getValidation());
assertTrue(validations.getValidation().isEmpty());
}
use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class AtlasCoreValidationTest method testMappingNameNull.
@Test
public void testMappingNameNull() throws AtlasException {
assertNotNull(context);
assertNotNull(session);
context.processValidation(session);
Validations validations = session.getValidations();
assertNotNull(validations);
assertNotNull(validations.getValidation());
assertFalse(validations.getValidation().isEmpty());
boolean found = false;
for (Validation v : validations.getValidation()) {
if ("Mapping name must not be null nor empty".equals(v.getMessage())) {
found = true;
assertEquals(ValidationStatus.ERROR, v.getStatus());
assertEquals(ValidationScope.ALL, v.getScope());
}
System.out.println(AtlasValidationTestHelper.validationToString(v));
}
assertTrue(found);
}
use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class AtlasCoreValidationTest method testXmlToJson.
@Test
public void testXmlToJson() throws AtlasException {
assertNotNull(context);
assertNotNull(session);
context.processValidation(session);
Validations validations = session.getValidations();
assertNotNull(validations);
assertNotNull(validations.getValidation());
assertTrue(validations.getValidation().isEmpty());
}
Aggregations