Search in sources :

Example 86 with AtlasMapping

use of io.atlasmap.v2.AtlasMapping 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 AtlasMapping

use of io.atlasmap.v2.AtlasMapping 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 AtlasMapping

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

the class BaseMarshallerTest method generateLookupTables.

private void generateLookupTables(AtlasMapping atlasMapping) {
    LookupTable table = new LookupTable();
    table.setName("lookupTable");
    table.setDescription("lookupTableDescription");
    LookupEntry l1 = new LookupEntry();
    l1.setSourceType(FieldType.STRING);
    l1.setSourceValue("Foo");
    l1.setTargetType(FieldType.STRING);
    l1.setTargetValue("Bar");
    table.getLookupEntry().add(l1);
    atlasMapping.getLookupTables().getLookupTable().add(table);
}
Also used : LookupEntry(io.atlasmap.v2.LookupEntry) LookupTable(io.atlasmap.v2.LookupTable)

Example 89 with AtlasMapping

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

the class JsonMarshallerTest method testJsonMapJavaField.

@Test
public void testJsonMapJavaField() throws Exception {
    AtlasMapping atlasMapping = generateAtlasMapping();
    // Object to JSON in file
    mapper.writerWithDefaultPrettyPrinter().writeValue(new File("target" + File.separator + "junit" + File.separator + testName.getMethodName() + File.separator + "atlasmapping.json"), atlasMapping);
    AtlasMapping uMapping = mapper.readValue(new File("target" + File.separator + "junit" + File.separator + testName.getMethodName() + File.separator + "atlasmapping.json"), AtlasMapping.class);
    assertNotNull(uMapping);
    validateAtlasMapping(uMapping);
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) File(java.io.File) Test(org.junit.Test)

Example 90 with AtlasMapping

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

the class JsonMarshallerTest method testJsonSeparateJavaField.

@Test
public void testJsonSeparateJavaField() throws Exception {
    AtlasMapping atlasMapping = generateSeparateAtlasMapping();
    // Object to JSON in file
    mapper.writerWithDefaultPrettyPrinter().writeValue(new File("target" + File.separator + "junit" + File.separator + testName.getMethodName() + File.separator + "atlasmapping-separate.json"), atlasMapping);
    AtlasMapping uMapping = mapper.readValue(new File("target" + File.separator + "junit" + File.separator + testName.getMethodName() + File.separator + "atlasmapping-separate.json"), AtlasMapping.class);
    assertNotNull(uMapping);
    validateSeparateAtlasMapping(uMapping);
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) File(java.io.File) Test(org.junit.Test)

Aggregations

AtlasMapping (io.atlasmap.v2.AtlasMapping)131 Test (org.junit.Test)84 Mapping (io.atlasmap.v2.Mapping)62 File (java.io.File)30 DataSource (io.atlasmap.v2.DataSource)21 Validation (io.atlasmap.v2.Validation)20 JavaField (io.atlasmap.java.v2.JavaField)15 MockField (io.atlasmap.v2.MockField)13 Mappings (io.atlasmap.v2.Mappings)10 AtlasContext (io.atlasmap.api.AtlasContext)9 AtlasSession (io.atlasmap.api.AtlasSession)9 Actions (io.atlasmap.v2.Actions)8 BaseMapping (io.atlasmap.v2.BaseMapping)8 LookupTable (io.atlasmap.v2.LookupTable)8 MappingType (io.atlasmap.v2.MappingType)8 BaseValidatorTest (io.atlasmap.validators.BaseValidatorTest)8 List (java.util.List)8 Collectors (java.util.stream.Collectors)8 AtlasMappingUtil (io.atlasmap.core.AtlasMappingUtil)7 DefaultAtlasConversionService (io.atlasmap.core.DefaultAtlasConversionService)7