@Test public void shouldRecognisedAnInitiallyNonInitialisedLastSyncTime() throws EncounterController.DownloadEncounterException, IOException { List<String> newPatients = asList("patientUuid2"); when(lastSyncTimeService.getLastSyncTimeFor(DOWNLOAD_ENCOUNTERS,"patientUuid1,patientUuid2")).thenReturn(null); when(lastSyncTimeService.getFullLastSyncTimeInfoFor(DOWNLOAD_ENCOUNTERS)).thenReturn(null); List<String> mPatientUuids = asList("patientUuid1", "patientUuid2"); encounterController.downloadEncountersByPatientUuids(mPatientUuids, activeSetupConfigUuid); verify(encounterService, never()).downloadEncountersByPatientUuidsAndSyncDate(newPatients, null); }
public List<Encounter> downloadEncountersByPatientUuids(List<String> patientUuids, String activeSetupConfigUuid) throws DownloadEncounterException { try { String paramSignature = StringUtils.getCommaSeparatedStringFromList(patientUuids); Date lastSyncTime = lastSyncTimeService.getLastSyncTimeFor(DOWNLOAD_ENCOUNTERS, paramSignature); List<Encounter> encounters = new ArrayList<>(); List<String> previousPatientsUuid = new ArrayList<>(); if (hasThisCallHappenedBefore(lastSyncTime)) { encounters.addAll(downloadEncounters(patientUuids, lastSyncTime, activeSetupConfigUuid)); } else { encounters.addAll(downloadEncounters(patientUuids, null, activeSetupConfigUuid)); } LastSyncTime newLastSyncTime = new LastSyncTime(DOWNLOAD_ENCOUNTERS, sntpService.getTimePerDeviceTimeZone(), paramSignature); lastSyncTimeService.saveLastSyncTime(newLastSyncTime); return encounters; } catch (IOException e) { throw new DownloadEncounterException(e); } }
EncounterController { public List<Encounter> downloadEncountersByPatientUuids(List<String> patientUuids, String activeSetupConfigUuid) throws DownloadEncounterException { try { String paramSignature = StringUtils.getCommaSeparatedStringFromList(patientUuids); Date lastSyncTime = lastSyncTimeService.getLastSyncTimeFor(DOWNLOAD_ENCOUNTERS, paramSignature); List<Encounter> encounters = new ArrayList<>(); List<String> previousPatientsUuid = new ArrayList<>(); if (hasThisCallHappenedBefore(lastSyncTime)) { encounters.addAll(downloadEncounters(patientUuids, lastSyncTime, activeSetupConfigUuid)); } else { encounters.addAll(downloadEncounters(patientUuids, null, activeSetupConfigUuid)); } LastSyncTime newLastSyncTime = new LastSyncTime(DOWNLOAD_ENCOUNTERS, sntpService.getTimePerDeviceTimeZone(), paramSignature); lastSyncTimeService.saveLastSyncTime(newLastSyncTime); return encounters; } catch (IOException e) { throw new DownloadEncounterException(e); } } }
EncounterController { public List<Encounter> downloadEncountersByPatientUuids(List<String> patientUuids, String activeSetupConfigUuid) throws DownloadEncounterException { try { String paramSignature = StringUtils.getCommaSeparatedStringFromList(patientUuids); Date lastSyncTime = lastSyncTimeService.getLastSyncTimeFor(DOWNLOAD_ENCOUNTERS, paramSignature); List<Encounter> encounters = new ArrayList<>(); List<String> previousPatientsUuid = new ArrayList<>(); if (hasThisCallHappenedBefore(lastSyncTime)) { encounters.addAll(downloadEncounters(patientUuids, lastSyncTime, activeSetupConfigUuid)); } else { encounters.addAll(downloadEncounters(patientUuids, null, activeSetupConfigUuid)); } LastSyncTime newLastSyncTime = new LastSyncTime(DOWNLOAD_ENCOUNTERS, sntpService.getTimePerDeviceTimeZone(), paramSignature); lastSyncTimeService.saveLastSyncTime(newLastSyncTime); return encounters; } catch (IOException e) { throw new DownloadEncounterException(e); } } EncounterController(EncounterService encounterService, LastSyncTimeService lastSyncTimeService, SntpService sntpService); }
EncounterController { public List<Encounter> downloadEncountersByPatientUuids(List<String> patientUuids, String activeSetupConfigUuid) throws DownloadEncounterException { try { String paramSignature = StringUtils.getCommaSeparatedStringFromList(patientUuids); Date lastSyncTime = lastSyncTimeService.getLastSyncTimeFor(DOWNLOAD_ENCOUNTERS, paramSignature); List<Encounter> encounters = new ArrayList<>(); List<String> previousPatientsUuid = new ArrayList<>(); if (hasThisCallHappenedBefore(lastSyncTime)) { encounters.addAll(downloadEncounters(patientUuids, lastSyncTime, activeSetupConfigUuid)); } else { encounters.addAll(downloadEncounters(patientUuids, null, activeSetupConfigUuid)); } LastSyncTime newLastSyncTime = new LastSyncTime(DOWNLOAD_ENCOUNTERS, sntpService.getTimePerDeviceTimeZone(), paramSignature); lastSyncTimeService.saveLastSyncTime(newLastSyncTime); return encounters; } catch (IOException e) { throw new DownloadEncounterException(e); } } EncounterController(EncounterService encounterService, LastSyncTimeService lastSyncTimeService, SntpService sntpService); void replaceEncounters(List<Encounter> allEncounters); int getEncountersCountByPatient(String patientUuid); List<Encounter> getEncountersByPatientUuid(String patientUuid); List<Encounter> downloadEncountersByPatientUuids(List<String> patientUuids, String activeSetupConfigUuid); void saveEncounters(List<Encounter> encounters); List<EncounterType> getEncounterTypes(); List<Encounter> getEncountersByEncounterTypeNameAndPatientUuid(String name,String patientUuid); List<Encounter> getEncountersByEncounterTypeUuidAndPatientUuid(String encounterTypeUuid,String patientUuid); List<Encounter> getEncountersByEncounterTypeIdAndPatientUuid(int encounterTypeId,String patientUuid); Encounter getEncounterByUuid(String encounterUuid); void deleteEncounters(List<Encounter> encounters); void saveEncounter(Encounter encounter); }
EncounterController { public List<Encounter> downloadEncountersByPatientUuids(List<String> patientUuids, String activeSetupConfigUuid) throws DownloadEncounterException { try { String paramSignature = StringUtils.getCommaSeparatedStringFromList(patientUuids); Date lastSyncTime = lastSyncTimeService.getLastSyncTimeFor(DOWNLOAD_ENCOUNTERS, paramSignature); List<Encounter> encounters = new ArrayList<>(); List<String> previousPatientsUuid = new ArrayList<>(); if (hasThisCallHappenedBefore(lastSyncTime)) { encounters.addAll(downloadEncounters(patientUuids, lastSyncTime, activeSetupConfigUuid)); } else { encounters.addAll(downloadEncounters(patientUuids, null, activeSetupConfigUuid)); } LastSyncTime newLastSyncTime = new LastSyncTime(DOWNLOAD_ENCOUNTERS, sntpService.getTimePerDeviceTimeZone(), paramSignature); lastSyncTimeService.saveLastSyncTime(newLastSyncTime); return encounters; } catch (IOException e) { throw new DownloadEncounterException(e); } } EncounterController(EncounterService encounterService, LastSyncTimeService lastSyncTimeService, SntpService sntpService); void replaceEncounters(List<Encounter> allEncounters); int getEncountersCountByPatient(String patientUuid); List<Encounter> getEncountersByPatientUuid(String patientUuid); List<Encounter> downloadEncountersByPatientUuids(List<String> patientUuids, String activeSetupConfigUuid); void saveEncounters(List<Encounter> encounters); List<EncounterType> getEncounterTypes(); List<Encounter> getEncountersByEncounterTypeNameAndPatientUuid(String name,String patientUuid); List<Encounter> getEncountersByEncounterTypeUuidAndPatientUuid(String encounterTypeUuid,String patientUuid); List<Encounter> getEncountersByEncounterTypeIdAndPatientUuid(int encounterTypeId,String patientUuid); Encounter getEncounterByUuid(String encounterUuid); void deleteEncounters(List<Encounter> encounters); void saveEncounter(Encounter encounter);  }