@Test public void downloadForms_shouldReturnDownloadErrorIfDownloadExceptionOccur() throws FormController.FormFetchException { doThrow(new FormController.FormFetchException(null)).when(formController).downloadAllForms(); assertThat(muzimaSyncService.downloadForms()[0], is(SyncStatusConstants.DOWNLOAD_ERROR)); }
public int[] downloadForms() { int[] result = new int[3]; try { long startDownloadForms = System.currentTimeMillis(); List<Form> allDownloadedForms = formController.downloadAllForms(); List<Form> allForms = formController.getAllAvailableForms(); int deletedFormCount = getDeletedFormCount(allDownloadedForms, allForms); long endDownloadForms = System.currentTimeMillis(); List<Form> voidedForms = deleteVoidedForms(allDownloadedForms); allDownloadedForms.removeAll(voidedForms); formController.updateAllForms(allDownloadedForms); long endSaveForms = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In downloading forms: " + (endDownloadForms - startDownloadForms) / 1000 + " sec\n" + "In replacing forms: " + (endDownloadForms - endSaveForms) / 1000 + " sec"); result[0] = SUCCESS; result[1] = allDownloadedForms.size(); result[2] = deletedFormCount; } catch (FormController.FormFetchException e) { Log.e(getClass().getSimpleName(), "Exception when trying to download forms", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; return result; } catch (FormController.FormSaveException e) { Log.e(getClass().getSimpleName(), "Exception when trying to save forms", e); result[0] = SyncStatusConstants.SAVE_ERROR; return result; } catch (FormController.FormDeleteException e) { Log.e(getClass().getSimpleName(), "Exception when trying to delete forms", e); result[0] = SyncStatusConstants.DELETE_ERROR; return result; } return result; }
MuzimaSyncService { public int[] downloadForms() { int[] result = new int[3]; try { long startDownloadForms = System.currentTimeMillis(); List<Form> allDownloadedForms = formController.downloadAllForms(); List<Form> allForms = formController.getAllAvailableForms(); int deletedFormCount = getDeletedFormCount(allDownloadedForms, allForms); long endDownloadForms = System.currentTimeMillis(); List<Form> voidedForms = deleteVoidedForms(allDownloadedForms); allDownloadedForms.removeAll(voidedForms); formController.updateAllForms(allDownloadedForms); long endSaveForms = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In downloading forms: " + (endDownloadForms - startDownloadForms) / 1000 + " sec\n" + "In replacing forms: " + (endDownloadForms - endSaveForms) / 1000 + " sec"); result[0] = SUCCESS; result[1] = allDownloadedForms.size(); result[2] = deletedFormCount; } catch (FormController.FormFetchException e) { Log.e(getClass().getSimpleName(), "Exception when trying to download forms", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; return result; } catch (FormController.FormSaveException e) { Log.e(getClass().getSimpleName(), "Exception when trying to save forms", e); result[0] = SyncStatusConstants.SAVE_ERROR; return result; } catch (FormController.FormDeleteException e) { Log.e(getClass().getSimpleName(), "Exception when trying to delete forms", e); result[0] = SyncStatusConstants.DELETE_ERROR; return result; } return result; } }
MuzimaSyncService { public int[] downloadForms() { int[] result = new int[3]; try { long startDownloadForms = System.currentTimeMillis(); List<Form> allDownloadedForms = formController.downloadAllForms(); List<Form> allForms = formController.getAllAvailableForms(); int deletedFormCount = getDeletedFormCount(allDownloadedForms, allForms); long endDownloadForms = System.currentTimeMillis(); List<Form> voidedForms = deleteVoidedForms(allDownloadedForms); allDownloadedForms.removeAll(voidedForms); formController.updateAllForms(allDownloadedForms); long endSaveForms = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In downloading forms: " + (endDownloadForms - startDownloadForms) / 1000 + " sec\n" + "In replacing forms: " + (endDownloadForms - endSaveForms) / 1000 + " sec"); result[0] = SUCCESS; result[1] = allDownloadedForms.size(); result[2] = deletedFormCount; } catch (FormController.FormFetchException e) { Log.e(getClass().getSimpleName(), "Exception when trying to download forms", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; return result; } catch (FormController.FormSaveException e) { Log.e(getClass().getSimpleName(), "Exception when trying to save forms", e); result[0] = SyncStatusConstants.SAVE_ERROR; return result; } catch (FormController.FormDeleteException e) { Log.e(getClass().getSimpleName(), "Exception when trying to delete forms", e); result[0] = SyncStatusConstants.DELETE_ERROR; return result; } return result; } MuzimaSyncService(MuzimaApplication muzimaContext); }
MuzimaSyncService { public int[] downloadForms() { int[] result = new int[3]; try { long startDownloadForms = System.currentTimeMillis(); List<Form> allDownloadedForms = formController.downloadAllForms(); List<Form> allForms = formController.getAllAvailableForms(); int deletedFormCount = getDeletedFormCount(allDownloadedForms, allForms); long endDownloadForms = System.currentTimeMillis(); List<Form> voidedForms = deleteVoidedForms(allDownloadedForms); allDownloadedForms.removeAll(voidedForms); formController.updateAllForms(allDownloadedForms); long endSaveForms = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In downloading forms: " + (endDownloadForms - startDownloadForms) / 1000 + " sec\n" + "In replacing forms: " + (endDownloadForms - endSaveForms) / 1000 + " sec"); result[0] = SUCCESS; result[1] = allDownloadedForms.size(); result[2] = deletedFormCount; } catch (FormController.FormFetchException e) { Log.e(getClass().getSimpleName(), "Exception when trying to download forms", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; return result; } catch (FormController.FormSaveException e) { Log.e(getClass().getSimpleName(), "Exception when trying to save forms", e); result[0] = SyncStatusConstants.SAVE_ERROR; return result; } catch (FormController.FormDeleteException e) { Log.e(getClass().getSimpleName(), "Exception when trying to delete forms", e); result[0] = SyncStatusConstants.DELETE_ERROR; return result; } return result; } MuzimaSyncService(MuzimaApplication muzimaContext); int authenticate(String[] credentials); int authenticate(String[] credentials, boolean isUpdatePasswordRequired); int[] downloadForms(); int[] downloadFormTemplatesAndRelatedMetadata(String[] formIds, boolean replaceExistingTemplates); int[] downloadFormTemplates(String[] formIds, boolean replaceExistingTemplates); int[] downloadLocations(String[] locationIds); int[] downloadProviders(String[] providerIds); int[] downloadConcepts(String[] conceptIds); int[] downloadCohorts(); int[] downloadCohorts(String[] cohortUuids); int[] downloadPatientsForCohortsWithUpdatesAvailable(); int[] downloadRemovedCohortMembershipData(String[] cohortUuids); int[] downloadPatientsForCohorts(String[] cohortUuids); int[] downloadPatients(String[] patientUUIDs); int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation); int[] downloadObservationsForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingObservations); int[] downloadEncountersForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingEncounters); int[] downloadEncountersForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingEncounters); int[] uploadAllCompletedForms(); void consolidatePatients(); List<FormData> getArchivedFormData(); int[] checkAndDeleteTemporaryDataForProcessedFormData(List<FormData> archivedFormData); List<String> getUuidsForAllPatientsFromLocalStorage(); List<Patient> updatePatientsNotPartOfCohorts(); int[] downloadNotifications(String receiverUuid); int[] downloadPatientReportHeaders(String patientUuid); int[] downloadAllPatientReportHeadersAndReports(); int[] downloadPatientReportsByUuid(String[] reportUuids); void downloadSetupConfigurations(); int[] downloadSetupConfigurationTemplate(String uuid); int[] downloadAndSaveUpdatedSetupConfigurationTemplate(String uuid); int[] updateSetupConfigurationTemplates(); int[] downloadSetting(String property); int[] downloadNewSettings(); void updateSettingsPreferences(List<MuzimaSetting> muzimaSettings); int[] downloadRelationshipsTypes(); int[] downloadRelationshipsForPatientsByPatientUUIDs(List<String> patientUuids); int[] downloadRelationshipsForPatientsByCohortUUIDs(String[] cohortUuids); String getDefaultLocation(); }
MuzimaSyncService { public int[] downloadForms() { int[] result = new int[3]; try { long startDownloadForms = System.currentTimeMillis(); List<Form> allDownloadedForms = formController.downloadAllForms(); List<Form> allForms = formController.getAllAvailableForms(); int deletedFormCount = getDeletedFormCount(allDownloadedForms, allForms); long endDownloadForms = System.currentTimeMillis(); List<Form> voidedForms = deleteVoidedForms(allDownloadedForms); allDownloadedForms.removeAll(voidedForms); formController.updateAllForms(allDownloadedForms); long endSaveForms = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In downloading forms: " + (endDownloadForms - startDownloadForms) / 1000 + " sec\n" + "In replacing forms: " + (endDownloadForms - endSaveForms) / 1000 + " sec"); result[0] = SUCCESS; result[1] = allDownloadedForms.size(); result[2] = deletedFormCount; } catch (FormController.FormFetchException e) { Log.e(getClass().getSimpleName(), "Exception when trying to download forms", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; return result; } catch (FormController.FormSaveException e) { Log.e(getClass().getSimpleName(), "Exception when trying to save forms", e); result[0] = SyncStatusConstants.SAVE_ERROR; return result; } catch (FormController.FormDeleteException e) { Log.e(getClass().getSimpleName(), "Exception when trying to delete forms", e); result[0] = SyncStatusConstants.DELETE_ERROR; return result; } return result; } MuzimaSyncService(MuzimaApplication muzimaContext); int authenticate(String[] credentials); int authenticate(String[] credentials, boolean isUpdatePasswordRequired); int[] downloadForms(); int[] downloadFormTemplatesAndRelatedMetadata(String[] formIds, boolean replaceExistingTemplates); int[] downloadFormTemplates(String[] formIds, boolean replaceExistingTemplates); int[] downloadLocations(String[] locationIds); int[] downloadProviders(String[] providerIds); int[] downloadConcepts(String[] conceptIds); int[] downloadCohorts(); int[] downloadCohorts(String[] cohortUuids); int[] downloadPatientsForCohortsWithUpdatesAvailable(); int[] downloadRemovedCohortMembershipData(String[] cohortUuids); int[] downloadPatientsForCohorts(String[] cohortUuids); int[] downloadPatients(String[] patientUUIDs); int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation); int[] downloadObservationsForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingObservations); int[] downloadEncountersForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingEncounters); int[] downloadEncountersForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingEncounters); int[] uploadAllCompletedForms(); void consolidatePatients(); List<FormData> getArchivedFormData(); int[] checkAndDeleteTemporaryDataForProcessedFormData(List<FormData> archivedFormData); List<String> getUuidsForAllPatientsFromLocalStorage(); List<Patient> updatePatientsNotPartOfCohorts(); int[] downloadNotifications(String receiverUuid); int[] downloadPatientReportHeaders(String patientUuid); int[] downloadAllPatientReportHeadersAndReports(); int[] downloadPatientReportsByUuid(String[] reportUuids); void downloadSetupConfigurations(); int[] downloadSetupConfigurationTemplate(String uuid); int[] downloadAndSaveUpdatedSetupConfigurationTemplate(String uuid); int[] updateSetupConfigurationTemplates(); int[] downloadSetting(String property); int[] downloadNewSettings(); void updateSettingsPreferences(List<MuzimaSetting> muzimaSettings); int[] downloadRelationshipsTypes(); int[] downloadRelationshipsForPatientsByPatientUUIDs(List<String> patientUuids); int[] downloadRelationshipsForPatientsByCohortUUIDs(String[] cohortUuids); String getDefaultLocation();  }