PatientListServiceImpl implements PatientListService { @Override public List<PatientList> getPatientListByName(String name) { return dao.getPatientListByName(name); }  @Override void setPatientListDAO(PatientListDAO dao); @Override PatientList savePatientList(PatientList patientList); @Override PatientList getPatientList(Integer id); @Override List<PatientList> getPatientListByName(String name); @Override PatientList getPatientListByUuid(String uuid); @Override List<PatientList> getPatientListByEncounterType(EncounterType encounterType); @Override List<PatientList> getAllPatientList(boolean includeRetired); @Override List<Encounter> getEncountersInPatientList(PatientList patientList); @Override List<Patient> getPatientsInPatientList(PatientList patientList); @Override PatientList updatePatientList(PatientList patientList); @Override void deletePatientList(PatientList patientList); @Override void onStartup(); @Override void onShutdown();  }
@Test public void testGetPatientListByNameShouldUsePrivileges() { Context.getUserContext().getAuthenticatedUser().removeRole(Context.getUserService().getRole("System Developer")); Context.getUserContext().removeProxyPrivilege("View Patient Lists"); String name = "TestList1"; String result = null; try { result = s.getPatientListByName(name).get(0).getName(); fail("No privileges required for getPatientListByName"); } catch (APIAuthenticationException e) { Context.getUserContext().addProxyPrivilege("View Patient Lists"); result = s.getPatientListByName(name).get(0).getName(); } }
@Test public void testGetPatientListByNameShouldReturnPatientList() { String name = "TestList1"; String result = s.getPatientListByName(name).get(0).getName(); assertEquals(name, result); }