@Test public void downloadAllCohorts_shouldReturnDownloadedCohorts() throws CohortController.CohortDownloadException, IOException { List<Cohort> downloadedCohorts = new ArrayList<>(); List<Cohort> cohorts = new ArrayList<>(); when(cohortService.downloadCohortsByName(StringUtils.EMPTY,null, null)).thenReturn(downloadedCohorts); when(lastSyncTimeService.getLastSyncTimeFor(DOWNLOAD_COHORTS)).thenReturn(null); controller.downloadAllCohorts(null); assertThat(controller.downloadAllCohorts(null), is(downloadedCohorts)); }
public List<Cohort> downloadAllCohorts(String defaultLocation) throws CohortDownloadException { try { Date lastSyncTimeForCohorts = lastSyncTimeService.getLastSyncTimeFor(DOWNLOAD_COHORTS); Provider loggedInProvider = getLoggedInProvider(); List<Cohort> allCohorts = cohortService.downloadCohortsByNameAndSyncDate(StringUtils.EMPTY, lastSyncTimeForCohorts, defaultLocation, loggedInProvider); LastSyncTime lastSyncTime = new LastSyncTime(DOWNLOAD_COHORTS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return allCohorts; } catch (IOException e) { throw new CohortDownloadException(e); } }
CohortController { public List<Cohort> downloadAllCohorts(String defaultLocation) throws CohortDownloadException { try { Date lastSyncTimeForCohorts = lastSyncTimeService.getLastSyncTimeFor(DOWNLOAD_COHORTS); Provider loggedInProvider = getLoggedInProvider(); List<Cohort> allCohorts = cohortService.downloadCohortsByNameAndSyncDate(StringUtils.EMPTY, lastSyncTimeForCohorts, defaultLocation, loggedInProvider); LastSyncTime lastSyncTime = new LastSyncTime(DOWNLOAD_COHORTS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return allCohorts; } catch (IOException e) { throw new CohortDownloadException(e); } } }
CohortController { public List<Cohort> downloadAllCohorts(String defaultLocation) throws CohortDownloadException { try { Date lastSyncTimeForCohorts = lastSyncTimeService.getLastSyncTimeFor(DOWNLOAD_COHORTS); Provider loggedInProvider = getLoggedInProvider(); List<Cohort> allCohorts = cohortService.downloadCohortsByNameAndSyncDate(StringUtils.EMPTY, lastSyncTimeForCohorts, defaultLocation, loggedInProvider); LastSyncTime lastSyncTime = new LastSyncTime(DOWNLOAD_COHORTS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return allCohorts; } catch (IOException e) { throw new CohortDownloadException(e); } } CohortController(CohortService cohortService, LastSyncTimeService lastSyncTimeService, SntpService sntpService, MuzimaApplication muzimaApplication); }
CohortController { public List<Cohort> downloadAllCohorts(String defaultLocation) throws CohortDownloadException { try { Date lastSyncTimeForCohorts = lastSyncTimeService.getLastSyncTimeFor(DOWNLOAD_COHORTS); Provider loggedInProvider = getLoggedInProvider(); List<Cohort> allCohorts = cohortService.downloadCohortsByNameAndSyncDate(StringUtils.EMPTY, lastSyncTimeForCohorts, defaultLocation, loggedInProvider); LastSyncTime lastSyncTime = new LastSyncTime(DOWNLOAD_COHORTS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return allCohorts; } catch (IOException e) { throw new CohortDownloadException(e); } } CohortController(CohortService cohortService, LastSyncTimeService lastSyncTimeService, SntpService sntpService, MuzimaApplication muzimaApplication); String getDefaultLocation(); Provider getLoggedInProvider(); List<Cohort> getAllCohorts(); int countAllCohorts(); List<Cohort> downloadAllCohorts(String defaultLocation); List<CohortData> downloadCohortData(String[] cohortUuids, String defaulLocation); List<CohortData> downloadRemovedCohortData(String[] cohortUuids); CohortData downloadCohortDataByUuid(String uuid,String defaultLocation); CohortData downloadRemovedCohortDataByUuid(String uuid); List<Cohort> downloadCohortsByPrefix(List<String> cohortPrefixes,String defaultLocation); void saveAllCohorts(List<Cohort> cohorts); void saveOrUpdateCohorts(List<Cohort> cohorts); void deleteAllCohorts(); void deleteCohorts(List<Cohort> cohorts); List<Cohort> getSyncedCohorts(); boolean isDownloaded(Cohort cohort); boolean isUpdateAvailable(); List<Cohort> getCohortsWithPendingUpdates(); void markAsUpToDate(String[] cohortUuids); void setSyncStatus(String[] cohortUuids); int countSyncedCohorts(); void deleteAllCohortMembers(String cohortUuid); void addCohortMembers(List<CohortMember> cohortMembers); int countCohortMembers(Cohort cohort); List<Cohort> downloadCohortByName(String name); List<Cohort> downloadCohortsByUuidList(String[] uuidList); List<CohortMember> getCohortMembershipByPatientUuid(String patientUuid); void deleteAllCohortMembers(List<Cohort> allCohorts); void deleteCohortMembers(List<CohortMember> cohortMembers); }
CohortController { public List<Cohort> downloadAllCohorts(String defaultLocation) throws CohortDownloadException { try { Date lastSyncTimeForCohorts = lastSyncTimeService.getLastSyncTimeFor(DOWNLOAD_COHORTS); Provider loggedInProvider = getLoggedInProvider(); List<Cohort> allCohorts = cohortService.downloadCohortsByNameAndSyncDate(StringUtils.EMPTY, lastSyncTimeForCohorts, defaultLocation, loggedInProvider); LastSyncTime lastSyncTime = new LastSyncTime(DOWNLOAD_COHORTS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return allCohorts; } catch (IOException e) { throw new CohortDownloadException(e); } } CohortController(CohortService cohortService, LastSyncTimeService lastSyncTimeService, SntpService sntpService, MuzimaApplication muzimaApplication); String getDefaultLocation(); Provider getLoggedInProvider(); List<Cohort> getAllCohorts(); int countAllCohorts(); List<Cohort> downloadAllCohorts(String defaultLocation); List<CohortData> downloadCohortData(String[] cohortUuids, String defaulLocation); List<CohortData> downloadRemovedCohortData(String[] cohortUuids); CohortData downloadCohortDataByUuid(String uuid,String defaultLocation); CohortData downloadRemovedCohortDataByUuid(String uuid); List<Cohort> downloadCohortsByPrefix(List<String> cohortPrefixes,String defaultLocation); void saveAllCohorts(List<Cohort> cohorts); void saveOrUpdateCohorts(List<Cohort> cohorts); void deleteAllCohorts(); void deleteCohorts(List<Cohort> cohorts); List<Cohort> getSyncedCohorts(); boolean isDownloaded(Cohort cohort); boolean isUpdateAvailable(); List<Cohort> getCohortsWithPendingUpdates(); void markAsUpToDate(String[] cohortUuids); void setSyncStatus(String[] cohortUuids); int countSyncedCohorts(); void deleteAllCohortMembers(String cohortUuid); void addCohortMembers(List<CohortMember> cohortMembers); int countCohortMembers(Cohort cohort); List<Cohort> downloadCohortByName(String name); List<Cohort> downloadCohortsByUuidList(String[] uuidList); List<CohortMember> getCohortMembershipByPatientUuid(String patientUuid); void deleteAllCohortMembers(List<Cohort> allCohorts); void deleteCohortMembers(List<CohortMember> cohortMembers);  }