Search in sources :

Example 86 with Mapping

use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.

the class JavaValidationServiceTest method testValidateMappingClassNotFound.

@Test
public void testValidateMappingClassNotFound() throws Exception {
    AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/HappyPathMapping.xml");
    assertNotNull(mapping);
    Mapping fieldMapping = (Mapping) mapping.getMappings().getMapping().get(0);
    JavaField in = (JavaField) fieldMapping.getInputField().get(0);
    in.setClassName("java.lang.String3");
    validations.addAll(sourceValidationService.validateMapping(mapping));
    validations.addAll(targetValidationService.validateMapping(mapping));
    assertTrue(validationHelper.hasErrors());
    assertFalse(validationHelper.hasWarnings());
    assertFalse(validationHelper.hasInfos());
    assertEquals(1, validations.size());
    Validation v = validations.get(0);
    assertEquals(ValidationScope.MAPPING, v.getScope());
    assertEquals("map.firstName.firstName", v.getId());
    assertEquals(ValidationStatus.ERROR, v.getStatus());
}
Also used : Validation(io.atlasmap.v2.Validation) AtlasMapping(io.atlasmap.v2.AtlasMapping) JavaField(io.atlasmap.java.v2.JavaField) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) Test(org.junit.Test)

Example 87 with Mapping

use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.

the class BaseMarshallerTest method generateCombineMapping.

protected AtlasMapping generateCombineMapping() {
    Actions actions = generateActions();
    StringList annotations = generateAnnotations();
    ModifierList modifierList = generateModifierList();
    StringList parameterizedTypes = generateParameterizedTypes();
    JavaField inputJavaField = generateJavaField(actions, annotations, modifierList, parameterizedTypes);
    JavaField inputJavaFieldB = generateJavaField(actions, annotations, modifierList, parameterizedTypes);
    JavaField outputJavaFieldA = generateJavaField(actions, annotations, modifierList, parameterizedTypes);
    Mapping fm = (Mapping) AtlasModelFactory.createMapping(MappingType.COMBINE);
    fm.getInputField().add(inputJavaField);
    fm.getInputField().add(inputJavaFieldB);
    fm.getOutputField().add(outputJavaFieldA);
    populateMapping(fm, MappingType.COMBINE, "MapPropertyFieldAlias", ",", ",");
    populateMappingString(fm, "description", "id", "lookupTableName", "strategy", "strategyClassName");
    AtlasMapping mapping = generateAtlasMapping();
    mapping.getMappings().getMapping().clear();
    mapping.getMappings().getMapping().add(fm);
    generateProperties(mapping);
    return mapping;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) Actions(io.atlasmap.v2.Actions) StringList(io.atlasmap.v2.StringList) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping)

Example 88 with Mapping

use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.

the class BaseMarshallerTest method generateAtlasMapping.

protected AtlasMapping generateAtlasMapping() {
    AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
    atlasMapping.setName("junit");
    generateDataSource(atlasMapping);
    generateLookupTables(atlasMapping);
    Actions actions = generateActions();
    StringList annotations = generateAnnotations();
    ModifierList modifierList = generateModifierList();
    StringList parameterizedTypes = generateParameterizedTypes();
    JavaField inputField = generateJavaField(actions, annotations, modifierList, parameterizedTypes);
    JavaField outputField = generateJavaField(actions, annotations, modifierList, parameterizedTypes);
    Mapping fm = AtlasModelFactory.createMapping(MappingType.MAP);
    fm.getInputField().add(inputField);
    fm.getOutputField().add(outputField);
    populateMapping(fm, MappingType.MAP, "MapPropertyFieldAlias", ",", ",");
    populateMappingString(fm, "description", "id", "lookupTableName", "strategy", "strategyClassName");
    atlasMapping.getMappings().getMapping().add(fm);
    generateProperties(atlasMapping);
    return atlasMapping;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) Actions(io.atlasmap.v2.Actions) StringList(io.atlasmap.v2.StringList) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping)

Example 89 with Mapping

use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.

the class BaseMarshallerTest method generateCollectionMapping.

protected AtlasMapping generateCollectionMapping() {
    AtlasMapping innerMapping1 = generateAtlasMapping();
    AtlasMapping innerMapping2 = generateAtlasMapping();
    Collection cMapping = (Collection) AtlasModelFactory.createMapping(MappingType.COLLECTION);
    cMapping.setMappings(new Mappings());
    cMapping.getMappings().getMapping().addAll(innerMapping1.getMappings().getMapping());
    cMapping.getMappings().getMapping().addAll(innerMapping2.getMappings().getMapping());
    cMapping.setCollectionType(CollectionType.LIST);
    cMapping.setCollectionSize(new BigInteger("2"));
    cMapping.setAlias("alias");
    cMapping.setDescription("description");
    AtlasMapping mapping = generateAtlasMapping();
    mapping.getMappings().getMapping().clear();
    mapping.getMappings().getMapping().add(cMapping);
    return mapping;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) Mappings(io.atlasmap.v2.Mappings) Collection(io.atlasmap.v2.Collection) BigInteger(java.math.BigInteger)

Example 90 with Mapping

use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.

the class BaseMarshallerTest method generateActionMapping.

protected AtlasMapping generateActionMapping() {
    AtlasMapping mapping = generateAtlasMapping();
    JavaField outputField = (JavaField) ((Mapping) mapping.getMappings().getMapping().get(0)).getOutputField().get(0);
    populateJavaField(outputField, generateAnnotations(), generateModifierList(), generateParameterizedTypes(), Boolean.FALSE, Boolean.TRUE);
    populateJavaFieldString(outputField, "JavaField", "ArrayList", "getMethod", "setMethod", "foo");
    populateFieldComplexObject(outputField, generateActions(), CollectionType.ARRAY, FieldStatus.SUPPORTED, FieldType.INTEGER);
    populateFieldSimpleObject(outputField, 3, "docid", "/path", false, "bar");
    return mapping;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping)

Aggregations

AtlasMapping (io.atlasmap.v2.AtlasMapping)120 Mapping (io.atlasmap.v2.Mapping)83 Test (org.junit.Test)65 BaseMapping (io.atlasmap.v2.BaseMapping)29 Field (io.atlasmap.v2.Field)28 Validation (io.atlasmap.v2.Validation)26 DataSource (io.atlasmap.v2.DataSource)21 JavaField (io.atlasmap.java.v2.JavaField)19 MockField (io.atlasmap.v2.MockField)17 Mappings (io.atlasmap.v2.Mappings)11 SimpleField (io.atlasmap.v2.SimpleField)11 MappingType (io.atlasmap.v2.MappingType)10 PropertyField (io.atlasmap.v2.PropertyField)9 File (java.io.File)9 List (java.util.List)9 Collectors (java.util.stream.Collectors)9 AtlasContext (io.atlasmap.api.AtlasContext)8 AtlasSession (io.atlasmap.api.AtlasSession)8 Actions (io.atlasmap.v2.Actions)8 BaseValidatorTest (io.atlasmap.validators.BaseValidatorTest)8