From 157b904888bf8b50c4d6d6e1c6755d6152546ae5 Mon Sep 17 00:00:00 2001 From: MayorJay Date: Sun, 11 Feb 2024 15:14:07 +0000 Subject: [PATCH] feat: Modify WorkflowOverrides Response --- .../api/workflowoverrides/WorkflowOverrideApi.java | 4 ++-- .../workflowoverrides/WorkflowOverrideHandler.java | 6 +++--- .../response/GetWorkflowOverridesResponse.java | 8 -------- src/main/java/co/novu/common/base/Novu.java | 10 ++++------ .../workflowoverride/WorkflowOverrideHandlerTest.java | 11 ++++------- 5 files changed, 13 insertions(+), 26 deletions(-) delete mode 100644 src/main/java/co/novu/api/workflowoverrides/response/GetWorkflowOverridesResponse.java diff --git a/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideApi.java b/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideApi.java index 46571b5..01d915c 100644 --- a/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideApi.java +++ b/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideApi.java @@ -2,8 +2,8 @@ import co.novu.api.workflowoverrides.request.CreateWorkflowOverrideRequest; import co.novu.api.workflowoverrides.request.UpdateWorkflowOverrideRequest; +import co.novu.api.workflowoverrides.response.BulkWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.DeleteWorkflowOverrideResponse; -import co.novu.api.workflowoverrides.response.GetWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.WorkflowOverrideResponse; import retrofit2.Call; import retrofit2.http.Body; @@ -24,7 +24,7 @@ public interface WorkflowOverrideApi { Call createWorkflowOverride(@Body CreateWorkflowOverrideRequest request); @GET(ENDPOINT) - Call getWorkflowOverrides(@QueryMap Map params); + Call getWorkflowOverrides(@QueryMap Map params); @GET(ENDPOINT + "/workflows/{workflowId}/tenants/{tenantId}") Call getWorkflowOverride(@Path("workflowId") String workflowId, @Path("tenantId") String tenantId); diff --git a/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideHandler.java b/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideHandler.java index 8ac123c..95df046 100644 --- a/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideHandler.java +++ b/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideHandler.java @@ -3,8 +3,8 @@ import co.novu.api.workflowoverrides.request.CreateWorkflowOverrideRequest; import co.novu.api.workflowoverrides.request.GetWorkflowOverrideRequest; import co.novu.api.workflowoverrides.request.UpdateWorkflowOverrideRequest; +import co.novu.api.workflowoverrides.response.BulkWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.DeleteWorkflowOverrideResponse; -import co.novu.api.workflowoverrides.response.GetWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.WorkflowOverrideResponse; import co.novu.common.rest.NovuNetworkException; import co.novu.common.rest.RestHandler; @@ -30,11 +30,11 @@ public WorkflowOverrideResponse createWorkflowOverride(CreateWorkflowOverrideReq return restHandler.extractResponse(response); } - public GetWorkflowOverridesResponse getWorkflowOverrides(GetWorkflowOverrideRequest request) throws IOException, NovuNetworkException { + public BulkWorkflowOverridesResponse getWorkflowOverrides(GetWorkflowOverrideRequest request) throws IOException, NovuNetworkException { Map params = new HashMap<>(); if (request.getPage() != null) params.put("page", request.getPage()); if (request.getLimit() != null) params.put("limit", request.getLimit()); - Response response = workflowOverrideApi.getWorkflowOverrides(params).execute(); + Response response = workflowOverrideApi.getWorkflowOverrides(params).execute(); return restHandler.extractResponse(response); } diff --git a/src/main/java/co/novu/api/workflowoverrides/response/GetWorkflowOverridesResponse.java b/src/main/java/co/novu/api/workflowoverrides/response/GetWorkflowOverridesResponse.java deleted file mode 100644 index 8dd4d05..0000000 --- a/src/main/java/co/novu/api/workflowoverrides/response/GetWorkflowOverridesResponse.java +++ /dev/null @@ -1,8 +0,0 @@ -package co.novu.api.workflowoverrides.response; - -import lombok.Data; - -@Data -public class GetWorkflowOverridesResponse { - private BulkWorkflowOverridesResponse data; -} diff --git a/src/main/java/co/novu/common/base/Novu.java b/src/main/java/co/novu/common/base/Novu.java index af13ec9..11d89fa 100644 --- a/src/main/java/co/novu/common/base/Novu.java +++ b/src/main/java/co/novu/common/base/Novu.java @@ -108,13 +108,11 @@ import co.novu.api.workflowgroups.responses.GetWorkflowGroupsResponse; import co.novu.api.workflowgroups.responses.WorkflowGroupResponse; import co.novu.api.workflowoverrides.WorkflowOverrideHandler; -import co.novu.api.workflowoverrides.pojos.WorkflowOverride; import co.novu.api.workflowoverrides.request.CreateWorkflowOverrideRequest; import co.novu.api.workflowoverrides.request.GetWorkflowOverrideRequest; import co.novu.api.workflowoverrides.request.UpdateWorkflowOverrideRequest; import co.novu.api.workflowoverrides.response.BulkWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.DeleteWorkflowOverrideResponse; -import co.novu.api.workflowoverrides.response.GetWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.WorkflowOverrideResponse; import co.novu.api.workflows.WorkflowHandler; import co.novu.api.workflows.requests.UpdateWorkflowRequest; @@ -996,11 +994,11 @@ public WorkflowOverrideResponse createWorkflowOverride(CreateWorkflowOverrideReq } } - public GetWorkflowOverridesResponse getWorkflowOverrides(GetWorkflowOverrideRequest request) throws IOException, NovuNetworkException { + public BulkWorkflowOverridesResponse getWorkflowOverrides(GetWorkflowOverrideRequest request) throws IOException, NovuNetworkException { try { return workflowOverrideHandler.getWorkflowOverrides(request); } catch (Exception e) { - log.error("Error fetching Workflow-Override", e); + log.error("Error fetching bulk Workflow-Override", e); throw e; } } @@ -1018,7 +1016,7 @@ public WorkflowOverrideResponse getWorkflowOverrideById(String overrideId) throw try { return workflowOverrideHandler.getWorkflowOverrideById(overrideId); } catch (Exception e) { - log.error("Error fetching Workflow-Override", e); + log.error("Error fetching Workflow-Override by id", e); throw e; } } @@ -1027,7 +1025,7 @@ public WorkflowOverrideResponse updateWorkflowOverrideById(String overrideId, Up try { return workflowOverrideHandler.updateWorkflowOverrideById(overrideId, request); } catch (Exception e) { - log.error("Error updating Workflow-Override", e); + log.error("Error updating Workflow-Override by id", e); throw e; } } diff --git a/src/test/java/co/novu/api/workflowoverride/WorkflowOverrideHandlerTest.java b/src/test/java/co/novu/api/workflowoverride/WorkflowOverrideHandlerTest.java index fd0352a..ca881f9 100644 --- a/src/test/java/co/novu/api/workflowoverride/WorkflowOverrideHandlerTest.java +++ b/src/test/java/co/novu/api/workflowoverride/WorkflowOverrideHandlerTest.java @@ -8,7 +8,6 @@ import co.novu.api.workflowoverrides.request.UpdateWorkflowOverrideRequest; import co.novu.api.workflowoverrides.response.BulkWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.DeleteWorkflowOverrideResponse; -import co.novu.api.workflowoverrides.response.GetWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.WorkflowOverrideResponse; import co.novu.common.base.NovuConfig; import co.novu.common.rest.NovuNetworkException; @@ -52,13 +51,13 @@ public void test_createWorkflowOverrideHandler() throws IOException, NovuNetwork } public void test_getWorkflowOverrides() throws IOException, NovuNetworkException, InterruptedException { - GetWorkflowOverridesResponse workflowOverridesResponse = getWorkflowOverridesResponse(); + BulkWorkflowOverridesResponse workflowOverridesResponse = getWorkflowOverridesResponse(); Gson gson = new Gson(); mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(gson.toJson(workflowOverridesResponse))); GetWorkflowOverrideRequest getWorkflowOverrideRequest = new GetWorkflowOverrideRequest(); getWorkflowOverrideRequest.setPage(1); getWorkflowOverrideRequest.setLimit(10); - GetWorkflowOverridesResponse response = workflowOverrideHandler.getWorkflowOverrides(getWorkflowOverrideRequest); + BulkWorkflowOverridesResponse response = workflowOverrideHandler.getWorkflowOverrides(getWorkflowOverrideRequest); assertNotNull(response); RecordedRequest request = mockWebServer.takeRequest(); assertEquals("/workflow-overrides?limit=10&page=1", request.getPath()); @@ -166,15 +165,13 @@ private CreateWorkflowOverrideRequest getCreateWorkflowOverrideRequest() { return createWorkflowOverrideRequest; } - private GetWorkflowOverridesResponse getWorkflowOverridesResponse() { + private BulkWorkflowOverridesResponse getWorkflowOverridesResponse() { BulkWorkflowOverridesResponse bulkWorkflowOverridesResponse = new BulkWorkflowOverridesResponse(); bulkWorkflowOverridesResponse.setData(List.of(getWorkflowOverride(), getWorkflowOverride())); bulkWorkflowOverridesResponse.setHasMore(true); bulkWorkflowOverridesResponse.setPageSize(10L); bulkWorkflowOverridesResponse.setPage(1L); - GetWorkflowOverridesResponse getWorkflowOverridesResponse = new GetWorkflowOverridesResponse(); - getWorkflowOverridesResponse.setData(bulkWorkflowOverridesResponse); - return getWorkflowOverridesResponse; + return bulkWorkflowOverridesResponse; } private UpdateWorkflowOverrideRequest getUpdateWorkflowOverrideRequest() {