Search in sources :

Example 1 with AtlasConversionConcern

use of io.atlasmap.spi.AtlasConversionConcern in project atlasmap by atlasmap.

the class BaseModuleValidationService method populateConversionConcerns.

protected void populateConversionConcerns(String mappingId, AtlasConversionInfo converterAnno, String inputFieldName, String outFieldName, List<Validation> validations) {
    if (converterAnno == null || converterAnno.concerns() == null) {
        return;
    }
    for (AtlasConversionConcern atlasConversionConcern : converterAnno.concerns()) {
        String message = atlasConversionConcern.getMessage(converterAnno);
        if (AtlasConversionConcern.NONE.equals(atlasConversionConcern)) {
            Validation validation = new Validation();
            validation.setScope(ValidationScope.MAPPING);
            validation.setId(mappingId);
            validation.setMessage(message);
            validation.setStatus(ValidationStatus.INFO);
            validations.add(validation);
        } else if (atlasConversionConcern.equals(AtlasConversionConcern.RANGE) || atlasConversionConcern.equals(AtlasConversionConcern.FORMAT) || atlasConversionConcern.equals(AtlasConversionConcern.FRACTIONAL_PART) || atlasConversionConcern.equals(AtlasConversionConcern.TIMEZONE)) {
            Validation validation = new Validation();
            validation.setScope(ValidationScope.MAPPING);
            validation.setId(mappingId);
            validation.setMessage(message);
            validation.setStatus(ValidationStatus.WARN);
            validations.add(validation);
        } else if (atlasConversionConcern.equals(AtlasConversionConcern.UNSUPPORTED)) {
            Validation validation = new Validation();
            validation.setScope(ValidationScope.MAPPING);
            validation.setId(mappingId);
            validation.setMessage(message);
            validation.setStatus(ValidationStatus.ERROR);
            validations.add(validation);
        }
    }
}
Also used : Validation(io.atlasmap.v2.Validation) AtlasConversionConcern(io.atlasmap.spi.AtlasConversionConcern)

Example 2 with AtlasConversionConcern

use of io.atlasmap.spi.AtlasConversionConcern in project atlasmap by atlasmap.

the class DoubleConverterTest method checkAnnotations.

@Test
public void checkAnnotations() throws Exception {
    Class<?> aClass = DoubleConverter.class;
    Method[] methods = aClass.getMethods();
    for (Method method : methods) {
        if (method.isSynthetic()) {
            // We are running in Eclipse or jacoco
            continue;
        }
        if (method.getName().startsWith("convert")) {
            Annotation[] annotations = method.getDeclaredAnnotations();
            assertNotNull(annotations);
            assertTrue(annotations.length > 0);
            for (Annotation annotation : annotations) {
                assertTrue(AtlasConversionInfo.class.isAssignableFrom(annotation.annotationType()));
                AtlasConversionInfo atlasConversionInfo = (AtlasConversionInfo) annotation;
                assertNotNull(atlasConversionInfo.sourceType());
                assertTrue(atlasConversionInfo.sourceType().compareTo(FieldType.DOUBLE) == 0);
                assertNotNull(atlasConversionInfo.targetType());
                for (AtlasConversionConcern atlasConversionConcern : atlasConversionInfo.concerns()) {
                    assertNotNull(atlasConversionConcern.getMessage(atlasConversionInfo));
                    assertNotNull(atlasConversionConcern.value());
                }
            }
        }
    }
}
Also used : AtlasConversionInfo(io.atlasmap.spi.AtlasConversionInfo) AtlasConversionConcern(io.atlasmap.spi.AtlasConversionConcern) Method(java.lang.reflect.Method) Annotation(java.lang.annotation.Annotation) Test(org.junit.Test)

Example 3 with AtlasConversionConcern

use of io.atlasmap.spi.AtlasConversionConcern in project atlasmap by atlasmap.

the class FloatConverterTest method checkAnnotations.

@Test
public void checkAnnotations() throws Exception {
    Class<?> aClass = FloatConverter.class;
    Method[] methods = aClass.getMethods();
    for (Method method : methods) {
        if (method.isSynthetic()) {
            // We are running in Eclipse or jacoco
            continue;
        }
        if (method.getName().startsWith("convert")) {
            Annotation[] annotations = method.getDeclaredAnnotations();
            assertNotNull(annotations);
            assertTrue(annotations.length > 0);
            for (Annotation annotation : annotations) {
                assertTrue(AtlasConversionInfo.class.isAssignableFrom(annotation.annotationType()));
                AtlasConversionInfo atlasConversionInfo = (AtlasConversionInfo) annotation;
                assertNotNull(atlasConversionInfo.sourceType());
                assertTrue(atlasConversionInfo.sourceType().compareTo(FieldType.FLOAT) == 0);
                assertNotNull(atlasConversionInfo.targetType());
                for (AtlasConversionConcern atlasConversionConcern : atlasConversionInfo.concerns()) {
                    assertNotNull(atlasConversionConcern.getMessage(atlasConversionInfo));
                    assertNotNull(atlasConversionConcern.value());
                }
            }
        }
    }
}
Also used : AtlasConversionInfo(io.atlasmap.spi.AtlasConversionInfo) AtlasConversionConcern(io.atlasmap.spi.AtlasConversionConcern) Method(java.lang.reflect.Method) Annotation(java.lang.annotation.Annotation) Test(org.junit.Test)

Example 4 with AtlasConversionConcern

use of io.atlasmap.spi.AtlasConversionConcern in project atlasmap by atlasmap.

the class BooleanConverterTest method checkAnnotations.

@Test
public void checkAnnotations() throws Exception {
    Class<?> aClass = BooleanConverter.class;
    Method[] methods = aClass.getMethods();
    for (Method method : methods) {
        if (method.isSynthetic()) {
            // We are running in Eclipse or jacoco
            continue;
        }
        if (method.getName().startsWith("convert")) {
            Annotation[] annotations = method.getDeclaredAnnotations();
            assertNotNull(annotations);
            assertTrue(annotations.length > 0);
            for (Annotation annotation : annotations) {
                assertTrue(AtlasConversionInfo.class.isAssignableFrom(annotation.annotationType()));
                AtlasConversionInfo atlasConversionInfo = (AtlasConversionInfo) annotation;
                assertNotNull(atlasConversionInfo.sourceType());
                assertTrue(atlasConversionInfo.sourceType().compareTo(FieldType.BOOLEAN) == 0);
                assertNotNull(atlasConversionInfo.targetType());
                for (AtlasConversionConcern atlasConversionConcern : atlasConversionInfo.concerns()) {
                    assertNotNull(atlasConversionConcern.getMessage(atlasConversionInfo));
                    assertNotNull(atlasConversionConcern.value());
                }
            }
        }
    }
}
Also used : AtlasConversionInfo(io.atlasmap.spi.AtlasConversionInfo) AtlasConversionConcern(io.atlasmap.spi.AtlasConversionConcern) Method(java.lang.reflect.Method) Annotation(java.lang.annotation.Annotation) Test(org.junit.Test)

Example 5 with AtlasConversionConcern

use of io.atlasmap.spi.AtlasConversionConcern in project atlasmap by atlasmap.

the class ByteConverterTest method checkAnnotations.

@Test
public void checkAnnotations() throws Exception {
    Class<?> aClass = ByteConverter.class;
    Method[] methods = aClass.getMethods();
    for (Method method : methods) {
        if (method.isSynthetic()) {
            // We are running in Eclipse or jacoco
            continue;
        }
        if (method.getName().startsWith("convert")) {
            Annotation[] annotations = method.getDeclaredAnnotations();
            assertNotNull(annotations);
            assertTrue(annotations.length > 0);
            for (Annotation annotation : annotations) {
                assertTrue(AtlasConversionInfo.class.isAssignableFrom(annotation.annotationType()));
                AtlasConversionInfo atlasConversionInfo = (AtlasConversionInfo) annotation;
                assertNotNull(atlasConversionInfo.sourceType());
                assertTrue(atlasConversionInfo.sourceType().compareTo(FieldType.BYTE) == 0);
                assertNotNull(atlasConversionInfo.targetType());
                for (AtlasConversionConcern atlasConversionConcern : atlasConversionInfo.concerns()) {
                    assertNotNull(atlasConversionConcern.getMessage(atlasConversionInfo));
                    assertNotNull(atlasConversionConcern.value());
                }
            }
        }
    }
}
Also used : AtlasConversionInfo(io.atlasmap.spi.AtlasConversionInfo) AtlasConversionConcern(io.atlasmap.spi.AtlasConversionConcern) Method(java.lang.reflect.Method) Annotation(java.lang.annotation.Annotation) Test(org.junit.Test)

Aggregations

AtlasConversionConcern (io.atlasmap.spi.AtlasConversionConcern)10 AtlasConversionInfo (io.atlasmap.spi.AtlasConversionInfo)9 Annotation (java.lang.annotation.Annotation)9 Method (java.lang.reflect.Method)9 Test (org.junit.Test)9 Validation (io.atlasmap.v2.Validation)1