@Test public void should_return_400_when_request_fields_are_invalid() throws Exception { InvalidComplaintStatusSearchException exception = new InvalidComplaintStatusSearchException( new ComplaintStatusSearchCriteria("", Collections.emptyList(),"default") ); when(complaintStatusService.getNextStatuses(any(ComplaintStatusSearchCriteria.class))).thenThrow(exception); mockMvc.perform( post("/v1/nextstatuses/_search") .param("currentStatusCode", "") .contentType(MediaType.APPLICATION_JSON) .content(resources.getFileContents("complaintStatusRequest.json")) ) .andExpect(status().isBadRequest()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(content().json(resources.getFileContents("getNextStatusErrorResponseForFieldValidationErrors.json"))); }
@PostMapping("/nextstatuses/_search") public ServiceStatusResponse getNextStatuses(@RequestBody final ComplaintStatusRequest request, @RequestParam final String currentStatusCode, @RequestParam(defaultValue = "default") final String tenantId) { List<Long> roles = request.getRequestInfo().getUserInfo().getRoles().stream() .map(Role::getId) .collect(Collectors.toList()); ComplaintStatusSearchCriteria complaintStatusSearchCriteria = new ComplaintStatusSearchCriteria(currentStatusCode, roles,tenantId); List<org.egov.workflow.domain.model.ComplaintStatus> domainStatuses = complaintStatusService .getNextStatuses(complaintStatusSearchCriteria); return new ServiceStatusResponse(null, domainStatuses); }
ServiceStatusController { @PostMapping("/nextstatuses/_search") public ServiceStatusResponse getNextStatuses(@RequestBody final ComplaintStatusRequest request, @RequestParam final String currentStatusCode, @RequestParam(defaultValue = "default") final String tenantId) { List<Long> roles = request.getRequestInfo().getUserInfo().getRoles().stream() .map(Role::getId) .collect(Collectors.toList()); ComplaintStatusSearchCriteria complaintStatusSearchCriteria = new ComplaintStatusSearchCriteria(currentStatusCode, roles,tenantId); List<org.egov.workflow.domain.model.ComplaintStatus> domainStatuses = complaintStatusService .getNextStatuses(complaintStatusSearchCriteria); return new ServiceStatusResponse(null, domainStatuses); } }
ServiceStatusController { @PostMapping("/nextstatuses/_search") public ServiceStatusResponse getNextStatuses(@RequestBody final ComplaintStatusRequest request, @RequestParam final String currentStatusCode, @RequestParam(defaultValue = "default") final String tenantId) { List<Long> roles = request.getRequestInfo().getUserInfo().getRoles().stream() .map(Role::getId) .collect(Collectors.toList()); ComplaintStatusSearchCriteria complaintStatusSearchCriteria = new ComplaintStatusSearchCriteria(currentStatusCode, roles,tenantId); List<org.egov.workflow.domain.model.ComplaintStatus> domainStatuses = complaintStatusService .getNextStatuses(complaintStatusSearchCriteria); return new ServiceStatusResponse(null, domainStatuses); } @Autowired  ServiceStatusController(ComplaintStatusService complaintStatusService, KeywordStatusMappingService keywordStatusMappingService); }
ServiceStatusController { @PostMapping("/nextstatuses/_search") public ServiceStatusResponse getNextStatuses(@RequestBody final ComplaintStatusRequest request, @RequestParam final String currentStatusCode, @RequestParam(defaultValue = "default") final String tenantId) { List<Long> roles = request.getRequestInfo().getUserInfo().getRoles().stream() .map(Role::getId) .collect(Collectors.toList()); ComplaintStatusSearchCriteria complaintStatusSearchCriteria = new ComplaintStatusSearchCriteria(currentStatusCode, roles,tenantId); List<org.egov.workflow.domain.model.ComplaintStatus> domainStatuses = complaintStatusService .getNextStatuses(complaintStatusSearchCriteria); return new ServiceStatusResponse(null, domainStatuses); } @Autowired  ServiceStatusController(ComplaintStatusService complaintStatusService, KeywordStatusMappingService keywordStatusMappingService); @PostMapping("/statuses/_search") ServiceStatusResponse getAllStatus(@RequestBody final ComplaintStatusRequest request,
                                              @RequestParam(defaultValue = "Complaint") final String keyword,
                                              @RequestParam(defaultValue = "default") final String tenantId); @PostMapping("/nextstatuses/_search") ServiceStatusResponse getNextStatuses(@RequestBody final ComplaintStatusRequest request,
                                                 @RequestParam final String currentStatusCode,
                                                 @RequestParam(defaultValue = "default") final String tenantId); }
ServiceStatusController { @PostMapping("/nextstatuses/_search") public ServiceStatusResponse getNextStatuses(@RequestBody final ComplaintStatusRequest request, @RequestParam final String currentStatusCode, @RequestParam(defaultValue = "default") final String tenantId) { List<Long> roles = request.getRequestInfo().getUserInfo().getRoles().stream() .map(Role::getId) .collect(Collectors.toList()); ComplaintStatusSearchCriteria complaintStatusSearchCriteria = new ComplaintStatusSearchCriteria(currentStatusCode, roles,tenantId); List<org.egov.workflow.domain.model.ComplaintStatus> domainStatuses = complaintStatusService .getNextStatuses(complaintStatusSearchCriteria); return new ServiceStatusResponse(null, domainStatuses); } @Autowired  ServiceStatusController(ComplaintStatusService complaintStatusService, KeywordStatusMappingService keywordStatusMappingService); @PostMapping("/statuses/_search") ServiceStatusResponse getAllStatus(@RequestBody final ComplaintStatusRequest request,
                                              @RequestParam(defaultValue = "Complaint") final String keyword,
                                              @RequestParam(defaultValue = "default") final String tenantId); @PostMapping("/nextstatuses/_search") ServiceStatusResponse getNextStatuses(@RequestBody final ComplaintStatusRequest request,
                                                 @RequestParam final String currentStatusCode,
                                                 @RequestParam(defaultValue = "default") final String tenantId);  }