Search in sources :

Example 46 with AtlasMapping

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

the class AtlasMappingUtil method loadMapping.

public AtlasMapping loadMapping(String fileName) throws Exception {
    AtlasMapping mapping = null;
    if (jaxbContext != null) {
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        Path newFilePath = Paths.get(fileName);
        mapping = (AtlasMapping) ((javax.xml.bind.JAXBElement<?>) unmarshaller.unmarshal(newFilePath.toFile())).getValue();
    }
    return mapping;
}
Also used : Path(java.nio.file.Path) AtlasMapping(io.atlasmap.v2.AtlasMapping) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 47 with AtlasMapping

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

the class AtlasModuleSupportTest method testListTargetPathsAtlasMapping.

@Test
public void testListTargetPathsAtlasMapping() {
    AtlasMapping atlasMapping = null;
    assertEquals(0, AtlasModuleSupport.listTargetPaths(atlasMapping).size());
    atlasMapping = new AtlasMapping();
    assertEquals(0, AtlasModuleSupport.listTargetPaths(atlasMapping).size());
    Mappings mappings = new Mappings();
    atlasMapping.setMappings(mappings);
    assertEquals(0, AtlasModuleSupport.listTargetPaths(atlasMapping).size());
    Mapping mapping = new Mapping();
    mappings.getMapping().add(mapping);
    assertEquals(0, AtlasModuleSupport.listTargetPaths(atlasMapping).size());
    class MockMapping extends Mappings {

        private static final long serialVersionUID = 1L;

        @Override
        public List<BaseMapping> getMapping() {
            return null;
        }
    }
    Mappings mockMapping = new MockMapping();
    atlasMapping.setMappings(mockMapping);
    assertEquals(0, AtlasModuleSupport.listTargetPaths(atlasMapping).size());
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) Mappings(io.atlasmap.v2.Mappings) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) BaseMapping(io.atlasmap.v2.BaseMapping) BaseMapping(io.atlasmap.v2.BaseMapping) Test(org.junit.Test)

Example 48 with AtlasMapping

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

the class AtlasMappingServiceTest method testLoadMappingFileAtlasMappingFormatAtlasValidationException.

@Test(expected = AtlasValidationException.class)
public void testLoadMappingFileAtlasMappingFormatAtlasValidationException() throws AtlasValidationException {
    File file = Paths.get("src" + File.separator + "test" + File.separator + "resources" + File.separator + "atlasmapping2.json").toFile();
    AtlasMapping atlasMapping = atlasMappingService.loadMapping(file, AtlasMappingFormat.JSON);
    assertNotNull(atlasMapping);
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) File(java.io.File) Test(org.junit.Test)

Example 49 with AtlasMapping

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

the class AtlasMappingServiceTest method testLoadMappingString.

@Test
public void testLoadMappingString() throws AtlasValidationException {
    String filename = "src" + File.separator + "test" + File.separator + "resources" + File.separator + "atlasmapping.xml";
    AtlasMapping atlasMapping = atlasMappingService.loadMapping(filename);
    assertNotNull(atlasMapping);
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) Test(org.junit.Test)

Example 50 with AtlasMapping

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

the class AtlasMappingServiceTest method testLoadMappingURI.

@Test
public void testLoadMappingURI() throws Exception {
    URI uri = Paths.get("src" + File.separator + "test" + File.separator + "resources" + File.separator + "atlasmapping.xml").toUri();
    AtlasMapping atlasMapping = atlasMappingService.loadMapping(uri);
    assertNotNull(atlasMapping);
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) URI(java.net.URI) 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