Search in sources :

Example 61 with Mappings

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

the class XmlJsonFlatMappingTest method testCreateXmlJsonFlatFieldMapping.

@Test
public void testCreateXmlJsonFlatFieldMapping() throws Exception {
    AtlasMapping atlasMapping = generateXmlJsonFlatMapping();
    File path = new File("target/reference-mappings/xmlToJson");
    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 62 with Mappings

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

the class JsonValidationServiceMultiplicityTest method testHappyPath.

@Test
public void testHappyPath() throws Exception {
    AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/atlasmapping-multiplicity-transformation-concatenate-split.json");
    assertNotNull(mapping);
    validations.addAll(sourceValidationService.validateMapping(mapping));
    validations.addAll(targetValidationService.validateMapping(mapping));
    assertFalse(validationHelper.hasErrors(), validationHelper.allValidationsToString());
    assertFalse(validationHelper.hasWarnings(), validationHelper.allValidationsToString());
    assertFalse(validationHelper.hasInfos(), validationHelper.allValidationsToString());
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) Test(org.junit.jupiter.api.Test)

Example 63 with Mappings

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

the class JsonValidationServiceMultiplicityTest method testCollectionInFieldGroup.

@Test
public void testCollectionInFieldGroup() throws Exception {
    AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/atlasmapping-multiplicity-transformation-concatenate-split.json");
    for (BaseMapping m : mapping.getMappings().getMapping()) {
        Mapping entry = (Mapping) m;
        if ("concatenate-from-field-group".equals(entry.getId())) {
            JsonField f = new JsonField();
            f.setCollectionType(CollectionType.LIST);
            f.setFieldType(FieldType.STRING);
            f.setPath("/sourceStringList<>");
            entry.getInputFieldGroup().getField().add(f);
            break;
        }
    }
    validations.addAll(sourceValidationService.validateMapping(mapping));
    validations.addAll(targetValidationService.validateMapping(mapping));
    assertFalse(validationHelper.hasErrors(), validationHelper.allValidationsToString());
    assertFalse(validationHelper.hasWarnings(), validationHelper.allValidationsToString());
    assertFalse(validationHelper.hasInfos(), validationHelper.allValidationsToString());
    assertEquals(0, validationHelper.getCount());
}
Also used : JsonField(io.atlasmap.json.v2.JsonField) AtlasMapping(io.atlasmap.v2.AtlasMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) BaseMapping(io.atlasmap.v2.BaseMapping) BaseMapping(io.atlasmap.v2.BaseMapping) Test(org.junit.jupiter.api.Test)

Example 64 with Mappings

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

the class JsonValidationServiceMultiplicityTest method testCollectionInTargetFields.

@Test
public void testCollectionInTargetFields() throws Exception {
    AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/atlasmapping-multiplicity-transformation-concatenate-split.json");
    for (BaseMapping m : mapping.getMappings().getMapping()) {
        Mapping entry = (Mapping) m;
        if ("split-into-multiple-fields".equals(entry.getId())) {
            JsonField f = new JsonField();
            f.setCollectionType(CollectionType.LIST);
            f.setFieldType(FieldType.STRING);
            f.setPath("/targetStringList<>");
            entry.getOutputField().add(f);
            break;
        }
    }
    validations.addAll(sourceValidationService.validateMapping(mapping));
    validations.addAll(targetValidationService.validateMapping(mapping));
    assertFalse(validationHelper.hasErrors(), validationHelper.allValidationsToString());
    assertFalse(validationHelper.hasWarnings(), validationHelper.allValidationsToString());
    assertFalse(validationHelper.hasInfos(), validationHelper.allValidationsToString());
    assertEquals(0, validationHelper.getCount());
}
Also used : JsonField(io.atlasmap.json.v2.JsonField) AtlasMapping(io.atlasmap.v2.AtlasMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) BaseMapping(io.atlasmap.v2.BaseMapping) BaseMapping(io.atlasmap.v2.BaseMapping) Test(org.junit.jupiter.api.Test)

Example 65 with Mappings

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

the class JsonValidationServiceTest method testValidateMappingHappyPathFromFile.

@Test
public void testValidateMappingHappyPathFromFile() throws Exception {
    AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/HappyPathMapping.json");
    assertNotNull(mapping);
    validations.addAll(sourceValidationService.validateMapping(mapping));
    validations.addAll(targetValidationService.validateMapping(mapping));
    assertFalse(validationHelper.hasErrors());
    assertFalse(validationHelper.hasWarnings());
    assertFalse(validationHelper.hasInfos());
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) Test(org.junit.jupiter.api.Test)

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