Search in sources :

Example 1 with ProcessMappingResponse

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

the class AtlasServiceTest method testProcessMapping.

@Test
public void testProcessMapping() throws Exception {
    Response res = service.processMappingRequest(this.getClass().getClassLoader().getResourceAsStream("mappings/process-mapping-request.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()));
    FieldGroup group = (FieldGroup) resp.getMapping().getOutputField().get(0);
    assertEquals("/addressList<>/city", group.getPath());
    Field f = group.getField().get(0);
    assertEquals("/addressList<0>/city", f.getPath());
    assertEquals("testZzz", f.getValue());
}
Also used : ProcessMappingResponse(io.atlasmap.v2.ProcessMappingResponse) Response(javax.ws.rs.core.Response) Field(io.atlasmap.v2.Field) ProcessMappingResponse(io.atlasmap.v2.ProcessMappingResponse) FieldGroup(io.atlasmap.v2.FieldGroup) Test(org.junit.jupiter.api.Test)

Example 2 with ProcessMappingResponse

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

the class AtlasServiceTest method testJarUploadNoProcessorLoader.

@Test
public void testJarUploadNoProcessorLoader() throws Exception {
    assumeFalse(isWindowsJDK8());
    createJarFile(false, true);
    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());
    String responseJson = new String((byte[]) resFA.getEntity());
    assertFalse(responseJson.contains("myCustomFieldAction"));
    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(1, pmr.getAudits().getAudit().size(), printAudit(pmr.getAudits()));
    Audit audit = pmr.getAudits().getAudit().get(0);
    assertEquals(AuditStatus.WARN, audit.getStatus());
    assertTrue(audit.getMessage().contains("Couldn't find metadata for a FieldAction 'MyFieldActionsModel'"));
    assertEquals("foo", pmr.getMapping().getOutputField().get(0).getValue());
}
Also used : Action(io.atlasmap.v2.Action) ProcessMappingResponse(io.atlasmap.v2.ProcessMappingResponse) BaseMapping(io.atlasmap.v2.BaseMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) Method(java.lang.reflect.Method) FileInputStream(java.io.FileInputStream) ProcessMappingResponse(io.atlasmap.v2.ProcessMappingResponse) Response(javax.ws.rs.core.Response) Field(io.atlasmap.v2.Field) Audit(io.atlasmap.v2.Audit) AtlasMapping(io.atlasmap.v2.AtlasMapping) BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ProcessMappingRequest(io.atlasmap.v2.ProcessMappingRequest) Test(org.junit.jupiter.api.Test)

Example 3 with ProcessMappingResponse

use of io.atlasmap.v2.ProcessMappingResponse 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 4 with ProcessMappingResponse

use of io.atlasmap.v2.ProcessMappingResponse 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 5 with ProcessMappingResponse

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

ProcessMappingResponse (io.atlasmap.v2.ProcessMappingResponse)6 Field (io.atlasmap.v2.Field)5 Response (javax.ws.rs.core.Response)5 Test (org.junit.jupiter.api.Test)5 AtlasMapping (io.atlasmap.v2.AtlasMapping)3 Mapping (io.atlasmap.v2.Mapping)3 ProcessMappingRequest (io.atlasmap.v2.ProcessMappingRequest)3 Action (io.atlasmap.v2.Action)2 BaseMapping (io.atlasmap.v2.BaseMapping)2 BufferedInputStream (java.io.BufferedInputStream)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 FileInputStream (java.io.FileInputStream)2 Method (java.lang.reflect.Method)2 AtlasException (io.atlasmap.api.AtlasException)1 Audit (io.atlasmap.v2.Audit)1 Audits (io.atlasmap.v2.Audits)1 FieldGroup (io.atlasmap.v2.FieldGroup)1 Operation (io.swagger.v3.oas.annotations.Operation)1 RequestBody (io.swagger.v3.oas.annotations.parameters.RequestBody)1 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)1