### Question:
PatientController { public List<Patient> searchPatientLocally(String term, String cohortUuid) throws PatientLoadException { try { return StringUtils.isEmpty(cohortUuid) ? patientService.searchPatients(term) : patientService.searchPatients(term, cohortUuid); } catch (IOException | ParseException e) { throw new PatientLoadException(e); } } PatientController(PatientService patientService, CohortService cohortService, FormService formService,PatientTagService patientTagService); void replacePatients(List<Patient> patients); List<Patient> getPatients(String cohortId); List<Patient> getPatients(String cohortId,int page, int pageSize); List<Patient> getAllPatients(); List<Patient> getPatients(int page, int pageSize); int countAllPatients(); int countPatients(String cohortId); Patient getPatientByUuid(String uuid); List<Patient> searchPatientLocally(String term, String cohortUuid); List<Patient> searchPatientLocally(String term,  int page, int pageSize); List<Patient> getPatientsForCohorts(String[] cohortUuids); List<Patient> searchPatientOnServer(String name); List<Patient> getAllPatientsCreatedLocallyAndNotSynced(); Patient consolidateTemporaryPatient(Patient patient); void savePatient(Patient patient); void updatePatient(Patient patient); void savePatientTags(PatientTag tag); void savePatients(List<Patient> patients); void deletePatient(Patient localPatient); void deletePatient(List<Patient> localPatients); List<Patient> getPatientsNotInCohorts(); Patient downloadPatientByUUID(String uuid); void deleteAllPatients(); PatientIdentifierType getPatientIdentifierTypeByUuid(String uuid); List<PatientIdentifierType> getPatientIdentifierTypeByName(String name); PersonAttributeType getPersonAttributeTypeByUuid(String uuid); List<PersonAttributeType> getPersonAttributeTypeByName(String name); int getTagColor(String uuid); List<PatientTag> getSelectedTags(); void setSelectedTags(List<PatientTag> selectedTags); List<PatientTag> getAllTags(); List<String> getSelectedTagUuids(); List<Patient> filterPatientByTags(List<Patient> patients, List<String> tagsUuid); void deletePatientByCohortMembership(List<CohortMember> cohortMembers); void deletePatientsPendingDeletion(); int getFormDataCount(String patientUuid);  }### Answer:
@Test public void shouldSearchWithOutCohortUUIDIsNull() throws IOException, ParseException, PatientController.PatientLoadException { String searchString = "searchString"; List<Patient> patients = new ArrayList<>(); when(patientService.searchPatients(searchString)).thenReturn(patients); assertThat(patientController.searchPatientLocally(searchString, null), is(patients)); verify(patientService).searchPatients(searchString); }
@Test public void shouldSearchWithOutCohortUUIDIsEmpty() throws IOException, ParseException, PatientController.PatientLoadException { String searchString = "searchString"; List<Patient> patients = new ArrayList<>(); when(patientService.searchPatients(searchString)).thenReturn(patients); assertThat(patientController.searchPatientLocally(searchString, StringUtils.EMPTY), is(patients)); verify(patientService).searchPatients(searchString); }
@Test public void shouldCallSearchPatientWithCohortIDIfPresent() throws Exception, PatientController.PatientLoadException { String searchString = "searchString"; String cohortUUID = "cohortUUID"; List<Patient> patients = new ArrayList<>(); when(patientService.searchPatients(searchString, cohortUUID)).thenReturn(patients); assertThat(patientController.searchPatientLocally(searchString, cohortUUID), is(patients)); verify(patientService).searchPatients(searchString, cohortUUID); }