Skip to content

Commit

Permalink
feat: Modify WorkflowOverrides Response
Browse files Browse the repository at this point in the history
  • Loading branch information
mayorJAY committed Feb 11, 2024
1 parent f1204f0 commit 157b904
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,7 +24,7 @@ public interface WorkflowOverrideApi {
Call<WorkflowOverrideResponse> createWorkflowOverride(@Body CreateWorkflowOverrideRequest request);

@GET(ENDPOINT)
Call<GetWorkflowOverridesResponse> getWorkflowOverrides(@QueryMap Map<String, Object> params);
Call<BulkWorkflowOverridesResponse> getWorkflowOverrides(@QueryMap Map<String, Object> params);

@GET(ENDPOINT + "/workflows/{workflowId}/tenants/{tenantId}")
Call<WorkflowOverrideResponse> getWorkflowOverride(@Path("workflowId") String workflowId, @Path("tenantId") String tenantId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String, Object> params = new HashMap<>();
if (request.getPage() != null) params.put("page", request.getPage());
if (request.getLimit() != null) params.put("limit", request.getLimit());
Response<GetWorkflowOverridesResponse> response = workflowOverrideApi.getWorkflowOverrides(params).execute();
Response<BulkWorkflowOverridesResponse> response = workflowOverrideApi.getWorkflowOverrides(params).execute();
return restHandler.extractResponse(response);
}

Expand Down

This file was deleted.

10 changes: 4 additions & 6 deletions src/main/java/co/novu/common/base/Novu.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 157b904

Please sign in to comment.