@Test public void test_should_find_next_statuses_given_current_status_name_and_user_roles() throws Exception { final String CURRENT_STATUS_NAME = "REJECTED"; final Long CURRENT_STATUS_ID = 1L; final String CURRENT_STATUS_TENANTID = "default"; ComplaintStatus currentStatus = new ComplaintStatus(CURRENT_STATUS_ID, CURRENT_STATUS_NAME,CURRENT_STATUS_TENANTID,"0001"); List<Long> listOfRoles = asList(1L, 2L); List<ComplaintStatus> complaintStatuses = getListOfComplaintStatusModels(); when(complaintStatusRepository.findByCodeAndTenantId(CURRENT_STATUS_NAME,"default")).thenReturn(currentStatus); when(complaintStatusMappingRepository.getNextStatuses(CURRENT_STATUS_ID, listOfRoles, "default")) .thenReturn(complaintStatuses); ComplaintStatusSearchCriteria complaintStatusSearchCriteria = new ComplaintStatusSearchCriteria(CURRENT_STATUS_NAME, listOfRoles, "default"); List<ComplaintStatus> nextStatuses = complaintStatusService.getNextStatuses(complaintStatusSearchCriteria); assertThat(nextStatuses).isEqualTo(complaintStatuses); }
public List<ComplaintStatus> getNextStatuses(ComplaintStatusSearchCriteria complaintStatusSearchCriteria) { complaintStatusSearchCriteria.validate(); ComplaintStatus currentStatus = complaintStatusRepository.findByCodeAndTenantId( complaintStatusSearchCriteria.getComplaintStatusCode(), complaintStatusSearchCriteria.getTenantId()); if (currentStatus == null) { throw new InvalidComplaintStatusException(); } return complaintStatusMappingRepository .getNextStatuses(currentStatus.getId(), complaintStatusSearchCriteria.getRoles(), complaintStatusSearchCriteria.getTenantId()); }
ComplaintStatusService { public List<ComplaintStatus> getNextStatuses(ComplaintStatusSearchCriteria complaintStatusSearchCriteria) { complaintStatusSearchCriteria.validate(); ComplaintStatus currentStatus = complaintStatusRepository.findByCodeAndTenantId( complaintStatusSearchCriteria.getComplaintStatusCode(), complaintStatusSearchCriteria.getTenantId()); if (currentStatus == null) { throw new InvalidComplaintStatusException(); } return complaintStatusMappingRepository .getNextStatuses(currentStatus.getId(), complaintStatusSearchCriteria.getRoles(), complaintStatusSearchCriteria.getTenantId()); } }
ComplaintStatusService { public List<ComplaintStatus> getNextStatuses(ComplaintStatusSearchCriteria complaintStatusSearchCriteria) { complaintStatusSearchCriteria.validate(); ComplaintStatus currentStatus = complaintStatusRepository.findByCodeAndTenantId( complaintStatusSearchCriteria.getComplaintStatusCode(), complaintStatusSearchCriteria.getTenantId()); if (currentStatus == null) { throw new InvalidComplaintStatusException(); } return complaintStatusMappingRepository .getNextStatuses(currentStatus.getId(), complaintStatusSearchCriteria.getRoles(), complaintStatusSearchCriteria.getTenantId()); } ComplaintStatusService(ComplaintStatusRepository complaintStatusRepository,
                                  ComplaintStatusMappingRepository complaintStatusMappingRepository); }
ComplaintStatusService { public List<ComplaintStatus> getNextStatuses(ComplaintStatusSearchCriteria complaintStatusSearchCriteria) { complaintStatusSearchCriteria.validate(); ComplaintStatus currentStatus = complaintStatusRepository.findByCodeAndTenantId( complaintStatusSearchCriteria.getComplaintStatusCode(), complaintStatusSearchCriteria.getTenantId()); if (currentStatus == null) { throw new InvalidComplaintStatusException(); } return complaintStatusMappingRepository .getNextStatuses(currentStatus.getId(), complaintStatusSearchCriteria.getRoles(), complaintStatusSearchCriteria.getTenantId()); } ComplaintStatusService(ComplaintStatusRepository complaintStatusRepository,
                                  ComplaintStatusMappingRepository complaintStatusMappingRepository); List<ComplaintStatus> findAll(); List<ComplaintStatus> getNextStatuses(ComplaintStatusSearchCriteria complaintStatusSearchCriteria); }
ComplaintStatusService { public List<ComplaintStatus> getNextStatuses(ComplaintStatusSearchCriteria complaintStatusSearchCriteria) { complaintStatusSearchCriteria.validate(); ComplaintStatus currentStatus = complaintStatusRepository.findByCodeAndTenantId( complaintStatusSearchCriteria.getComplaintStatusCode(), complaintStatusSearchCriteria.getTenantId()); if (currentStatus == null) { throw new InvalidComplaintStatusException(); } return complaintStatusMappingRepository .getNextStatuses(currentStatus.getId(), complaintStatusSearchCriteria.getRoles(), complaintStatusSearchCriteria.getTenantId()); } ComplaintStatusService(ComplaintStatusRepository complaintStatusRepository,
                                  ComplaintStatusMappingRepository complaintStatusMappingRepository); List<ComplaintStatus> findAll(); List<ComplaintStatus> getNextStatuses(ComplaintStatusSearchCriteria complaintStatusSearchCriteria);  }