Search in sources :

Example 76 with Mappings

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

the class AtlasServiceTest method testProcessMappingCustomAction.

@Test
public void testProcessMappingCustomAction() throws Exception {
    createJarFile(false, false);
    FileInputStream jarIn = new FileInputStream(TEST_JAR_PATH);
    Response resUL = service.uploadLibrary(jarIn);
    assertEquals(200, resUL.getStatus());
    Response resFA = service.listFieldActions(null);
    assertEquals(200, resFA.getStatus());
    BufferedInputStream in = new BufferedInputStream(new FileInputStream("src/test/resources/mappings/atlasmapping-custom-action.json"));
    AtlasMapping am = mapper.readValue(in, AtlasMapping.class);
    Mapping m = (Mapping) am.getMappings().getMapping().get(0);
    Field f = m.getInputField().get(0);
    f.setValue("foo");
    Action action = f.getActions().get(0);
    Method method = action.getClass().getDeclaredMethod("setParam", new Class[] { String.class });
    method.invoke(action, "param");
    ProcessMappingRequest request = new ProcessMappingRequest();
    request.setMapping(m);
    Response resMR = service.processMappingRequest(new ByteArrayInputStream(mapper.writeValueAsBytes(request)), null);
    assertEquals(200, resMR.getStatus());
    ProcessMappingResponse pmr = Json.mapper().readValue((byte[]) resMR.getEntity(), ProcessMappingResponse.class);
    assertEquals(0, pmr.getAudits().getAudit().size(), printAudit(pmr.getAudits()));
    assertEquals("param foo", pmr.getMapping().getOutputField().get(0).getValue());
}
Also used : ProcessMappingResponse(io.atlasmap.v2.ProcessMappingResponse) Response(javax.ws.rs.core.Response) Field(io.atlasmap.v2.Field) AtlasMapping(io.atlasmap.v2.AtlasMapping) Action(io.atlasmap.v2.Action) ProcessMappingResponse(io.atlasmap.v2.ProcessMappingResponse) BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) BaseMapping(io.atlasmap.v2.BaseMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) Method(java.lang.reflect.Method) FileInputStream(java.io.FileInputStream) ProcessMappingRequest(io.atlasmap.v2.ProcessMappingRequest) Test(org.junit.jupiter.api.Test)

Example 77 with Mappings

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

the class AtlasServiceTest method testActionDeserialization.

@Test
public void testActionDeserialization() throws Exception {
    File file = new File("src/test/resources/atlasmapping-actions.json");
    AtlasMapping mapping = mapper.readValue(file, AtlasMapping.class);
    Mappings mappings = mapping.getMappings();
    for (BaseMapping baseMapping : mappings.getMapping()) {
        if (MappingType.MAP.equals(baseMapping.getMappingType())) {
            List<Field> fields = ((Mapping) baseMapping).getOutputField();
            for (Field f : fields) {
                if (f.getActions() != null && f.getActions() != null && !f.getActions().isEmpty()) {
                    LOG.info("Found actions: " + f.getActions().size());
                }
            }
        }
    }
}
Also used : Field(io.atlasmap.v2.Field) AtlasMapping(io.atlasmap.v2.AtlasMapping) Mappings(io.atlasmap.v2.Mappings) BaseMapping(io.atlasmap.v2.BaseMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) File(java.io.File) BaseMapping(io.atlasmap.v2.BaseMapping) Test(org.junit.jupiter.api.Test)

Example 78 with Mappings

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

the class AtlasServiceTest method testADMUpload.

@Test
public void testADMUpload() throws Exception {
    InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("json-schema-source-to-xml-schema-target.adm");
    Response res = service.createMappingRequest(in, MappingFileType.ZIP, 0, generateTestUriInfo("http://localhost:8686/v2/atlas", "http://localhost:8686/v2/atlas/mapping/ZIP/0"));
    assertEquals(200, res.getStatus());
    res = service.getMappingRequest(MappingFileType.JSON, 0);
    assertEquals(200, res.getStatus());
    AtlasMapping mappings = mapper.readValue((byte[]) res.getEntity(), AtlasMapping.class);
    assertEquals(4, mappings.getMappings().getMapping().size());
}
Also used : ProcessMappingResponse(io.atlasmap.v2.ProcessMappingResponse) Response(javax.ws.rs.core.Response) AtlasMapping(io.atlasmap.v2.AtlasMapping) BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Test(org.junit.jupiter.api.Test)

Example 79 with Mappings

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

the class AtlasServiceTest method testProcessMapping3064.

@Test
public void testProcessMapping3064() throws Exception {
    Response res = service.processMappingRequest(this.getClass().getClassLoader().getResourceAsStream("mappings/process-mapping-request-3064.json"), generateTestUriInfo("http://localhost:8686/v2/atlas", "http://localhost:8686/v2/atlas/mapping/process"));
    ProcessMappingResponse resp = Json.mapper().readValue((byte[]) res.getEntity(), ProcessMappingResponse.class);
    assertEquals(0, resp.getAudits().getAudit().size(), printAudit(resp.getAudits()));
    Field field = resp.getMapping().getInputField().get(0);
    assertEquals("/primitives/stringPrimitive", field.getPath());
}
Also used : ProcessMappingResponse(io.atlasmap.v2.ProcessMappingResponse) Response(javax.ws.rs.core.Response) Field(io.atlasmap.v2.Field) ProcessMappingResponse(io.atlasmap.v2.ProcessMappingResponse) Test(org.junit.jupiter.api.Test)

Example 80 with Mappings

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

the class AtlasServiceTest method testProcessMapping2977.

@Test
public void testProcessMapping2977() throws Exception {
    Response res = service.processMappingRequest(this.getClass().getClassLoader().getResourceAsStream("mappings/process-mapping-request-2977.json"), generateTestUriInfo("http://localhost:8686/v2/atlas", "http://localhost:8686/v2/atlas/mapping/process"));
    ProcessMappingResponse resp = Json.mapper().readValue((byte[]) res.getEntity(), ProcessMappingResponse.class);
    assertEquals(0, resp.getAudits().getAudit().size(), printAudit(resp.getAudits()));
    Field field = resp.getMapping().getOutputField().get(0);
    assertEquals("/ns:XmlOE/ns:Address/ns:addressLine1", field.getPath());
    assertEquals("Boston", field.getValue());
}
Also used : ProcessMappingResponse(io.atlasmap.v2.ProcessMappingResponse) Response(javax.ws.rs.core.Response) Field(io.atlasmap.v2.Field) ProcessMappingResponse(io.atlasmap.v2.ProcessMappingResponse) 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