Search in sources :

Example 66 with Mappings

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

the class JsonValidationServiceTest method testValidateMappingPathNull.

@Test
public void testValidateMappingPathNull() throws Exception {
    AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/HappyPathMapping.json");
    assertNotNull(mapping);
    Mapping fieldMapping = (Mapping) mapping.getMappings().getMapping().get(0);
    JsonField in = (JsonField) fieldMapping.getInputField().get(0);
    in.setPath(null);
    validations.addAll(sourceValidationService.validateMapping(mapping));
    validations.addAll(targetValidationService.validateMapping(mapping));
    assertTrue(validationHelper.hasErrors());
    assertFalse(validationHelper.hasWarnings());
    assertFalse(validationHelper.hasInfos());
}
Also used : JsonField(io.atlasmap.json.v2.JsonField) AtlasMapping(io.atlasmap.v2.AtlasMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) Test(org.junit.jupiter.api.Test)

Example 67 with Mappings

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

the class JavaJavaComplexListTest method testGenerateListMappingBasic.

@Test
public void testGenerateListMappingBasic() throws Exception {
    AtlasMapping a = AtlasModelFactory.createAtlasMapping();
    a.setName("JavaJavaComplexListBase");
    DataSource s = new DataSource();
    s.setDataSourceType(DataSourceType.SOURCE);
    s.setUri("atlas:java?className=io.atlasmap.java.test.SourceOrderList");
    DataSource t = new DataSource();
    t.setDataSourceType(DataSourceType.TARGET);
    t.setUri("atlas:java?className=io.atlasmap.java.test.TargetOrderList");
    JavaField f1 = AtlasJavaModelFactory.createJavaField();
    f1.setPath("/numberOrders");
    f1.setModifiers(null);
    JavaField f2 = AtlasJavaModelFactory.createJavaField();
    f2.setPath("/orderBatchNumber");
    f2.setModifiers(null);
    Mapping m1 = AtlasModelFactory.createMapping(MappingType.MAP);
    m1.getInputField().add(f1);
    m1.getOutputField().add(f1);
    Mapping m2 = AtlasModelFactory.createMapping(MappingType.MAP);
    m2.getInputField().add(f2);
    m2.getOutputField().add(f2);
    JavaCollection cm = new JavaCollection();
    cm.setMappingType(MappingType.COLLECTION);
    cm.setCollectionType(CollectionType.LIST);
    JavaField f3 = AtlasJavaModelFactory.createJavaField();
    f3.setPath("/orders<>/orderId");
    f3.setModifiers(null);
    Mapping m3 = AtlasModelFactory.createMapping(MappingType.MAP);
    m3.getInputField().add(f3);
    m3.getOutputField().add(f3);
    if (cm.getMappings() == null) {
        cm.setMappings(new Mappings());
    }
    cm.getMappings().getMapping().add(m3);
    a.getDataSource().addAll(Arrays.asList(s, t));
    a.getMappings().getMapping().addAll(Arrays.asList(m1, m2, cm));
    File path = new File("target/reference-mappings/javaToJava");
    path.mkdirs();
    Json.mapper().writeValue(new File(path, "atlasmapping-complex-list-autodetect-base.xml"), a);
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) JavaField(io.atlasmap.java.v2.JavaField) JavaCollection(io.atlasmap.java.v2.JavaCollection) Mappings(io.atlasmap.v2.Mappings) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) File(java.io.File) DataSource(io.atlasmap.v2.DataSource) AtlasMappingBaseTest(io.atlasmap.itests.reference.AtlasMappingBaseTest) Test(org.junit.jupiter.api.Test)

Example 68 with Mappings

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

the class JavaJavaFlatMappingTest method testCreateJavaJavaFlatFieldMapping.

@Test
public void testCreateJavaJavaFlatFieldMapping() throws Exception {
    AtlasMapping atlasMapping = generateJavaJavaFlatMapping();
    File path = new File("target/reference-mappings/javaToJava");
    path.mkdirs();
    Json.mapper().writeValue(new File(path, "atlasmapping-flatprimitive.json"), atlasMapping);
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) File(java.io.File) AtlasMappingBaseTest(io.atlasmap.itests.reference.AtlasMappingBaseTest) Test(org.junit.jupiter.api.Test)

Example 69 with Mappings

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

the class JsonJavaFlatMappingTest method testCreateJsonJavaFlatFieldMappings.

@Test
public void testCreateJsonJavaFlatFieldMappings() throws Exception {
    AtlasMapping atlasMapping = generateJsonJavaFlatMapping();
    File path = new File("target/reference-mappings/jsonToJava");
    path.mkdirs();
    Json.mapper().writeValue(new File(path, "atlasmapping-flatprimitive.xml"), atlasMapping);
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) File(java.io.File) AtlasMappingBaseTest(io.atlasmap.itests.reference.AtlasMappingBaseTest) Test(org.junit.jupiter.api.Test)

Example 70 with Mappings

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

the class JsonJavaFlatMappingTest method generateJsonJavaFlatMapping.

protected AtlasMapping generateJsonJavaFlatMapping() {
    AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
    atlasMapping.setName("JsonJavaFlatMapping");
    atlasMapping.getDataSource().add(generateDataSource("atlas:json", DataSourceType.SOURCE));
    atlasMapping.getDataSource().add(generateDataSource("atlas:java?className=io.atlasmap.java.test.TargetFlatPrimitiveClass", DataSourceType.TARGET));
    List<BaseMapping> mappings = atlasMapping.getMappings().getMapping();
    // Add fieldMappings
    for (String fieldName : FLAT_FIELDS) {
        Mapping mfm = AtlasModelFactory.createMapping(MappingType.MAP);
        mfm.getInputField().add(generateJsonField("/" + fieldName));
        mfm.getOutputField().add(generateJavaField("/" + fieldName));
        mappings.add(mfm);
    }
    return atlasMapping;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) BaseMapping(io.atlasmap.v2.BaseMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) BaseMapping(io.atlasmap.v2.BaseMapping)

Aggregations

AtlasMapping (io.atlasmap.v2.AtlasMapping)86 Mapping (io.atlasmap.v2.Mapping)50 Test (org.junit.jupiter.api.Test)45 BaseMapping (io.atlasmap.v2.BaseMapping)26 File (java.io.File)20 Mappings (io.atlasmap.v2.Mappings)16 Test (org.junit.Test)15 JavaField (io.atlasmap.java.v2.JavaField)14 AtlasContext (io.atlasmap.api.AtlasContext)12 AtlasSession (io.atlasmap.api.AtlasSession)12 DataSource (io.atlasmap.v2.DataSource)12 Validation (io.atlasmap.v2.Validation)11 Field (io.atlasmap.v2.Field)10 JsonField (io.atlasmap.json.v2.JsonField)7 AtlasModelFactory (io.atlasmap.v2.AtlasModelFactory)7 DataSourceType (io.atlasmap.v2.DataSourceType)7 FieldType (io.atlasmap.v2.FieldType)7 MappingType (io.atlasmap.v2.MappingType)7 ProcessMappingResponse (io.atlasmap.v2.ProcessMappingResponse)7 ValidationScope (io.atlasmap.v2.ValidationScope)7