@Test public void test_should_update_seva_request_with_create_workflow_response() { final HashMap<String, Object> complaintRequestMap = new HashMap<>(); final HashMap<String, Object> serviceRequestMap = new HashMap<>(); serviceRequestMap.put("serviceCode", "serviceCode"); serviceRequestMap.put("systemStatus", "REGISTERED"); serviceRequestMap.put("isAttribValuesPopulated", false); final ArrayList<HashMap<String, String>> attributeValues = new ArrayList<>(); final HashMap<String, String> locationIdEntry = new HashMap<>(); locationIdEntry.put("key", VALUES_LOCATION_ID); locationIdEntry.put("name", "systemLocationId"); attributeValues.add(locationIdEntry); final HashMap<String, String> statusEntry = new HashMap<>(); statusEntry.put("key", STATUS); statusEntry.put("name", "REGISTERED"); attributeValues.add(statusEntry); serviceRequestMap.put("attribValues", attributeValues); complaintRequestMap.put("serviceRequest", serviceRequestMap); final RequestInfo requestInfo = RequestInfo.builder().action("POST").build(); complaintRequestMap.put("RequestInfo", requestInfo); final SevaRequest sevaRequest = new SevaRequest(complaintRequestMap); final WorkflowResponse workflowResponse = new WorkflowResponse(ASSIGNEE, getValuesWithStateId()); when(workflowRepository.create(any(WorkflowRequest.class))).thenReturn(workflowResponse); final SevaRequest enrichedSevaRequest = workflowService.enrichWorkflow(sevaRequest); assertEquals(ASSIGNEE, enrichedSevaRequest.getDynamicSingleValue("systemPositionId")); assertEquals(STATE_ID, enrichedSevaRequest.getDynamicSingleValue("systemStateId")); }
public SevaRequest enrichWorkflow(SevaRequest sevaRequest) { WorkflowRequest request = sevaRequest.getWorkFlowRequest(); WorkflowResponse workflowResponse = null; if (request.isCreate() && sevaRequest.isCreate()) { workflowResponse = workflowRepository.create(request); } else if (request.isClosed()) { workflowResponse = workflowRepository.close(request); } else { ServiceRequest responseFromDB = complaintRestRepository.getComplaintByCrn(request.getTenantId(), request.getCrn()); String locationId = responseFromDB.getDynamicSingleValue("systemLocationId"); String departmentId = responseFromDB.getDynamicSingleValue("systemDepartmentId"); String positionId = responseFromDB.getDynamicSingleValue("systemPositionId"); String status = responseFromDB.getDynamicSingleValue("systemStatus"); boolean isUpdate = false; if (!responseFromDB.getComplaintTypeCode().equals(request.getValueForKey("complaintTypeCode")) || !locationId.equals(request.getValueForKey("boundaryId")) || !positionId.equals(request.getPositionId().toString())) { isUpdate = true; } else if (!departmentId.equals(request.getValueForKey("systemDepartmentId")) || (!status.equals(request.getStatus()) || !responseFromDB.getDescription().equals(request.getValueForKey("systemApprovalComments"))) && !isUpdate) { isUpdate = true; } if (isUpdate) { workflowResponse = workflowRepository.update(request); } } if (workflowResponse != null) sevaRequest.update(workflowResponse); return sevaRequest; }
WorkflowService { public SevaRequest enrichWorkflow(SevaRequest sevaRequest) { WorkflowRequest request = sevaRequest.getWorkFlowRequest(); WorkflowResponse workflowResponse = null; if (request.isCreate() && sevaRequest.isCreate()) { workflowResponse = workflowRepository.create(request); } else if (request.isClosed()) { workflowResponse = workflowRepository.close(request); } else { ServiceRequest responseFromDB = complaintRestRepository.getComplaintByCrn(request.getTenantId(), request.getCrn()); String locationId = responseFromDB.getDynamicSingleValue("systemLocationId"); String departmentId = responseFromDB.getDynamicSingleValue("systemDepartmentId"); String positionId = responseFromDB.getDynamicSingleValue("systemPositionId"); String status = responseFromDB.getDynamicSingleValue("systemStatus"); boolean isUpdate = false; if (!responseFromDB.getComplaintTypeCode().equals(request.getValueForKey("complaintTypeCode")) || !locationId.equals(request.getValueForKey("boundaryId")) || !positionId.equals(request.getPositionId().toString())) { isUpdate = true; } else if (!departmentId.equals(request.getValueForKey("systemDepartmentId")) || (!status.equals(request.getStatus()) || !responseFromDB.getDescription().equals(request.getValueForKey("systemApprovalComments"))) && !isUpdate) { isUpdate = true; } if (isUpdate) { workflowResponse = workflowRepository.update(request); } } if (workflowResponse != null) sevaRequest.update(workflowResponse); return sevaRequest; } }
WorkflowService { public SevaRequest enrichWorkflow(SevaRequest sevaRequest) { WorkflowRequest request = sevaRequest.getWorkFlowRequest(); WorkflowResponse workflowResponse = null; if (request.isCreate() && sevaRequest.isCreate()) { workflowResponse = workflowRepository.create(request); } else if (request.isClosed()) { workflowResponse = workflowRepository.close(request); } else { ServiceRequest responseFromDB = complaintRestRepository.getComplaintByCrn(request.getTenantId(), request.getCrn()); String locationId = responseFromDB.getDynamicSingleValue("systemLocationId"); String departmentId = responseFromDB.getDynamicSingleValue("systemDepartmentId"); String positionId = responseFromDB.getDynamicSingleValue("systemPositionId"); String status = responseFromDB.getDynamicSingleValue("systemStatus"); boolean isUpdate = false; if (!responseFromDB.getComplaintTypeCode().equals(request.getValueForKey("complaintTypeCode")) || !locationId.equals(request.getValueForKey("boundaryId")) || !positionId.equals(request.getPositionId().toString())) { isUpdate = true; } else if (!departmentId.equals(request.getValueForKey("systemDepartmentId")) || (!status.equals(request.getStatus()) || !responseFromDB.getDescription().equals(request.getValueForKey("systemApprovalComments"))) && !isUpdate) { isUpdate = true; } if (isUpdate) { workflowResponse = workflowRepository.update(request); } } if (workflowResponse != null) sevaRequest.update(workflowResponse); return sevaRequest; } @Autowired  WorkflowService(WorkflowRepository workflowRepository, ComplaintRestRepository complaintRestRepository); }
WorkflowService { public SevaRequest enrichWorkflow(SevaRequest sevaRequest) { WorkflowRequest request = sevaRequest.getWorkFlowRequest(); WorkflowResponse workflowResponse = null; if (request.isCreate() && sevaRequest.isCreate()) { workflowResponse = workflowRepository.create(request); } else if (request.isClosed()) { workflowResponse = workflowRepository.close(request); } else { ServiceRequest responseFromDB = complaintRestRepository.getComplaintByCrn(request.getTenantId(), request.getCrn()); String locationId = responseFromDB.getDynamicSingleValue("systemLocationId"); String departmentId = responseFromDB.getDynamicSingleValue("systemDepartmentId"); String positionId = responseFromDB.getDynamicSingleValue("systemPositionId"); String status = responseFromDB.getDynamicSingleValue("systemStatus"); boolean isUpdate = false; if (!responseFromDB.getComplaintTypeCode().equals(request.getValueForKey("complaintTypeCode")) || !locationId.equals(request.getValueForKey("boundaryId")) || !positionId.equals(request.getPositionId().toString())) { isUpdate = true; } else if (!departmentId.equals(request.getValueForKey("systemDepartmentId")) || (!status.equals(request.getStatus()) || !responseFromDB.getDescription().equals(request.getValueForKey("systemApprovalComments"))) && !isUpdate) { isUpdate = true; } if (isUpdate) { workflowResponse = workflowRepository.update(request); } } if (workflowResponse != null) sevaRequest.update(workflowResponse); return sevaRequest; } @Autowired  WorkflowService(WorkflowRepository workflowRepository, ComplaintRestRepository complaintRestRepository); SevaRequest enrichWorkflow(SevaRequest sevaRequest); }
WorkflowService { public SevaRequest enrichWorkflow(SevaRequest sevaRequest) { WorkflowRequest request = sevaRequest.getWorkFlowRequest(); WorkflowResponse workflowResponse = null; if (request.isCreate() && sevaRequest.isCreate()) { workflowResponse = workflowRepository.create(request); } else if (request.isClosed()) { workflowResponse = workflowRepository.close(request); } else { ServiceRequest responseFromDB = complaintRestRepository.getComplaintByCrn(request.getTenantId(), request.getCrn()); String locationId = responseFromDB.getDynamicSingleValue("systemLocationId"); String departmentId = responseFromDB.getDynamicSingleValue("systemDepartmentId"); String positionId = responseFromDB.getDynamicSingleValue("systemPositionId"); String status = responseFromDB.getDynamicSingleValue("systemStatus"); boolean isUpdate = false; if (!responseFromDB.getComplaintTypeCode().equals(request.getValueForKey("complaintTypeCode")) || !locationId.equals(request.getValueForKey("boundaryId")) || !positionId.equals(request.getPositionId().toString())) { isUpdate = true; } else if (!departmentId.equals(request.getValueForKey("systemDepartmentId")) || (!status.equals(request.getStatus()) || !responseFromDB.getDescription().equals(request.getValueForKey("systemApprovalComments"))) && !isUpdate) { isUpdate = true; } if (isUpdate) { workflowResponse = workflowRepository.update(request); } } if (workflowResponse != null) sevaRequest.update(workflowResponse); return sevaRequest; } @Autowired  WorkflowService(WorkflowRepository workflowRepository, ComplaintRestRepository complaintRestRepository); SevaRequest enrichWorkflow(SevaRequest sevaRequest);  }