use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class JavaValidationService method validateClassConversion.
private void validateClassConversion(String mappingId, JavaField inputField, JavaField outField, List<Validation> validations) {
Optional<AtlasConverter<?>> atlasConverter = getConversionService().findMatchingConverter(inputField.getClassName(), outField.getClassName());
if (!atlasConverter.isPresent()) {
Validation validation = new Validation();
validation.setScope(ValidationScope.MAPPING);
validation.setId(mappingId);
validation.setMessage(String.format("Conversion from '%s' to '%s' is required but no converter is available", inputField.getClassName(), outField.getClassName()));
validation.setStatus(ValidationStatus.WARN);
validations.add(validation);
} else {
AtlasConversionInfo conversionInfo;
// find the method that does the conversion
Method[] methods = atlasConverter.get().getClass().getMethods();
conversionInfo = Arrays.stream(methods).map(method -> method.getAnnotation(AtlasConversionInfo.class)).filter(atlasConversionInfo -> atlasConversionInfo != null).filter(atlasConversionInfo -> atlasConversionInfo.sourceType().compareTo(inputField.getFieldType()) == 0 && atlasConversionInfo.targetType().compareTo(outField.getFieldType()) == 0).findFirst().orElse(null);
if (conversionInfo != null) {
populateConversionConcerns(mappingId, conversionInfo, getFieldName(inputField), getFieldName(outField), validations);
}
}
}
use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class JavaJavaFlatMappingTest method testProcessJavaJavaFlatFieldMappingPrimitivesBoxedValues.
@Test
public void testProcessJavaJavaFlatFieldMappingPrimitivesBoxedValues() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/javaToJava/atlasmapping-flatprimitive.xml").toURI());
AtlasSession session = context.createSession();
BaseFlatPrimitiveClass sourceClass = generateFlatPrimitiveClassPrimitiveFieldsBoxedValues(SourceFlatPrimitiveClass.class);
session.setDefaultSourceDocument(sourceClass);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof TargetFlatPrimitiveClass);
validateFlatPrimitiveClassPrimitiveFields((TargetFlatPrimitiveClass) object);
Validations validations = session.getValidations();
for (Validation v : validations.getValidation()) {
printValidation(v);
}
}
use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class AtlasCoreValidationTest method testJavaToJson.
@Test
public void testJavaToJson() 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 testMappingNameEmpty.
@Test
public void testMappingNameEmpty() 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());
}
}
assertTrue(found);
}
use of io.atlasmap.v2.Validations in project atlasmap by atlasmap.
the class AtlasCoreValidationTest method testJsonToJava.
@Test
public void testJsonToJava() throws AtlasException {
assertNotNull(context);
assertNotNull(session);
context.processValidation(session);
Validations validations = session.getValidations();
assertNotNull(validations);
assertNotNull(validations.getValidation());
assertTrue(validations.getValidation().isEmpty());
}
Aggregations