@Test(expected = InvalidComplaintStatusSearchException.class) public void test_should_validate_search_criteria_before_proceeding() { ComplaintStatusSearchCriteria complaintStatusSearchCriteria = mock(ComplaintStatusSearchCriteria.class); Mockito.doThrow(new InvalidComplaintStatusSearchException(complaintStatusSearchCriteria)) .when(complaintStatusSearchCriteria).validate(); complaintStatusService.getNextStatuses(complaintStatusSearchCriteria); verify(complaintStatusSearchCriteria).validate(); }
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);  }