target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void downloadObservationsForPatients_shouldReturnSuccessAndCountWhenDownloadingObservationsForPatient() throws PatientController.PatientLoadException, ObservationController.DownloadObservationException, ConceptController.ConceptFetchException { String[] cohortUuids = new String[]{"uuid1"}; final Patient patient = new Patient() {{ setUuid("patient1"); }}; List<Patient> patients = new ArrayList<Patient>() {{ add(patient); }}; List<Observation> allObservations = new ArrayList<Observation>() {{ add(new Observation(){{setPerson(patient);}}); add(new Observation(){{setPerson(patient);}}); }}; when(patientController.getPatientsForCohorts(cohortUuids)).thenReturn(patients); List<String> conceptUuids = Collections.singletonList("weight"); Concept conceptWeight = new Concept(); conceptWeight.setUuid("weight"); when(conceptController.getConcepts()).thenReturn(Collections.singletonList(conceptWeight)); when(observationController.downloadObservationsByPatientUuidsAndConceptUuids(Collections.singletonList("patient1"), conceptUuids)) .thenReturn(allObservations); int[] result = muzimaSyncService.downloadObservationsForPatientsByCohortUUIDs(cohortUuids,true); assertThat(result[0], is(SyncStatusConstants.SUCCESS)); assertThat(result[1], is(2)); }
public int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } return result; }
MuzimaSyncService { public int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } return result; } }
MuzimaSyncService { public int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } return result; } MuzimaSyncService(MuzimaApplication muzimaContext); }
MuzimaSyncService { public int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } 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[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } 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(); }
@Test public void downloadObservationsForPatients_shouldReturnLoadErrorWhenLoadExceptionIsThrownForObservations() throws PatientController.PatientLoadException { String[] cohortUuids = new String[]{}; doThrow(new PatientController.PatientLoadException("")).when(patientController).getPatientsForCohorts(cohortUuids); int[] result = muzimaSyncService.downloadObservationsForPatientsByCohortUUIDs(cohortUuids,true); assertThat(result[0], is(SyncStatusConstants.LOAD_ERROR)); }
public int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } return result; }
MuzimaSyncService { public int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } return result; } }
MuzimaSyncService { public int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } return result; } MuzimaSyncService(MuzimaApplication muzimaContext); }
MuzimaSyncService { public int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } 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[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } 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(); }
@Test public void downloadObservationsForPatients_shouldReturnDownloadErrorWhenDownloadExceptionIsThrownForObservations() throws ObservationController.DownloadObservationException, PatientController.PatientLoadException, ConceptController.ConceptFetchException { String[] cohortUuids = new String[]{"uuid1"}; List<Patient> patients = new ArrayList<Patient>() {{ add(new Patient() {{ setUuid("patient1"); }}); }}; List<Concept> conceptList = new ArrayList<Concept>() {{ add(new Concept() {{ setUuid("concept1"); }}); }}; Set<String> concepts = new HashSet<String>() {{ add("weight"); }}; when(patientController.getPatientsForCohorts(cohortUuids)).thenReturn(patients); when(conceptController.getConcepts()).thenReturn(conceptList); when(muzimaApplication.getSharedPreferences(Constants.CONCEPT_PREF, android.content.Context.MODE_PRIVATE)).thenReturn(sharedPref); when(sharedPref.getStringSet(Constants.CONCEPT_PREF_KEY, new HashSet<String>())).thenReturn(concepts); doThrow(new ObservationController.DownloadObservationException(null)).when(observationController).downloadObservationsByPatientUuidsAndConceptUuids(anyList(), anyList()); int[] result = muzimaSyncService.downloadObservationsForPatientsByCohortUUIDs(cohortUuids,true); assertThat(result[0], is(SyncStatusConstants.DOWNLOAD_ERROR)); }
public int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } return result; }
MuzimaSyncService { public int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } return result; } }
MuzimaSyncService { public int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } return result; } MuzimaSyncService(MuzimaApplication muzimaContext); }
MuzimaSyncService { public int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } 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[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } 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(); }
@Test public void shouldSortTheEncountersByDate() { final Observation observation1 = createObservation(createEncounter("c1", new Date(1)), "01"); final Observation observation2 = createObservation(createEncounter("c2", new Date(3)), "02"); final Encounters encounters = new Encounters(observation1, observation2); encounters.sortByDate(); final Encounters expectedOrderedConcept = new Encounters() {{ add(encounterWithObservations(observation2)); add(encounterWithObservations(observation1)); }}; assertThat(encounters, is(expectedOrderedConcept)); }
public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); }
Encounters extends ArrayList<EncounterWithObservations> { public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); } }
Encounters extends ArrayList<EncounterWithObservations> { public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); } Encounters(); Encounters(Observation... observations); Encounters(List<Observation> observationsByPatient); }
Encounters extends ArrayList<EncounterWithObservations> { public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); } Encounters(); Encounters(Observation... observations); Encounters(List<Observation> observationsByPatient); void sortByDate(); }
Encounters extends ArrayList<EncounterWithObservations> { public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); } Encounters(); Encounters(Observation... observations); Encounters(List<Observation> observationsByPatient); void sortByDate(); }
@Test public void downloadObservationsForPatients_shouldReturnReplaceErrorWhenReplaceExceptionIsThrownForObservations() throws ReplaceObservationException, PatientController.PatientLoadException, ConceptController.ConceptFetchException { String[] cohortUuids = new String[]{}; List<Patient> patients = new ArrayList<Patient>() {{ add(new Patient() {{ setUuid("patient1"); }}); }}; List<Concept> concepts = new ArrayList<>(); concepts.add(new Concept(){{ setUuid("concept1"); }}); when(patientController.getPatientsForCohorts(cohortUuids)).thenReturn(patients); when(conceptController.getConcepts()).thenReturn(concepts); doThrow(new ObservationController.ReplaceObservationException(null)).when(observationController).replaceObservations(anyList()); int[] result = muzimaSyncService.downloadObservationsForPatientsByCohortUUIDs(cohortUuids,true); assertThat(result[0], is(SyncStatusConstants.REPLACE_ERROR)); }
public int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } return result; }
MuzimaSyncService { public int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } return result; } }
MuzimaSyncService { public int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } return result; } MuzimaSyncService(MuzimaApplication muzimaContext); }
MuzimaSyncService { public int[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } 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[] downloadObservationsForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingObservation) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadObservationsForPatientsByPatientUUIDs(patientlist, replaceExistingObservation); if (result[0] != SUCCESS) { updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_observation_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } 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(); }
@Test public void downloadEncountersForPatients_shouldDownloadInBatch() throws PatientController.PatientLoadException, EncounterController.ReplaceEncounterException, EncounterController.DownloadEncounterException, SetupConfigurationController.SetupConfigurationFetchException { String[] cohortUuids = new String[]{"uuid1"}; final Patient patient = new Patient() {{ setUuid("patient1"); }}; List<Patient> patients = new ArrayList<Patient>() {{ add(patient); }}; List<Encounter> encounters = new ArrayList<Encounter>() {{ add(new Encounter(){{setPatient(patient);}}); }}; SetupConfigurationTemplate setupConfigurationTemplate = new SetupConfigurationTemplate(); setupConfigurationTemplate.setUuid("dummySetupConfig"); when(setupConfigurationController.getActiveSetupConfigurationTemplate()).thenReturn(setupConfigurationTemplate); when(patientController.getPatientsForCohorts(cohortUuids)).thenReturn(patients); List<String> patientUuids = Collections.singletonList("patient1"); when(encounterController.downloadEncountersByPatientUuids(patientUuids, setupConfigurationTemplate.getUuid())).thenReturn(encounters); muzimaSyncService.downloadEncountersForPatientsByCohortUUIDs(cohortUuids, true); verify(encounterController).downloadEncountersByPatientUuids(patientUuids, setupConfigurationTemplate.getUuid()); verify(encounterController).replaceEncounters(encounters); verifyNoMoreInteractions(observationController); }
public int[] downloadEncountersForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingEncounters) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadEncountersForPatientsByPatientUUIDs(patientlist, replaceExistingEncounters); if (result[0] != SUCCESS) { Log.e(getClass().getSimpleName(), "Could not download encounters"); updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } return result; }
MuzimaSyncService { public int[] downloadEncountersForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingEncounters) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadEncountersForPatientsByPatientUUIDs(patientlist, replaceExistingEncounters); if (result[0] != SUCCESS) { Log.e(getClass().getSimpleName(), "Could not download encounters"); updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } return result; } }
MuzimaSyncService { public int[] downloadEncountersForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingEncounters) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadEncountersForPatientsByPatientUUIDs(patientlist, replaceExistingEncounters); if (result[0] != SUCCESS) { Log.e(getClass().getSimpleName(), "Could not download encounters"); updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } return result; } MuzimaSyncService(MuzimaApplication muzimaContext); }
MuzimaSyncService { public int[] downloadEncountersForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingEncounters) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadEncountersForPatientsByPatientUUIDs(patientlist, replaceExistingEncounters); if (result[0] != SUCCESS) { Log.e(getClass().getSimpleName(), "Could not download encounters"); updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } 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[] downloadEncountersForPatientsByCohortUUIDs(String[] cohortUuids, boolean replaceExistingEncounters) { int[] result = new int[4]; List<Patient> patients; try { patients = patientController.getPatientsForCohorts(cohortUuids); List<String> patientlist = new ArrayList(); for (Patient patient : patients) { patientlist.add(patient.getUuid()); } result = downloadEncountersForPatientsByPatientUUIDs(patientlist, replaceExistingEncounters); if (result[0] != SUCCESS) { Log.e(getClass().getSimpleName(), "Could not download encounters"); updateProgressDialog(muzimaApplication.getString(R.string.error_encounter_download)); } } catch (PatientController.PatientLoadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading patients.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } 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(); }
@Test public void shouldDeleteVoidedEncountersWhenDownloadingEncounters() throws EncounterController.DeleteEncounterException, EncounterController.DownloadEncounterException, SetupConfigurationController.SetupConfigurationFetchException { String[] patientUuids = new String[]{"patientUuid1", "patientUuid2"}; final Patient patient = new Patient() {{ setUuid("patient1"); }}; SetupConfigurationTemplate setupConfigurationTemplate = new SetupConfigurationTemplate(); setupConfigurationTemplate.setUuid("dummySetupConfig"); when(setupConfigurationController.getActiveSetupConfigurationTemplate()).thenReturn(setupConfigurationTemplate); List<Encounter> encounters = new ArrayList<>(); encounters.add(new Encounter(){{setPatient(patient);}}); Encounter voidedEncounter = mock(Encounter.class); when(voidedEncounter.isVoided()).thenReturn(true); when(voidedEncounter.getPatient()).thenReturn(patient); encounters.add(voidedEncounter); when(encounterController.downloadEncountersByPatientUuids(asList(patientUuids), setupConfigurationTemplate.getUuid())).thenReturn(encounters); muzimaSyncService.downloadEncountersForPatientsByPatientUUIDs(asList(patientUuids),true); verify(encounterController).deleteEncounters(Collections.singletonList(voidedEncounter)); }
public int[] downloadEncountersForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingEncounters) { int[] result = new int[4]; try { String activeSetupConfigUuid = null; try { SetupConfigurationTemplate setupConfigurationTemplate = setupConfigurationController.getActiveSetupConfigurationTemplate(); if (setupConfigurationTemplate != null) { activeSetupConfigUuid = setupConfigurationTemplate.getUuid(); } } catch (SetupConfigurationController.SetupConfigurationFetchException e) { Log.e(getClass().getSimpleName(), "Could not obtain active setup config", e); } List<List<String>> slicedPatientUuids = split(patientUuids); Set<String> patientsForDownloadedEncounters = new HashSet(); long totalTimeDownloading = 0, totalTimeReplacing = 0, totalTimeSaving = 0; int i = 0; for (List<String> slicedPatientUuid : slicedPatientUuids) { Log.i(getClass().getSimpleName(), "Downloading encounters for " + slicedPatientUuid.size() + " patients"); long startDownloadEncounters = System.currentTimeMillis(); List<Encounter> allEncounters = new ArrayList<>(encounterController.downloadEncountersByPatientUuids(slicedPatientUuid, activeSetupConfigUuid)); long endDownloadObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Downloading encounters : " + (endDownloadObservations - startDownloadEncounters) / 1000 + " sec\n"); totalTimeDownloading += endDownloadObservations - startDownloadEncounters; Log.i(getClass().getSimpleName(), "Encounters download successful with " + allEncounters.size() + " encounters"); for (Encounter encounter : allEncounters) { patientsForDownloadedEncounters.add(encounter.getPatient().getUuid()); } Log.i(getClass().getSimpleName(), "Downloaded Encounters for patient " + patientsForDownloadedEncounters.size() + " of " + patientUuids.size()); updateProgressDialog(muzimaApplication.getString(R.string.info_encounter_download_progress, patientsForDownloadedEncounters.size(), patientUuids.size())); ArrayList<Encounter> voidedEncounters = getVoidedEncounters(allEncounters); allEncounters.removeAll(voidedEncounters); encounterController.deleteEncounters(voidedEncounters); Log.i(getClass().getSimpleName(), "Voided encounters delete successful with " + voidedEncounters.size() + " encounters"); if (replaceExistingEncounters) { encounterController.replaceEncounters(allEncounters); long replacedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Replacing encounters for patients: " + (replacedEncounters - endDownloadObservations) / 1000 + " sec"); totalTimeReplacing += replacedEncounters - endDownloadObservations; } else { encounterController.saveEncounters(allEncounters); long savedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Saving encounters : " + (savedEncounters - endDownloadObservations) / 1000 + " sec\n"); totalTimeSaving += savedEncounters - endDownloadObservations; } result[1] += allEncounters.size(); result[2] += voidedEncounters.size(); } Log.d(getClass().getSimpleName(), "Total Downloading encounters : " + totalTimeDownloading / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Replacing encounters : " + totalTimeReplacing / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Saving encounters : " + totalTimeSaving / 1000 + " sec\n"); result[0] = SUCCESS; result[3] = patientsForDownloadedEncounters.size(); } catch (EncounterController.DownloadEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading encounters.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (EncounterController.ReplaceEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while replacing encounters.", e); result[0] = SyncStatusConstants.REPLACE_ERROR; } catch (EncounterController.DeleteEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while deleting encounters.", e); result[0] = SyncStatusConstants.DELETE_ERROR; } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while saving encounters.", e); result[0] = SyncStatusConstants.SAVE_ERROR; } return result; }
MuzimaSyncService { public int[] downloadEncountersForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingEncounters) { int[] result = new int[4]; try { String activeSetupConfigUuid = null; try { SetupConfigurationTemplate setupConfigurationTemplate = setupConfigurationController.getActiveSetupConfigurationTemplate(); if (setupConfigurationTemplate != null) { activeSetupConfigUuid = setupConfigurationTemplate.getUuid(); } } catch (SetupConfigurationController.SetupConfigurationFetchException e) { Log.e(getClass().getSimpleName(), "Could not obtain active setup config", e); } List<List<String>> slicedPatientUuids = split(patientUuids); Set<String> patientsForDownloadedEncounters = new HashSet(); long totalTimeDownloading = 0, totalTimeReplacing = 0, totalTimeSaving = 0; int i = 0; for (List<String> slicedPatientUuid : slicedPatientUuids) { Log.i(getClass().getSimpleName(), "Downloading encounters for " + slicedPatientUuid.size() + " patients"); long startDownloadEncounters = System.currentTimeMillis(); List<Encounter> allEncounters = new ArrayList<>(encounterController.downloadEncountersByPatientUuids(slicedPatientUuid, activeSetupConfigUuid)); long endDownloadObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Downloading encounters : " + (endDownloadObservations - startDownloadEncounters) / 1000 + " sec\n"); totalTimeDownloading += endDownloadObservations - startDownloadEncounters; Log.i(getClass().getSimpleName(), "Encounters download successful with " + allEncounters.size() + " encounters"); for (Encounter encounter : allEncounters) { patientsForDownloadedEncounters.add(encounter.getPatient().getUuid()); } Log.i(getClass().getSimpleName(), "Downloaded Encounters for patient " + patientsForDownloadedEncounters.size() + " of " + patientUuids.size()); updateProgressDialog(muzimaApplication.getString(R.string.info_encounter_download_progress, patientsForDownloadedEncounters.size(), patientUuids.size())); ArrayList<Encounter> voidedEncounters = getVoidedEncounters(allEncounters); allEncounters.removeAll(voidedEncounters); encounterController.deleteEncounters(voidedEncounters); Log.i(getClass().getSimpleName(), "Voided encounters delete successful with " + voidedEncounters.size() + " encounters"); if (replaceExistingEncounters) { encounterController.replaceEncounters(allEncounters); long replacedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Replacing encounters for patients: " + (replacedEncounters - endDownloadObservations) / 1000 + " sec"); totalTimeReplacing += replacedEncounters - endDownloadObservations; } else { encounterController.saveEncounters(allEncounters); long savedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Saving encounters : " + (savedEncounters - endDownloadObservations) / 1000 + " sec\n"); totalTimeSaving += savedEncounters - endDownloadObservations; } result[1] += allEncounters.size(); result[2] += voidedEncounters.size(); } Log.d(getClass().getSimpleName(), "Total Downloading encounters : " + totalTimeDownloading / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Replacing encounters : " + totalTimeReplacing / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Saving encounters : " + totalTimeSaving / 1000 + " sec\n"); result[0] = SUCCESS; result[3] = patientsForDownloadedEncounters.size(); } catch (EncounterController.DownloadEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading encounters.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (EncounterController.ReplaceEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while replacing encounters.", e); result[0] = SyncStatusConstants.REPLACE_ERROR; } catch (EncounterController.DeleteEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while deleting encounters.", e); result[0] = SyncStatusConstants.DELETE_ERROR; } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while saving encounters.", e); result[0] = SyncStatusConstants.SAVE_ERROR; } return result; } }
MuzimaSyncService { public int[] downloadEncountersForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingEncounters) { int[] result = new int[4]; try { String activeSetupConfigUuid = null; try { SetupConfigurationTemplate setupConfigurationTemplate = setupConfigurationController.getActiveSetupConfigurationTemplate(); if (setupConfigurationTemplate != null) { activeSetupConfigUuid = setupConfigurationTemplate.getUuid(); } } catch (SetupConfigurationController.SetupConfigurationFetchException e) { Log.e(getClass().getSimpleName(), "Could not obtain active setup config", e); } List<List<String>> slicedPatientUuids = split(patientUuids); Set<String> patientsForDownloadedEncounters = new HashSet(); long totalTimeDownloading = 0, totalTimeReplacing = 0, totalTimeSaving = 0; int i = 0; for (List<String> slicedPatientUuid : slicedPatientUuids) { Log.i(getClass().getSimpleName(), "Downloading encounters for " + slicedPatientUuid.size() + " patients"); long startDownloadEncounters = System.currentTimeMillis(); List<Encounter> allEncounters = new ArrayList<>(encounterController.downloadEncountersByPatientUuids(slicedPatientUuid, activeSetupConfigUuid)); long endDownloadObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Downloading encounters : " + (endDownloadObservations - startDownloadEncounters) / 1000 + " sec\n"); totalTimeDownloading += endDownloadObservations - startDownloadEncounters; Log.i(getClass().getSimpleName(), "Encounters download successful with " + allEncounters.size() + " encounters"); for (Encounter encounter : allEncounters) { patientsForDownloadedEncounters.add(encounter.getPatient().getUuid()); } Log.i(getClass().getSimpleName(), "Downloaded Encounters for patient " + patientsForDownloadedEncounters.size() + " of " + patientUuids.size()); updateProgressDialog(muzimaApplication.getString(R.string.info_encounter_download_progress, patientsForDownloadedEncounters.size(), patientUuids.size())); ArrayList<Encounter> voidedEncounters = getVoidedEncounters(allEncounters); allEncounters.removeAll(voidedEncounters); encounterController.deleteEncounters(voidedEncounters); Log.i(getClass().getSimpleName(), "Voided encounters delete successful with " + voidedEncounters.size() + " encounters"); if (replaceExistingEncounters) { encounterController.replaceEncounters(allEncounters); long replacedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Replacing encounters for patients: " + (replacedEncounters - endDownloadObservations) / 1000 + " sec"); totalTimeReplacing += replacedEncounters - endDownloadObservations; } else { encounterController.saveEncounters(allEncounters); long savedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Saving encounters : " + (savedEncounters - endDownloadObservations) / 1000 + " sec\n"); totalTimeSaving += savedEncounters - endDownloadObservations; } result[1] += allEncounters.size(); result[2] += voidedEncounters.size(); } Log.d(getClass().getSimpleName(), "Total Downloading encounters : " + totalTimeDownloading / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Replacing encounters : " + totalTimeReplacing / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Saving encounters : " + totalTimeSaving / 1000 + " sec\n"); result[0] = SUCCESS; result[3] = patientsForDownloadedEncounters.size(); } catch (EncounterController.DownloadEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading encounters.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (EncounterController.ReplaceEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while replacing encounters.", e); result[0] = SyncStatusConstants.REPLACE_ERROR; } catch (EncounterController.DeleteEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while deleting encounters.", e); result[0] = SyncStatusConstants.DELETE_ERROR; } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while saving encounters.", e); result[0] = SyncStatusConstants.SAVE_ERROR; } return result; } MuzimaSyncService(MuzimaApplication muzimaContext); }
MuzimaSyncService { public int[] downloadEncountersForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingEncounters) { int[] result = new int[4]; try { String activeSetupConfigUuid = null; try { SetupConfigurationTemplate setupConfigurationTemplate = setupConfigurationController.getActiveSetupConfigurationTemplate(); if (setupConfigurationTemplate != null) { activeSetupConfigUuid = setupConfigurationTemplate.getUuid(); } } catch (SetupConfigurationController.SetupConfigurationFetchException e) { Log.e(getClass().getSimpleName(), "Could not obtain active setup config", e); } List<List<String>> slicedPatientUuids = split(patientUuids); Set<String> patientsForDownloadedEncounters = new HashSet(); long totalTimeDownloading = 0, totalTimeReplacing = 0, totalTimeSaving = 0; int i = 0; for (List<String> slicedPatientUuid : slicedPatientUuids) { Log.i(getClass().getSimpleName(), "Downloading encounters for " + slicedPatientUuid.size() + " patients"); long startDownloadEncounters = System.currentTimeMillis(); List<Encounter> allEncounters = new ArrayList<>(encounterController.downloadEncountersByPatientUuids(slicedPatientUuid, activeSetupConfigUuid)); long endDownloadObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Downloading encounters : " + (endDownloadObservations - startDownloadEncounters) / 1000 + " sec\n"); totalTimeDownloading += endDownloadObservations - startDownloadEncounters; Log.i(getClass().getSimpleName(), "Encounters download successful with " + allEncounters.size() + " encounters"); for (Encounter encounter : allEncounters) { patientsForDownloadedEncounters.add(encounter.getPatient().getUuid()); } Log.i(getClass().getSimpleName(), "Downloaded Encounters for patient " + patientsForDownloadedEncounters.size() + " of " + patientUuids.size()); updateProgressDialog(muzimaApplication.getString(R.string.info_encounter_download_progress, patientsForDownloadedEncounters.size(), patientUuids.size())); ArrayList<Encounter> voidedEncounters = getVoidedEncounters(allEncounters); allEncounters.removeAll(voidedEncounters); encounterController.deleteEncounters(voidedEncounters); Log.i(getClass().getSimpleName(), "Voided encounters delete successful with " + voidedEncounters.size() + " encounters"); if (replaceExistingEncounters) { encounterController.replaceEncounters(allEncounters); long replacedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Replacing encounters for patients: " + (replacedEncounters - endDownloadObservations) / 1000 + " sec"); totalTimeReplacing += replacedEncounters - endDownloadObservations; } else { encounterController.saveEncounters(allEncounters); long savedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Saving encounters : " + (savedEncounters - endDownloadObservations) / 1000 + " sec\n"); totalTimeSaving += savedEncounters - endDownloadObservations; } result[1] += allEncounters.size(); result[2] += voidedEncounters.size(); } Log.d(getClass().getSimpleName(), "Total Downloading encounters : " + totalTimeDownloading / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Replacing encounters : " + totalTimeReplacing / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Saving encounters : " + totalTimeSaving / 1000 + " sec\n"); result[0] = SUCCESS; result[3] = patientsForDownloadedEncounters.size(); } catch (EncounterController.DownloadEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading encounters.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (EncounterController.ReplaceEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while replacing encounters.", e); result[0] = SyncStatusConstants.REPLACE_ERROR; } catch (EncounterController.DeleteEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while deleting encounters.", e); result[0] = SyncStatusConstants.DELETE_ERROR; } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while saving encounters.", e); result[0] = SyncStatusConstants.SAVE_ERROR; } 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[] downloadEncountersForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingEncounters) { int[] result = new int[4]; try { String activeSetupConfigUuid = null; try { SetupConfigurationTemplate setupConfigurationTemplate = setupConfigurationController.getActiveSetupConfigurationTemplate(); if (setupConfigurationTemplate != null) { activeSetupConfigUuid = setupConfigurationTemplate.getUuid(); } } catch (SetupConfigurationController.SetupConfigurationFetchException e) { Log.e(getClass().getSimpleName(), "Could not obtain active setup config", e); } List<List<String>> slicedPatientUuids = split(patientUuids); Set<String> patientsForDownloadedEncounters = new HashSet(); long totalTimeDownloading = 0, totalTimeReplacing = 0, totalTimeSaving = 0; int i = 0; for (List<String> slicedPatientUuid : slicedPatientUuids) { Log.i(getClass().getSimpleName(), "Downloading encounters for " + slicedPatientUuid.size() + " patients"); long startDownloadEncounters = System.currentTimeMillis(); List<Encounter> allEncounters = new ArrayList<>(encounterController.downloadEncountersByPatientUuids(slicedPatientUuid, activeSetupConfigUuid)); long endDownloadObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Downloading encounters : " + (endDownloadObservations - startDownloadEncounters) / 1000 + " sec\n"); totalTimeDownloading += endDownloadObservations - startDownloadEncounters; Log.i(getClass().getSimpleName(), "Encounters download successful with " + allEncounters.size() + " encounters"); for (Encounter encounter : allEncounters) { patientsForDownloadedEncounters.add(encounter.getPatient().getUuid()); } Log.i(getClass().getSimpleName(), "Downloaded Encounters for patient " + patientsForDownloadedEncounters.size() + " of " + patientUuids.size()); updateProgressDialog(muzimaApplication.getString(R.string.info_encounter_download_progress, patientsForDownloadedEncounters.size(), patientUuids.size())); ArrayList<Encounter> voidedEncounters = getVoidedEncounters(allEncounters); allEncounters.removeAll(voidedEncounters); encounterController.deleteEncounters(voidedEncounters); Log.i(getClass().getSimpleName(), "Voided encounters delete successful with " + voidedEncounters.size() + " encounters"); if (replaceExistingEncounters) { encounterController.replaceEncounters(allEncounters); long replacedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Replacing encounters for patients: " + (replacedEncounters - endDownloadObservations) / 1000 + " sec"); totalTimeReplacing += replacedEncounters - endDownloadObservations; } else { encounterController.saveEncounters(allEncounters); long savedEncounters = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Saving encounters : " + (savedEncounters - endDownloadObservations) / 1000 + " sec\n"); totalTimeSaving += savedEncounters - endDownloadObservations; } result[1] += allEncounters.size(); result[2] += voidedEncounters.size(); } Log.d(getClass().getSimpleName(), "Total Downloading encounters : " + totalTimeDownloading / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Replacing encounters : " + totalTimeReplacing / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Saving encounters : " + totalTimeSaving / 1000 + " sec\n"); result[0] = SUCCESS; result[3] = patientsForDownloadedEncounters.size(); } catch (EncounterController.DownloadEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading encounters.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (EncounterController.ReplaceEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while replacing encounters.", e); result[0] = SyncStatusConstants.REPLACE_ERROR; } catch (EncounterController.DeleteEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while deleting encounters.", e); result[0] = SyncStatusConstants.DELETE_ERROR; } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Exception thrown while saving encounters.", e); result[0] = SyncStatusConstants.SAVE_ERROR; } 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(); }
@Test public void consolidatePatients_shouldGetAllPatientsConsolidateSavePatientFromServerAndDeleteLocalPatient() throws PatientController.PatientSaveException { Patient localPatient = mock(Patient.class); Patient remotePatient = mock(Patient.class); when(patientController.consolidateTemporaryPatient(localPatient)).thenReturn(remotePatient); when(patientController.getAllPatientsCreatedLocallyAndNotSynced()).thenReturn(Collections.singletonList(localPatient)); muzimaSyncService.consolidatePatients(); verify(patientController).getAllPatientsCreatedLocallyAndNotSynced(); verify(patientController).consolidateTemporaryPatient(localPatient); verify(patientController).savePatient(remotePatient); verify(patientController).deletePatient(localPatient); }
public void consolidatePatients() { List<Patient> allLocalPatients = patientController.getAllPatientsCreatedLocallyAndNotSynced(); for (Patient localPatient : allLocalPatients) { Patient patientFromServer = patientController.consolidateTemporaryPatient(localPatient); if (patientFromServer != null) { checkChangeInPatientId(localPatient, patientFromServer); patientFromServer.addIdentifier(localPatient.getIdentifier(LOCAL_PATIENT)); patientController.deletePatient(localPatient); try { patientController.savePatient(patientFromServer); } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving patients.", e); } } } }
MuzimaSyncService { public void consolidatePatients() { List<Patient> allLocalPatients = patientController.getAllPatientsCreatedLocallyAndNotSynced(); for (Patient localPatient : allLocalPatients) { Patient patientFromServer = patientController.consolidateTemporaryPatient(localPatient); if (patientFromServer != null) { checkChangeInPatientId(localPatient, patientFromServer); patientFromServer.addIdentifier(localPatient.getIdentifier(LOCAL_PATIENT)); patientController.deletePatient(localPatient); try { patientController.savePatient(patientFromServer); } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving patients.", e); } } } } }
MuzimaSyncService { public void consolidatePatients() { List<Patient> allLocalPatients = patientController.getAllPatientsCreatedLocallyAndNotSynced(); for (Patient localPatient : allLocalPatients) { Patient patientFromServer = patientController.consolidateTemporaryPatient(localPatient); if (patientFromServer != null) { checkChangeInPatientId(localPatient, patientFromServer); patientFromServer.addIdentifier(localPatient.getIdentifier(LOCAL_PATIENT)); patientController.deletePatient(localPatient); try { patientController.savePatient(patientFromServer); } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving patients.", e); } } } } MuzimaSyncService(MuzimaApplication muzimaContext); }
MuzimaSyncService { public void consolidatePatients() { List<Patient> allLocalPatients = patientController.getAllPatientsCreatedLocallyAndNotSynced(); for (Patient localPatient : allLocalPatients) { Patient patientFromServer = patientController.consolidateTemporaryPatient(localPatient); if (patientFromServer != null) { checkChangeInPatientId(localPatient, patientFromServer); patientFromServer.addIdentifier(localPatient.getIdentifier(LOCAL_PATIENT)); patientController.deletePatient(localPatient); try { patientController.savePatient(patientFromServer); } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving patients.", e); } } } } 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 void consolidatePatients() { List<Patient> allLocalPatients = patientController.getAllPatientsCreatedLocallyAndNotSynced(); for (Patient localPatient : allLocalPatients) { Patient patientFromServer = patientController.consolidateTemporaryPatient(localPatient); if (patientFromServer != null) { checkChangeInPatientId(localPatient, patientFromServer); patientFromServer.addIdentifier(localPatient.getIdentifier(LOCAL_PATIENT)); patientController.deletePatient(localPatient); try { patientController.savePatient(patientFromServer); } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving patients.", e); } } } } 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(); }
@Test public void shouldUpdatePatientsThatAreNotInCohorts() throws PatientController.PatientSaveException, PatientController.PatientDownloadException { Patient localPatient1 = patient("patientUUID1"); Patient localPatient2 = patient("patientUUID2"); Patient serverPatient1 = patient("patientUUID3"); when(patientController.getPatientsNotInCohorts()).thenReturn(asList(localPatient1, localPatient2)); when(patientController.downloadPatientByUUID("patientUUID1")).thenReturn(serverPatient1); when(patientController.downloadPatientByUUID("patientUUID2")).thenReturn(null); muzimaSyncService.updatePatientsNotPartOfCohorts(); verify(patientController).downloadPatientByUUID("patientUUID1"); verify(patientController).downloadPatientByUUID("patientUUID2"); verify(patientController).replacePatients(Collections.singletonList(serverPatient1)); }
public List<Patient> updatePatientsNotPartOfCohorts() { List<Patient> patientsNotInCohorts = patientController.getPatientsNotInCohorts(); List<Patient> downloadedPatients = new ArrayList<>(); try { for (Patient patient : patientsNotInCohorts) { downloadedPatients.add(patientController.downloadPatientByUUID(patient.getUuid())); } downloadedPatients.removeAll(singleton(null)); patientController.replacePatients(downloadedPatients); } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Exception thrown while updating patients from server.", e); } catch (PatientController.PatientDownloadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading patients from server.", e); } return downloadedPatients; }
MuzimaSyncService { public List<Patient> updatePatientsNotPartOfCohorts() { List<Patient> patientsNotInCohorts = patientController.getPatientsNotInCohorts(); List<Patient> downloadedPatients = new ArrayList<>(); try { for (Patient patient : patientsNotInCohorts) { downloadedPatients.add(patientController.downloadPatientByUUID(patient.getUuid())); } downloadedPatients.removeAll(singleton(null)); patientController.replacePatients(downloadedPatients); } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Exception thrown while updating patients from server.", e); } catch (PatientController.PatientDownloadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading patients from server.", e); } return downloadedPatients; } }
MuzimaSyncService { public List<Patient> updatePatientsNotPartOfCohorts() { List<Patient> patientsNotInCohorts = patientController.getPatientsNotInCohorts(); List<Patient> downloadedPatients = new ArrayList<>(); try { for (Patient patient : patientsNotInCohorts) { downloadedPatients.add(patientController.downloadPatientByUUID(patient.getUuid())); } downloadedPatients.removeAll(singleton(null)); patientController.replacePatients(downloadedPatients); } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Exception thrown while updating patients from server.", e); } catch (PatientController.PatientDownloadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading patients from server.", e); } return downloadedPatients; } MuzimaSyncService(MuzimaApplication muzimaContext); }
MuzimaSyncService { public List<Patient> updatePatientsNotPartOfCohorts() { List<Patient> patientsNotInCohorts = patientController.getPatientsNotInCohorts(); List<Patient> downloadedPatients = new ArrayList<>(); try { for (Patient patient : patientsNotInCohorts) { downloadedPatients.add(patientController.downloadPatientByUUID(patient.getUuid())); } downloadedPatients.removeAll(singleton(null)); patientController.replacePatients(downloadedPatients); } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Exception thrown while updating patients from server.", e); } catch (PatientController.PatientDownloadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading patients from server.", e); } return downloadedPatients; } 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 List<Patient> updatePatientsNotPartOfCohorts() { List<Patient> patientsNotInCohorts = patientController.getPatientsNotInCohorts(); List<Patient> downloadedPatients = new ArrayList<>(); try { for (Patient patient : patientsNotInCohorts) { downloadedPatients.add(patientController.downloadPatientByUUID(patient.getUuid())); } downloadedPatients.removeAll(singleton(null)); patientController.replacePatients(downloadedPatients); } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Exception thrown while updating patients from server.", e); } catch (PatientController.PatientDownloadException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading patients from server.", e); } return downloadedPatients; } 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(); }
@Test public void shouldDownloadAndSavePatientsGivenByUUID() throws PatientController.PatientDownloadException, PatientController.PatientSaveException { Patient patient1 = patient("patientUUID1"); Patient patient2 = patient("patientUUID2"); String[] patientUUIDs = new String[]{"patientUUID1", "patientUUID2"}; when(patientController.downloadPatientByUUID("patientUUID1")).thenReturn(patient1); when(patientController.downloadPatientByUUID("patientUUID2")).thenReturn(patient2); int[] result = muzimaSyncService.downloadPatients(patientUUIDs); assertThat(result[0], is(SyncStatusConstants.SUCCESS)); assertThat(result[1], is(2)); verify(patientController).savePatients(asList(patient1, patient2)); }
public int[] downloadPatients(String[] patientUUIDs) { int[] result = new int[2]; List<Patient> downloadedPatients; try { downloadedPatients = downloadPatientsByUUID(patientUUIDs); patientController.savePatients(downloadedPatients); Log.e(getClass().getSimpleName(), "DOWNLOADED PATIENTS."); result[0] = SUCCESS; result[1] = downloadedPatients.size(); } catch (PatientController.PatientDownloadException e) { Log.e(getClass().getSimpleName(), "Error while downloading patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } return result; }
MuzimaSyncService { public int[] downloadPatients(String[] patientUUIDs) { int[] result = new int[2]; List<Patient> downloadedPatients; try { downloadedPatients = downloadPatientsByUUID(patientUUIDs); patientController.savePatients(downloadedPatients); Log.e(getClass().getSimpleName(), "DOWNLOADED PATIENTS."); result[0] = SUCCESS; result[1] = downloadedPatients.size(); } catch (PatientController.PatientDownloadException e) { Log.e(getClass().getSimpleName(), "Error while downloading patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } return result; } }
MuzimaSyncService { public int[] downloadPatients(String[] patientUUIDs) { int[] result = new int[2]; List<Patient> downloadedPatients; try { downloadedPatients = downloadPatientsByUUID(patientUUIDs); patientController.savePatients(downloadedPatients); Log.e(getClass().getSimpleName(), "DOWNLOADED PATIENTS."); result[0] = SUCCESS; result[1] = downloadedPatients.size(); } catch (PatientController.PatientDownloadException e) { Log.e(getClass().getSimpleName(), "Error while downloading patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } return result; } MuzimaSyncService(MuzimaApplication muzimaContext); }
MuzimaSyncService { public int[] downloadPatients(String[] patientUUIDs) { int[] result = new int[2]; List<Patient> downloadedPatients; try { downloadedPatients = downloadPatientsByUUID(patientUUIDs); patientController.savePatients(downloadedPatients); Log.e(getClass().getSimpleName(), "DOWNLOADED PATIENTS."); result[0] = SUCCESS; result[1] = downloadedPatients.size(); } catch (PatientController.PatientDownloadException e) { Log.e(getClass().getSimpleName(), "Error while downloading patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } 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[] downloadPatients(String[] patientUUIDs) { int[] result = new int[2]; List<Patient> downloadedPatients; try { downloadedPatients = downloadPatientsByUUID(patientUUIDs); patientController.savePatients(downloadedPatients); Log.e(getClass().getSimpleName(), "DOWNLOADED PATIENTS."); result[0] = SUCCESS; result[1] = downloadedPatients.size(); } catch (PatientController.PatientDownloadException e) { Log.e(getClass().getSimpleName(), "Error while downloading patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } 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(); }
@Test public void shouldReturnFailureIfDownloadFails() throws PatientController.PatientDownloadException, PatientController.PatientSaveException { Patient patient1 = patient("patientUUID1"); String[] patientUUIDs = new String[]{"patientUUID1"}; when(patientController.downloadPatientByUUID("patientUUID1")).thenReturn(patient1); doThrow(new PatientController.PatientSaveException(new Throwable())).when(patientController).savePatients(Collections.singletonList(patient1)); int[] result = muzimaSyncService.downloadPatients(patientUUIDs); assertThat(result[0], is(SyncStatusConstants.DOWNLOAD_ERROR)); assertThat(result[1], is(0)); verify(patientController).savePatients(Collections.singletonList(patient1)); }
public int[] downloadPatients(String[] patientUUIDs) { int[] result = new int[2]; List<Patient> downloadedPatients; try { downloadedPatients = downloadPatientsByUUID(patientUUIDs); patientController.savePatients(downloadedPatients); Log.e(getClass().getSimpleName(), "DOWNLOADED PATIENTS."); result[0] = SUCCESS; result[1] = downloadedPatients.size(); } catch (PatientController.PatientDownloadException e) { Log.e(getClass().getSimpleName(), "Error while downloading patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } return result; }
MuzimaSyncService { public int[] downloadPatients(String[] patientUUIDs) { int[] result = new int[2]; List<Patient> downloadedPatients; try { downloadedPatients = downloadPatientsByUUID(patientUUIDs); patientController.savePatients(downloadedPatients); Log.e(getClass().getSimpleName(), "DOWNLOADED PATIENTS."); result[0] = SUCCESS; result[1] = downloadedPatients.size(); } catch (PatientController.PatientDownloadException e) { Log.e(getClass().getSimpleName(), "Error while downloading patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } return result; } }
MuzimaSyncService { public int[] downloadPatients(String[] patientUUIDs) { int[] result = new int[2]; List<Patient> downloadedPatients; try { downloadedPatients = downloadPatientsByUUID(patientUUIDs); patientController.savePatients(downloadedPatients); Log.e(getClass().getSimpleName(), "DOWNLOADED PATIENTS."); result[0] = SUCCESS; result[1] = downloadedPatients.size(); } catch (PatientController.PatientDownloadException e) { Log.e(getClass().getSimpleName(), "Error while downloading patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } return result; } MuzimaSyncService(MuzimaApplication muzimaContext); }
MuzimaSyncService { public int[] downloadPatients(String[] patientUUIDs) { int[] result = new int[2]; List<Patient> downloadedPatients; try { downloadedPatients = downloadPatientsByUUID(patientUUIDs); patientController.savePatients(downloadedPatients); Log.e(getClass().getSimpleName(), "DOWNLOADED PATIENTS."); result[0] = SUCCESS; result[1] = downloadedPatients.size(); } catch (PatientController.PatientDownloadException e) { Log.e(getClass().getSimpleName(), "Error while downloading patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } 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[] downloadPatients(String[] patientUUIDs) { int[] result = new int[2]; List<Patient> downloadedPatients; try { downloadedPatients = downloadPatientsByUUID(patientUUIDs); patientController.savePatients(downloadedPatients); Log.e(getClass().getSimpleName(), "DOWNLOADED PATIENTS."); result[0] = SUCCESS; result[1] = downloadedPatients.size(); } catch (PatientController.PatientDownloadException e) { Log.e(getClass().getSimpleName(), "Error while downloading patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (PatientController.PatientSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving patients.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } 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(); }
@Test public void shouldDeleteVoidedObservationsWhenDownloadingObservations() throws ObservationController.DeleteObservationException, ObservationController.DownloadObservationException, ReplaceObservationException, ConceptController.ConceptFetchException { List<String> patientUuids = Collections.singletonList("patientUuid"); final Patient patient = new Patient() {{ setUuid("patientUuid"); }}; List<Observation> observations = new ArrayList<>(); Observation anObservation = mock(Observation.class); when(anObservation.isVoided()).thenReturn(false); when(anObservation.getPerson()).thenReturn(patient); observations.add(anObservation); Observation voidedObservation = mock(Observation.class); when(voidedObservation.isVoided()).thenReturn(true); when(voidedObservation.getPerson()).thenReturn(patient); observations.add(voidedObservation); List<Concept> conceptList = new ArrayList<Concept>() {{ add(new Concept() {{ setUuid("concept1"); }}); }}; when(conceptController.getConcepts()).thenReturn(conceptList); when(observationController.downloadObservationsByPatientUuidsAndConceptUuids (eq(patientUuids), eq(Collections.singletonList("concept1")))).thenReturn(observations); muzimaSyncService.downloadObservationsForPatientsByPatientUUIDs(patientUuids,true); verify(observationController).deleteObservations(Collections.singletonList(voidedObservation)); verify(observationController).replaceObservations(Collections.singletonList(anObservation)); }
public int[] downloadObservationsForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingObservations) { int[] result = new int[4]; try { List<String> conceptUuidsFromConcepts = getConceptUuidsFromConcepts(conceptController.getConcepts()); List<List<String>> slicedPatientUuids = split(patientUuids); List<List<String>> slicedConceptUuids = split(conceptUuidsFromConcepts); Set<String> patientUuidsForDownloadedObs = new HashSet<>(); long totalTimeDownloading = 0, totalTimeReplacing = 0, totalTimeSaving = 0; int i = 0; for (List<String> slicedPatientUuid : slicedPatientUuids) { for (List<String> slicedConceptUuid : slicedConceptUuids) { long startDownloadObservations = System.currentTimeMillis(); List<Observation> allObservations = new ArrayList<>(observationController.downloadObservationsByPatientUuidsAndConceptUuids( slicedPatientUuid, slicedConceptUuid)); for (Observation observation : allObservations) { patientUuidsForDownloadedObs.add(observation.getPerson().getUuid()); } updateProgressDialog(muzimaApplication.getString(R.string.info_observations_download_progress, patientUuidsForDownloadedObs.size(), patientUuids.size())); Log.i(getClass().getSimpleName(), "Downloading observations for " + slicedPatientUuid.size() + " patients and " + slicedConceptUuid.size() + " concepts"); long endDownloadObservations = System.currentTimeMillis(); Log.i(getClass().getSimpleName(), "Observations download successful with " + allObservations.size() + " observations"); Log.d(getClass().getSimpleName(), "In Downloading observations : " + (endDownloadObservations - startDownloadObservations) / 1000 + " sec"); totalTimeDownloading += endDownloadObservations - startDownloadObservations; List<Observation> voidedObservations = getVoidedObservations(allObservations); observationController.deleteObservations(voidedObservations); allObservations.removeAll(voidedObservations); Log.i(getClass().getSimpleName(), "Voided observations delete successful with " + voidedObservations.size() + " observations"); if (replaceExistingObservations) { observationController.replaceObservations(allObservations); long replacedObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Replacing observations for patients: " + (replacedObservations - endDownloadObservations) / 1000 + " sec"); totalTimeReplacing += replacedObservations - endDownloadObservations; } else { observationController.saveObservations(allObservations); long savedObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In saving observations : " + (savedObservations - endDownloadObservations) / 1000 + " sec\n"); totalTimeSaving += savedObservations - endDownloadObservations; } result[1] += allObservations.size(); result[2] += voidedObservations.size(); } } result[3] = patientUuidsForDownloadedObs.size(); result[0] = SUCCESS; Log.d(getClass().getSimpleName(), "Total Downloading observations : " + totalTimeDownloading / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Replacing observations : " + totalTimeReplacing / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Saving observations : " + totalTimeSaving / 1000 + " sec\n"); } catch (ObservationController.DownloadObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading observations.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (ObservationController.ReplaceObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while replacing observations.", e); result[0] = SyncStatusConstants.REPLACE_ERROR; } catch (ConceptController.ConceptFetchException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading concepts.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } catch (ObservationController.DeleteObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while deleting observations.", e); result[0] = SyncStatusConstants.DELETE_ERROR; } catch (ObservationController.SaveObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while saving observations.", e); result[0] = SyncStatusConstants.SAVE_ERROR; } return result; }
MuzimaSyncService { public int[] downloadObservationsForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingObservations) { int[] result = new int[4]; try { List<String> conceptUuidsFromConcepts = getConceptUuidsFromConcepts(conceptController.getConcepts()); List<List<String>> slicedPatientUuids = split(patientUuids); List<List<String>> slicedConceptUuids = split(conceptUuidsFromConcepts); Set<String> patientUuidsForDownloadedObs = new HashSet<>(); long totalTimeDownloading = 0, totalTimeReplacing = 0, totalTimeSaving = 0; int i = 0; for (List<String> slicedPatientUuid : slicedPatientUuids) { for (List<String> slicedConceptUuid : slicedConceptUuids) { long startDownloadObservations = System.currentTimeMillis(); List<Observation> allObservations = new ArrayList<>(observationController.downloadObservationsByPatientUuidsAndConceptUuids( slicedPatientUuid, slicedConceptUuid)); for (Observation observation : allObservations) { patientUuidsForDownloadedObs.add(observation.getPerson().getUuid()); } updateProgressDialog(muzimaApplication.getString(R.string.info_observations_download_progress, patientUuidsForDownloadedObs.size(), patientUuids.size())); Log.i(getClass().getSimpleName(), "Downloading observations for " + slicedPatientUuid.size() + " patients and " + slicedConceptUuid.size() + " concepts"); long endDownloadObservations = System.currentTimeMillis(); Log.i(getClass().getSimpleName(), "Observations download successful with " + allObservations.size() + " observations"); Log.d(getClass().getSimpleName(), "In Downloading observations : " + (endDownloadObservations - startDownloadObservations) / 1000 + " sec"); totalTimeDownloading += endDownloadObservations - startDownloadObservations; List<Observation> voidedObservations = getVoidedObservations(allObservations); observationController.deleteObservations(voidedObservations); allObservations.removeAll(voidedObservations); Log.i(getClass().getSimpleName(), "Voided observations delete successful with " + voidedObservations.size() + " observations"); if (replaceExistingObservations) { observationController.replaceObservations(allObservations); long replacedObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Replacing observations for patients: " + (replacedObservations - endDownloadObservations) / 1000 + " sec"); totalTimeReplacing += replacedObservations - endDownloadObservations; } else { observationController.saveObservations(allObservations); long savedObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In saving observations : " + (savedObservations - endDownloadObservations) / 1000 + " sec\n"); totalTimeSaving += savedObservations - endDownloadObservations; } result[1] += allObservations.size(); result[2] += voidedObservations.size(); } } result[3] = patientUuidsForDownloadedObs.size(); result[0] = SUCCESS; Log.d(getClass().getSimpleName(), "Total Downloading observations : " + totalTimeDownloading / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Replacing observations : " + totalTimeReplacing / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Saving observations : " + totalTimeSaving / 1000 + " sec\n"); } catch (ObservationController.DownloadObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading observations.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (ObservationController.ReplaceObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while replacing observations.", e); result[0] = SyncStatusConstants.REPLACE_ERROR; } catch (ConceptController.ConceptFetchException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading concepts.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } catch (ObservationController.DeleteObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while deleting observations.", e); result[0] = SyncStatusConstants.DELETE_ERROR; } catch (ObservationController.SaveObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while saving observations.", e); result[0] = SyncStatusConstants.SAVE_ERROR; } return result; } }
MuzimaSyncService { public int[] downloadObservationsForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingObservations) { int[] result = new int[4]; try { List<String> conceptUuidsFromConcepts = getConceptUuidsFromConcepts(conceptController.getConcepts()); List<List<String>> slicedPatientUuids = split(patientUuids); List<List<String>> slicedConceptUuids = split(conceptUuidsFromConcepts); Set<String> patientUuidsForDownloadedObs = new HashSet<>(); long totalTimeDownloading = 0, totalTimeReplacing = 0, totalTimeSaving = 0; int i = 0; for (List<String> slicedPatientUuid : slicedPatientUuids) { for (List<String> slicedConceptUuid : slicedConceptUuids) { long startDownloadObservations = System.currentTimeMillis(); List<Observation> allObservations = new ArrayList<>(observationController.downloadObservationsByPatientUuidsAndConceptUuids( slicedPatientUuid, slicedConceptUuid)); for (Observation observation : allObservations) { patientUuidsForDownloadedObs.add(observation.getPerson().getUuid()); } updateProgressDialog(muzimaApplication.getString(R.string.info_observations_download_progress, patientUuidsForDownloadedObs.size(), patientUuids.size())); Log.i(getClass().getSimpleName(), "Downloading observations for " + slicedPatientUuid.size() + " patients and " + slicedConceptUuid.size() + " concepts"); long endDownloadObservations = System.currentTimeMillis(); Log.i(getClass().getSimpleName(), "Observations download successful with " + allObservations.size() + " observations"); Log.d(getClass().getSimpleName(), "In Downloading observations : " + (endDownloadObservations - startDownloadObservations) / 1000 + " sec"); totalTimeDownloading += endDownloadObservations - startDownloadObservations; List<Observation> voidedObservations = getVoidedObservations(allObservations); observationController.deleteObservations(voidedObservations); allObservations.removeAll(voidedObservations); Log.i(getClass().getSimpleName(), "Voided observations delete successful with " + voidedObservations.size() + " observations"); if (replaceExistingObservations) { observationController.replaceObservations(allObservations); long replacedObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Replacing observations for patients: " + (replacedObservations - endDownloadObservations) / 1000 + " sec"); totalTimeReplacing += replacedObservations - endDownloadObservations; } else { observationController.saveObservations(allObservations); long savedObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In saving observations : " + (savedObservations - endDownloadObservations) / 1000 + " sec\n"); totalTimeSaving += savedObservations - endDownloadObservations; } result[1] += allObservations.size(); result[2] += voidedObservations.size(); } } result[3] = patientUuidsForDownloadedObs.size(); result[0] = SUCCESS; Log.d(getClass().getSimpleName(), "Total Downloading observations : " + totalTimeDownloading / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Replacing observations : " + totalTimeReplacing / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Saving observations : " + totalTimeSaving / 1000 + " sec\n"); } catch (ObservationController.DownloadObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading observations.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (ObservationController.ReplaceObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while replacing observations.", e); result[0] = SyncStatusConstants.REPLACE_ERROR; } catch (ConceptController.ConceptFetchException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading concepts.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } catch (ObservationController.DeleteObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while deleting observations.", e); result[0] = SyncStatusConstants.DELETE_ERROR; } catch (ObservationController.SaveObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while saving observations.", e); result[0] = SyncStatusConstants.SAVE_ERROR; } return result; } MuzimaSyncService(MuzimaApplication muzimaContext); }
MuzimaSyncService { public int[] downloadObservationsForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingObservations) { int[] result = new int[4]; try { List<String> conceptUuidsFromConcepts = getConceptUuidsFromConcepts(conceptController.getConcepts()); List<List<String>> slicedPatientUuids = split(patientUuids); List<List<String>> slicedConceptUuids = split(conceptUuidsFromConcepts); Set<String> patientUuidsForDownloadedObs = new HashSet<>(); long totalTimeDownloading = 0, totalTimeReplacing = 0, totalTimeSaving = 0; int i = 0; for (List<String> slicedPatientUuid : slicedPatientUuids) { for (List<String> slicedConceptUuid : slicedConceptUuids) { long startDownloadObservations = System.currentTimeMillis(); List<Observation> allObservations = new ArrayList<>(observationController.downloadObservationsByPatientUuidsAndConceptUuids( slicedPatientUuid, slicedConceptUuid)); for (Observation observation : allObservations) { patientUuidsForDownloadedObs.add(observation.getPerson().getUuid()); } updateProgressDialog(muzimaApplication.getString(R.string.info_observations_download_progress, patientUuidsForDownloadedObs.size(), patientUuids.size())); Log.i(getClass().getSimpleName(), "Downloading observations for " + slicedPatientUuid.size() + " patients and " + slicedConceptUuid.size() + " concepts"); long endDownloadObservations = System.currentTimeMillis(); Log.i(getClass().getSimpleName(), "Observations download successful with " + allObservations.size() + " observations"); Log.d(getClass().getSimpleName(), "In Downloading observations : " + (endDownloadObservations - startDownloadObservations) / 1000 + " sec"); totalTimeDownloading += endDownloadObservations - startDownloadObservations; List<Observation> voidedObservations = getVoidedObservations(allObservations); observationController.deleteObservations(voidedObservations); allObservations.removeAll(voidedObservations); Log.i(getClass().getSimpleName(), "Voided observations delete successful with " + voidedObservations.size() + " observations"); if (replaceExistingObservations) { observationController.replaceObservations(allObservations); long replacedObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Replacing observations for patients: " + (replacedObservations - endDownloadObservations) / 1000 + " sec"); totalTimeReplacing += replacedObservations - endDownloadObservations; } else { observationController.saveObservations(allObservations); long savedObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In saving observations : " + (savedObservations - endDownloadObservations) / 1000 + " sec\n"); totalTimeSaving += savedObservations - endDownloadObservations; } result[1] += allObservations.size(); result[2] += voidedObservations.size(); } } result[3] = patientUuidsForDownloadedObs.size(); result[0] = SUCCESS; Log.d(getClass().getSimpleName(), "Total Downloading observations : " + totalTimeDownloading / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Replacing observations : " + totalTimeReplacing / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Saving observations : " + totalTimeSaving / 1000 + " sec\n"); } catch (ObservationController.DownloadObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading observations.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (ObservationController.ReplaceObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while replacing observations.", e); result[0] = SyncStatusConstants.REPLACE_ERROR; } catch (ConceptController.ConceptFetchException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading concepts.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } catch (ObservationController.DeleteObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while deleting observations.", e); result[0] = SyncStatusConstants.DELETE_ERROR; } catch (ObservationController.SaveObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while saving observations.", e); result[0] = SyncStatusConstants.SAVE_ERROR; } 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[] downloadObservationsForPatientsByPatientUUIDs(List<String> patientUuids, boolean replaceExistingObservations) { int[] result = new int[4]; try { List<String> conceptUuidsFromConcepts = getConceptUuidsFromConcepts(conceptController.getConcepts()); List<List<String>> slicedPatientUuids = split(patientUuids); List<List<String>> slicedConceptUuids = split(conceptUuidsFromConcepts); Set<String> patientUuidsForDownloadedObs = new HashSet<>(); long totalTimeDownloading = 0, totalTimeReplacing = 0, totalTimeSaving = 0; int i = 0; for (List<String> slicedPatientUuid : slicedPatientUuids) { for (List<String> slicedConceptUuid : slicedConceptUuids) { long startDownloadObservations = System.currentTimeMillis(); List<Observation> allObservations = new ArrayList<>(observationController.downloadObservationsByPatientUuidsAndConceptUuids( slicedPatientUuid, slicedConceptUuid)); for (Observation observation : allObservations) { patientUuidsForDownloadedObs.add(observation.getPerson().getUuid()); } updateProgressDialog(muzimaApplication.getString(R.string.info_observations_download_progress, patientUuidsForDownloadedObs.size(), patientUuids.size())); Log.i(getClass().getSimpleName(), "Downloading observations for " + slicedPatientUuid.size() + " patients and " + slicedConceptUuid.size() + " concepts"); long endDownloadObservations = System.currentTimeMillis(); Log.i(getClass().getSimpleName(), "Observations download successful with " + allObservations.size() + " observations"); Log.d(getClass().getSimpleName(), "In Downloading observations : " + (endDownloadObservations - startDownloadObservations) / 1000 + " sec"); totalTimeDownloading += endDownloadObservations - startDownloadObservations; List<Observation> voidedObservations = getVoidedObservations(allObservations); observationController.deleteObservations(voidedObservations); allObservations.removeAll(voidedObservations); Log.i(getClass().getSimpleName(), "Voided observations delete successful with " + voidedObservations.size() + " observations"); if (replaceExistingObservations) { observationController.replaceObservations(allObservations); long replacedObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In Replacing observations for patients: " + (replacedObservations - endDownloadObservations) / 1000 + " sec"); totalTimeReplacing += replacedObservations - endDownloadObservations; } else { observationController.saveObservations(allObservations); long savedObservations = System.currentTimeMillis(); Log.d(getClass().getSimpleName(), "In saving observations : " + (savedObservations - endDownloadObservations) / 1000 + " sec\n"); totalTimeSaving += savedObservations - endDownloadObservations; } result[1] += allObservations.size(); result[2] += voidedObservations.size(); } } result[3] = patientUuidsForDownloadedObs.size(); result[0] = SUCCESS; Log.d(getClass().getSimpleName(), "Total Downloading observations : " + totalTimeDownloading / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Replacing observations : " + totalTimeReplacing / 1000 + " sec\n"); Log.d(getClass().getSimpleName(), "Total Saving observations : " + totalTimeSaving / 1000 + " sec\n"); } catch (ObservationController.DownloadObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while downloading observations.", e); result[0] = SyncStatusConstants.DOWNLOAD_ERROR; } catch (ObservationController.ReplaceObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while replacing observations.", e); result[0] = SyncStatusConstants.REPLACE_ERROR; } catch (ConceptController.ConceptFetchException e) { Log.e(getClass().getSimpleName(), "Exception thrown while loading concepts.", e); result[0] = SyncStatusConstants.LOAD_ERROR; } catch (ObservationController.DeleteObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while deleting observations.", e); result[0] = SyncStatusConstants.DELETE_ERROR; } catch (ObservationController.SaveObservationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while saving observations.", e); result[0] = SyncStatusConstants.SAVE_ERROR; } 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(); }
@Test public void shouldCreateEncounterEntityWithAppropriateValues() throws ProviderController.ProviderLoadException, FormController.FormFetchException { Date encounterDateTime = new Date(); final String formUuid = "formUuid"; String providerId = "providerId"; int locationId = 1; String userSystemId = "userSystemId"; final EncounterType encounterType = new EncounterType(){{ setUuid("encounterTypeForObservationsCreatedOnPhone"); }}; Form form = new Form(){{ setUuid(formUuid); setEncounterType(encounterType); }}; List<Provider> providers = new ArrayList<Provider>() {{ add(new Provider() {{ setUuid("provider1"); }}); }}; when(providerController.getAllProviders()).thenReturn(providers); when(formController.getFormByUuid(formUuid)).thenReturn(form); Encounter encounter = observationParserUtility.getEncounterEntity(encounterDateTime, formUuid,providerId, locationId, userSystemId, patient, formDataUuid); assertTrue(encounter.getUuid().startsWith("encounterUuid")); assertThat(encounter.getEncounterType().getUuid(), is(form.getEncounterType().getUuid())); assertThat(encounter.getProvider().getUuid(), is("providerForObservationsCreatedOnPhone")); assertThat(encounter.getEncounterDatetime(), is(encounterDateTime)); }
public Encounter getEncounterEntity(Date encounterDateTime,String formUuid,String providerId, int locationId, String userSystemId, Patient patient, String formDataUuid) { Encounter encounter = new Encounter(); encounter.setProvider(getDummyProvider(providerId)); encounter.setUuid(getEncounterUUID()); encounter.setLocation(getDummyLocation(locationId)); encounter.setEncounterType(getDummyEncounterType(formUuid)); encounter.setEncounterDatetime(encounterDateTime); encounter.setUserSystemId(userSystemId); encounter.setFormDataUuid(formDataUuid); encounter.setPatient(patient); return encounter; }
ObservationParserUtility { public Encounter getEncounterEntity(Date encounterDateTime,String formUuid,String providerId, int locationId, String userSystemId, Patient patient, String formDataUuid) { Encounter encounter = new Encounter(); encounter.setProvider(getDummyProvider(providerId)); encounter.setUuid(getEncounterUUID()); encounter.setLocation(getDummyLocation(locationId)); encounter.setEncounterType(getDummyEncounterType(formUuid)); encounter.setEncounterDatetime(encounterDateTime); encounter.setUserSystemId(userSystemId); encounter.setFormDataUuid(formDataUuid); encounter.setPatient(patient); return encounter; } }
ObservationParserUtility { public Encounter getEncounterEntity(Date encounterDateTime,String formUuid,String providerId, int locationId, String userSystemId, Patient patient, String formDataUuid) { Encounter encounter = new Encounter(); encounter.setProvider(getDummyProvider(providerId)); encounter.setUuid(getEncounterUUID()); encounter.setLocation(getDummyLocation(locationId)); encounter.setEncounterType(getDummyEncounterType(formUuid)); encounter.setEncounterDatetime(encounterDateTime); encounter.setUserSystemId(userSystemId); encounter.setFormDataUuid(formDataUuid); encounter.setPatient(patient); return encounter; } ObservationParserUtility(MuzimaApplication muzimaApplication, boolean createObservationsForConceptsNotAvailableLocally); }
ObservationParserUtility { public Encounter getEncounterEntity(Date encounterDateTime,String formUuid,String providerId, int locationId, String userSystemId, Patient patient, String formDataUuid) { Encounter encounter = new Encounter(); encounter.setProvider(getDummyProvider(providerId)); encounter.setUuid(getEncounterUUID()); encounter.setLocation(getDummyLocation(locationId)); encounter.setEncounterType(getDummyEncounterType(formUuid)); encounter.setEncounterDatetime(encounterDateTime); encounter.setUserSystemId(userSystemId); encounter.setFormDataUuid(formDataUuid); encounter.setPatient(patient); return encounter; } ObservationParserUtility(MuzimaApplication muzimaApplication, boolean createObservationsForConceptsNotAvailableLocally); Encounter getEncounterEntity(Date encounterDateTime,String formUuid,String providerId, int locationId, String userSystemId, Patient patient, String formDataUuid); Concept getConceptEntity(String rawConceptName, boolean isCoded, boolean createConceptIfNotAvailableLocally); Observation getObservationEntity(Concept concept, String value); List<Concept> getNewConceptList(); static boolean isFormattedAsConcept(String peek); String getObservationUuid(); }
ObservationParserUtility { public Encounter getEncounterEntity(Date encounterDateTime,String formUuid,String providerId, int locationId, String userSystemId, Patient patient, String formDataUuid) { Encounter encounter = new Encounter(); encounter.setProvider(getDummyProvider(providerId)); encounter.setUuid(getEncounterUUID()); encounter.setLocation(getDummyLocation(locationId)); encounter.setEncounterType(getDummyEncounterType(formUuid)); encounter.setEncounterDatetime(encounterDateTime); encounter.setUserSystemId(userSystemId); encounter.setFormDataUuid(formDataUuid); encounter.setPatient(patient); return encounter; } ObservationParserUtility(MuzimaApplication muzimaApplication, boolean createObservationsForConceptsNotAvailableLocally); Encounter getEncounterEntity(Date encounterDateTime,String formUuid,String providerId, int locationId, String userSystemId, Patient patient, String formDataUuid); Concept getConceptEntity(String rawConceptName, boolean isCoded, boolean createConceptIfNotAvailableLocally); Observation getObservationEntity(Concept concept, String value); List<Concept> getNewConceptList(); static boolean isFormattedAsConcept(String peek); String getObservationUuid(); }
@Test public void shouldNotCreateNewConceptOrObservationForInvalidConceptName() { observationParserUtility = new ObservationParserUtility(muzimaApplication,true); assertThat(observationParserUtility.getNewConceptList().size(), is(0)); }
public List<Concept> getNewConceptList() { return newConceptList; }
ObservationParserUtility { public List<Concept> getNewConceptList() { return newConceptList; } }
ObservationParserUtility { public List<Concept> getNewConceptList() { return newConceptList; } ObservationParserUtility(MuzimaApplication muzimaApplication, boolean createObservationsForConceptsNotAvailableLocally); }
ObservationParserUtility { public List<Concept> getNewConceptList() { return newConceptList; } ObservationParserUtility(MuzimaApplication muzimaApplication, boolean createObservationsForConceptsNotAvailableLocally); Encounter getEncounterEntity(Date encounterDateTime,String formUuid,String providerId, int locationId, String userSystemId, Patient patient, String formDataUuid); Concept getConceptEntity(String rawConceptName, boolean isCoded, boolean createConceptIfNotAvailableLocally); Observation getObservationEntity(Concept concept, String value); List<Concept> getNewConceptList(); static boolean isFormattedAsConcept(String peek); String getObservationUuid(); }
ObservationParserUtility { public List<Concept> getNewConceptList() { return newConceptList; } ObservationParserUtility(MuzimaApplication muzimaApplication, boolean createObservationsForConceptsNotAvailableLocally); Encounter getEncounterEntity(Date encounterDateTime,String formUuid,String providerId, int locationId, String userSystemId, Patient patient, String formDataUuid); Concept getConceptEntity(String rawConceptName, boolean isCoded, boolean createConceptIfNotAvailableLocally); Observation getObservationEntity(Concept concept, String value); List<Concept> getNewConceptList(); static boolean isFormattedAsConcept(String peek); String getObservationUuid(); }
@Test public void shouldPutEncounterWithNullDateAtTheTopWhenItsNotAtTheTop() { final Observation observation1 = createObservation(createEncounter("c1", new Date(1)), "01"); final Observation observation2 = createObservation(createEncounter("c2", null), "02"); final Encounters encounters = new Encounters(observation1, observation2); encounters.sortByDate(); final Encounters expectedOrderedConcept = new Encounters() {{ add(encounterWithObservations(observation2)); add(encounterWithObservations(observation1)); }}; assertThat(encounters, is(expectedOrderedConcept)); }
public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); }
Encounters extends ArrayList<EncounterWithObservations> { public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); } }
Encounters extends ArrayList<EncounterWithObservations> { public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); } Encounters(); Encounters(Observation... observations); Encounters(List<Observation> observationsByPatient); }
Encounters extends ArrayList<EncounterWithObservations> { public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); } Encounters(); Encounters(Observation... observations); Encounters(List<Observation> observationsByPatient); void sortByDate(); }
Encounters extends ArrayList<EncounterWithObservations> { public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); } Encounters(); Encounters(Observation... observations); Encounters(List<Observation> observationsByPatient); void sortByDate(); }
@Test public void shouldCreateNumericObservation() throws ConceptController.ConceptFetchException, ConceptController.ConceptParseException, ObservationController.ParseObservationException{ Concept concept = mock(Concept.class); when(concept.isNumeric()).thenReturn(true); when(concept.isCoded()).thenReturn(false); Observation observation = observationParserUtility.getObservationEntity(concept, "20.0"); assertThat(observation.getValueNumeric(), is(20.0)); assertTrue(observation.getUuid().startsWith("observationFromPhoneUuid")); }
public Observation getObservationEntity(Concept concept, String value) throws ConceptController.ConceptFetchException, ConceptController.ConceptParseException, ObservationController.ParseObservationException{ if (concept == null) { throw new ObservationController.ParseObservationException("Could not create Observation entity." + " Reason: No Concept provided."); } if (StringUtils.isEmpty(value)) { throw new ObservationController.ParseObservationException("Could not create Observation entity for concept '" + concept.getName() + "'. Reason: No Observation value provided."); } Observation observation = new Observation(); observation.setUuid(getObservationUuid()); observation.setValueCoded(defaultValueCodedConcept()); if (concept.isCoded()) { try { Concept valueCoded = getConceptEntity(value,false, true); observation.setValueCoded(valueCoded); } catch (ConceptController.ConceptParseException e) { throw new ConceptController.ConceptParseException("Could not get value for coded concept '" + concept.getName() + "', from provided value '" + value + "'"); } } else if (concept.isNumeric()) { observation.setValueNumeric(getDoubleValue(value)); } else { observation.setValueText(value); } observation.setConcept(concept); return observation; }
ObservationParserUtility { public Observation getObservationEntity(Concept concept, String value) throws ConceptController.ConceptFetchException, ConceptController.ConceptParseException, ObservationController.ParseObservationException{ if (concept == null) { throw new ObservationController.ParseObservationException("Could not create Observation entity." + " Reason: No Concept provided."); } if (StringUtils.isEmpty(value)) { throw new ObservationController.ParseObservationException("Could not create Observation entity for concept '" + concept.getName() + "'. Reason: No Observation value provided."); } Observation observation = new Observation(); observation.setUuid(getObservationUuid()); observation.setValueCoded(defaultValueCodedConcept()); if (concept.isCoded()) { try { Concept valueCoded = getConceptEntity(value,false, true); observation.setValueCoded(valueCoded); } catch (ConceptController.ConceptParseException e) { throw new ConceptController.ConceptParseException("Could not get value for coded concept '" + concept.getName() + "', from provided value '" + value + "'"); } } else if (concept.isNumeric()) { observation.setValueNumeric(getDoubleValue(value)); } else { observation.setValueText(value); } observation.setConcept(concept); return observation; } }
ObservationParserUtility { public Observation getObservationEntity(Concept concept, String value) throws ConceptController.ConceptFetchException, ConceptController.ConceptParseException, ObservationController.ParseObservationException{ if (concept == null) { throw new ObservationController.ParseObservationException("Could not create Observation entity." + " Reason: No Concept provided."); } if (StringUtils.isEmpty(value)) { throw new ObservationController.ParseObservationException("Could not create Observation entity for concept '" + concept.getName() + "'. Reason: No Observation value provided."); } Observation observation = new Observation(); observation.setUuid(getObservationUuid()); observation.setValueCoded(defaultValueCodedConcept()); if (concept.isCoded()) { try { Concept valueCoded = getConceptEntity(value,false, true); observation.setValueCoded(valueCoded); } catch (ConceptController.ConceptParseException e) { throw new ConceptController.ConceptParseException("Could not get value for coded concept '" + concept.getName() + "', from provided value '" + value + "'"); } } else if (concept.isNumeric()) { observation.setValueNumeric(getDoubleValue(value)); } else { observation.setValueText(value); } observation.setConcept(concept); return observation; } ObservationParserUtility(MuzimaApplication muzimaApplication, boolean createObservationsForConceptsNotAvailableLocally); }
ObservationParserUtility { public Observation getObservationEntity(Concept concept, String value) throws ConceptController.ConceptFetchException, ConceptController.ConceptParseException, ObservationController.ParseObservationException{ if (concept == null) { throw new ObservationController.ParseObservationException("Could not create Observation entity." + " Reason: No Concept provided."); } if (StringUtils.isEmpty(value)) { throw new ObservationController.ParseObservationException("Could not create Observation entity for concept '" + concept.getName() + "'. Reason: No Observation value provided."); } Observation observation = new Observation(); observation.setUuid(getObservationUuid()); observation.setValueCoded(defaultValueCodedConcept()); if (concept.isCoded()) { try { Concept valueCoded = getConceptEntity(value,false, true); observation.setValueCoded(valueCoded); } catch (ConceptController.ConceptParseException e) { throw new ConceptController.ConceptParseException("Could not get value for coded concept '" + concept.getName() + "', from provided value '" + value + "'"); } } else if (concept.isNumeric()) { observation.setValueNumeric(getDoubleValue(value)); } else { observation.setValueText(value); } observation.setConcept(concept); return observation; } ObservationParserUtility(MuzimaApplication muzimaApplication, boolean createObservationsForConceptsNotAvailableLocally); Encounter getEncounterEntity(Date encounterDateTime,String formUuid,String providerId, int locationId, String userSystemId, Patient patient, String formDataUuid); Concept getConceptEntity(String rawConceptName, boolean isCoded, boolean createConceptIfNotAvailableLocally); Observation getObservationEntity(Concept concept, String value); List<Concept> getNewConceptList(); static boolean isFormattedAsConcept(String peek); String getObservationUuid(); }
ObservationParserUtility { public Observation getObservationEntity(Concept concept, String value) throws ConceptController.ConceptFetchException, ConceptController.ConceptParseException, ObservationController.ParseObservationException{ if (concept == null) { throw new ObservationController.ParseObservationException("Could not create Observation entity." + " Reason: No Concept provided."); } if (StringUtils.isEmpty(value)) { throw new ObservationController.ParseObservationException("Could not create Observation entity for concept '" + concept.getName() + "'. Reason: No Observation value provided."); } Observation observation = new Observation(); observation.setUuid(getObservationUuid()); observation.setValueCoded(defaultValueCodedConcept()); if (concept.isCoded()) { try { Concept valueCoded = getConceptEntity(value,false, true); observation.setValueCoded(valueCoded); } catch (ConceptController.ConceptParseException e) { throw new ConceptController.ConceptParseException("Could not get value for coded concept '" + concept.getName() + "', from provided value '" + value + "'"); } } else if (concept.isNumeric()) { observation.setValueNumeric(getDoubleValue(value)); } else { observation.setValueText(value); } observation.setConcept(concept); return observation; } ObservationParserUtility(MuzimaApplication muzimaApplication, boolean createObservationsForConceptsNotAvailableLocally); Encounter getEncounterEntity(Date encounterDateTime,String formUuid,String providerId, int locationId, String userSystemId, Patient patient, String formDataUuid); Concept getConceptEntity(String rawConceptName, boolean isCoded, boolean createConceptIfNotAvailableLocally); Observation getObservationEntity(Concept concept, String value); List<Concept> getNewConceptList(); static boolean isFormattedAsConcept(String peek); String getObservationUuid(); }
@Test public void shouldCreateObsWithStringForNonNumericNonCodedConcept() throws ConceptController.ConceptFetchException, ConceptController.ConceptParseException, ObservationController.ParseObservationException{ observationParserUtility = new ObservationParserUtility(muzimaApplication,true); Concept concept = mock(Concept.class); when(concept.getName()).thenReturn("SomeConcept"); when(concept.isNumeric()).thenReturn(false); when(concept.isCoded()).thenReturn(false); Observation observation = observationParserUtility.getObservationEntity(concept, "someString"); assertThat(observation.getValueAsString(), is("someString")); }
public Observation getObservationEntity(Concept concept, String value) throws ConceptController.ConceptFetchException, ConceptController.ConceptParseException, ObservationController.ParseObservationException{ if (concept == null) { throw new ObservationController.ParseObservationException("Could not create Observation entity." + " Reason: No Concept provided."); } if (StringUtils.isEmpty(value)) { throw new ObservationController.ParseObservationException("Could not create Observation entity for concept '" + concept.getName() + "'. Reason: No Observation value provided."); } Observation observation = new Observation(); observation.setUuid(getObservationUuid()); observation.setValueCoded(defaultValueCodedConcept()); if (concept.isCoded()) { try { Concept valueCoded = getConceptEntity(value,false, true); observation.setValueCoded(valueCoded); } catch (ConceptController.ConceptParseException e) { throw new ConceptController.ConceptParseException("Could not get value for coded concept '" + concept.getName() + "', from provided value '" + value + "'"); } } else if (concept.isNumeric()) { observation.setValueNumeric(getDoubleValue(value)); } else { observation.setValueText(value); } observation.setConcept(concept); return observation; }
ObservationParserUtility { public Observation getObservationEntity(Concept concept, String value) throws ConceptController.ConceptFetchException, ConceptController.ConceptParseException, ObservationController.ParseObservationException{ if (concept == null) { throw new ObservationController.ParseObservationException("Could not create Observation entity." + " Reason: No Concept provided."); } if (StringUtils.isEmpty(value)) { throw new ObservationController.ParseObservationException("Could not create Observation entity for concept '" + concept.getName() + "'. Reason: No Observation value provided."); } Observation observation = new Observation(); observation.setUuid(getObservationUuid()); observation.setValueCoded(defaultValueCodedConcept()); if (concept.isCoded()) { try { Concept valueCoded = getConceptEntity(value,false, true); observation.setValueCoded(valueCoded); } catch (ConceptController.ConceptParseException e) { throw new ConceptController.ConceptParseException("Could not get value for coded concept '" + concept.getName() + "', from provided value '" + value + "'"); } } else if (concept.isNumeric()) { observation.setValueNumeric(getDoubleValue(value)); } else { observation.setValueText(value); } observation.setConcept(concept); return observation; } }
ObservationParserUtility { public Observation getObservationEntity(Concept concept, String value) throws ConceptController.ConceptFetchException, ConceptController.ConceptParseException, ObservationController.ParseObservationException{ if (concept == null) { throw new ObservationController.ParseObservationException("Could not create Observation entity." + " Reason: No Concept provided."); } if (StringUtils.isEmpty(value)) { throw new ObservationController.ParseObservationException("Could not create Observation entity for concept '" + concept.getName() + "'. Reason: No Observation value provided."); } Observation observation = new Observation(); observation.setUuid(getObservationUuid()); observation.setValueCoded(defaultValueCodedConcept()); if (concept.isCoded()) { try { Concept valueCoded = getConceptEntity(value,false, true); observation.setValueCoded(valueCoded); } catch (ConceptController.ConceptParseException e) { throw new ConceptController.ConceptParseException("Could not get value for coded concept '" + concept.getName() + "', from provided value '" + value + "'"); } } else if (concept.isNumeric()) { observation.setValueNumeric(getDoubleValue(value)); } else { observation.setValueText(value); } observation.setConcept(concept); return observation; } ObservationParserUtility(MuzimaApplication muzimaApplication, boolean createObservationsForConceptsNotAvailableLocally); }
ObservationParserUtility { public Observation getObservationEntity(Concept concept, String value) throws ConceptController.ConceptFetchException, ConceptController.ConceptParseException, ObservationController.ParseObservationException{ if (concept == null) { throw new ObservationController.ParseObservationException("Could not create Observation entity." + " Reason: No Concept provided."); } if (StringUtils.isEmpty(value)) { throw new ObservationController.ParseObservationException("Could not create Observation entity for concept '" + concept.getName() + "'. Reason: No Observation value provided."); } Observation observation = new Observation(); observation.setUuid(getObservationUuid()); observation.setValueCoded(defaultValueCodedConcept()); if (concept.isCoded()) { try { Concept valueCoded = getConceptEntity(value,false, true); observation.setValueCoded(valueCoded); } catch (ConceptController.ConceptParseException e) { throw new ConceptController.ConceptParseException("Could not get value for coded concept '" + concept.getName() + "', from provided value '" + value + "'"); } } else if (concept.isNumeric()) { observation.setValueNumeric(getDoubleValue(value)); } else { observation.setValueText(value); } observation.setConcept(concept); return observation; } ObservationParserUtility(MuzimaApplication muzimaApplication, boolean createObservationsForConceptsNotAvailableLocally); Encounter getEncounterEntity(Date encounterDateTime,String formUuid,String providerId, int locationId, String userSystemId, Patient patient, String formDataUuid); Concept getConceptEntity(String rawConceptName, boolean isCoded, boolean createConceptIfNotAvailableLocally); Observation getObservationEntity(Concept concept, String value); List<Concept> getNewConceptList(); static boolean isFormattedAsConcept(String peek); String getObservationUuid(); }
ObservationParserUtility { public Observation getObservationEntity(Concept concept, String value) throws ConceptController.ConceptFetchException, ConceptController.ConceptParseException, ObservationController.ParseObservationException{ if (concept == null) { throw new ObservationController.ParseObservationException("Could not create Observation entity." + " Reason: No Concept provided."); } if (StringUtils.isEmpty(value)) { throw new ObservationController.ParseObservationException("Could not create Observation entity for concept '" + concept.getName() + "'. Reason: No Observation value provided."); } Observation observation = new Observation(); observation.setUuid(getObservationUuid()); observation.setValueCoded(defaultValueCodedConcept()); if (concept.isCoded()) { try { Concept valueCoded = getConceptEntity(value,false, true); observation.setValueCoded(valueCoded); } catch (ConceptController.ConceptParseException e) { throw new ConceptController.ConceptParseException("Could not get value for coded concept '" + concept.getName() + "', from provided value '" + value + "'"); } } else if (concept.isNumeric()) { observation.setValueNumeric(getDoubleValue(value)); } else { observation.setValueText(value); } observation.setConcept(concept); return observation; } ObservationParserUtility(MuzimaApplication muzimaApplication, boolean createObservationsForConceptsNotAvailableLocally); Encounter getEncounterEntity(Date encounterDateTime,String formUuid,String providerId, int locationId, String userSystemId, Patient patient, String formDataUuid); Concept getConceptEntity(String rawConceptName, boolean isCoded, boolean createConceptIfNotAvailableLocally); Observation getObservationEntity(Concept concept, String value); List<Concept> getNewConceptList(); static boolean isFormattedAsConcept(String peek); String getObservationUuid(); }
@Test public void shouldVerifyAllObservationsAndRelatedEntitiesAreSaved() throws EncounterController.SaveEncounterException, ConceptController.ConceptSaveException, ObservationController.SaveObservationException { htmlFormObservationCreator.createAndPersistObservations(readFile(),formDataUuid); verify(encounterController).saveEncounters(encounterArgumentCaptor.capture()); assertThat(encounterArgumentCaptor.getValue().size(), is(1)); verify(conceptController).saveConcepts(conceptArgumentCaptor.capture()); List<Concept> value = conceptArgumentCaptor.getValue(); assertThat(value.size(), is(33)); verify(observationController).saveObservations(observationArgumentCaptor.capture()); assertThat(observationArgumentCaptor.getValue().size(), is(30)); }
public void createAndPersistObservations(String jsonResponse,String formDataUuid) { parseJSONResponse(jsonResponse,formDataUuid); try { saveObservationsAndRelatedEntities(); } catch (ConceptController.ConceptSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving concept", e); } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Error while saving Encounter", e); } catch (ObservationController.SaveObservationException e) { Log.e(getClass().getSimpleName(), "Error while saving Observation", e); } catch (Exception e) { Log.e(getClass().getSimpleName(), "Unexpected Exception occurred", e); } }
HTMLFormObservationCreator { public void createAndPersistObservations(String jsonResponse,String formDataUuid) { parseJSONResponse(jsonResponse,formDataUuid); try { saveObservationsAndRelatedEntities(); } catch (ConceptController.ConceptSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving concept", e); } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Error while saving Encounter", e); } catch (ObservationController.SaveObservationException e) { Log.e(getClass().getSimpleName(), "Error while saving Observation", e); } catch (Exception e) { Log.e(getClass().getSimpleName(), "Unexpected Exception occurred", e); } } }
HTMLFormObservationCreator { public void createAndPersistObservations(String jsonResponse,String formDataUuid) { parseJSONResponse(jsonResponse,formDataUuid); try { saveObservationsAndRelatedEntities(); } catch (ConceptController.ConceptSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving concept", e); } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Error while saving Encounter", e); } catch (ObservationController.SaveObservationException e) { Log.e(getClass().getSimpleName(), "Error while saving Observation", e); } catch (Exception e) { Log.e(getClass().getSimpleName(), "Unexpected Exception occurred", e); } } HTMLFormObservationCreator(MuzimaApplication muzimaApplication, boolean createObservationsForConceptsNotAvailableLocally); }
HTMLFormObservationCreator { public void createAndPersistObservations(String jsonResponse,String formDataUuid) { parseJSONResponse(jsonResponse,formDataUuid); try { saveObservationsAndRelatedEntities(); } catch (ConceptController.ConceptSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving concept", e); } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Error while saving Encounter", e); } catch (ObservationController.SaveObservationException e) { Log.e(getClass().getSimpleName(), "Error while saving Observation", e); } catch (Exception e) { Log.e(getClass().getSimpleName(), "Unexpected Exception occurred", e); } } HTMLFormObservationCreator(MuzimaApplication muzimaApplication, boolean createObservationsForConceptsNotAvailableLocally); void createAndPersistObservations(String jsonResponse,String formDataUuid); void createObservationsAndRelatedEntities(String jsonResponse,String formDataUuid); List<Observation> getObservations(); Encounter getEncounter(); List<Concept> getNewConceptList(); Date getEncounterDateFromFormDate(String jsonResponse); }
HTMLFormObservationCreator { public void createAndPersistObservations(String jsonResponse,String formDataUuid) { parseJSONResponse(jsonResponse,formDataUuid); try { saveObservationsAndRelatedEntities(); } catch (ConceptController.ConceptSaveException e) { Log.e(getClass().getSimpleName(), "Error while saving concept", e); } catch (EncounterController.SaveEncounterException e) { Log.e(getClass().getSimpleName(), "Error while saving Encounter", e); } catch (ObservationController.SaveObservationException e) { Log.e(getClass().getSimpleName(), "Error while saving Observation", e); } catch (Exception e) { Log.e(getClass().getSimpleName(), "Unexpected Exception occurred", e); } } HTMLFormObservationCreator(MuzimaApplication muzimaApplication, boolean createObservationsForConceptsNotAvailableLocally); void createAndPersistObservations(String jsonResponse,String formDataUuid); void createObservationsAndRelatedEntities(String jsonResponse,String formDataUuid); List<Observation> getObservations(); Encounter getEncounter(); List<Concept> getNewConceptList(); Date getEncounterDateFromFormDate(String jsonResponse); }
@Test public void shouldReturnListOfConcepts() { String html = readFile(); List<String> concepts = new HTMLConceptParser().parse(html); assertThat(concepts.size(),is(7)); assertThat(concepts,hasItem("BODY PART")); assertThat(concepts,hasItem("PROCEDURES DONE THIS VISIT")); assertThat(concepts,hasItem("ANATOMIC LOCATION DESCRIPTION")); assertThat(concepts,hasItem("CLOCK FACE CERVICAL BIOPSY LOCATION ")); assertThat(concepts,hasItem("PATHOLOGICAL DIAGNOSIS ADDED")); assertThat(concepts,hasItem("FREETEXT GENERAL")); assertThat(concepts,hasItem("RETURN VISIT DATE")); }
public List<String> parse(String html) { Set<String> concepts = new HashSet<>(); Document htmlDoc = Jsoup.parse(html); Elements elements = htmlDoc.select("*:not(div)[" + DATA_CONCEPT_TAG + "]"); for (Element element : elements) { concepts.add(getConceptName(element.attr(DATA_CONCEPT_TAG))); } return new ArrayList<>(concepts); }
HTMLConceptParser { public List<String> parse(String html) { Set<String> concepts = new HashSet<>(); Document htmlDoc = Jsoup.parse(html); Elements elements = htmlDoc.select("*:not(div)[" + DATA_CONCEPT_TAG + "]"); for (Element element : elements) { concepts.add(getConceptName(element.attr(DATA_CONCEPT_TAG))); } return new ArrayList<>(concepts); } }
HTMLConceptParser { public List<String> parse(String html) { Set<String> concepts = new HashSet<>(); Document htmlDoc = Jsoup.parse(html); Elements elements = htmlDoc.select("*:not(div)[" + DATA_CONCEPT_TAG + "]"); for (Element element : elements) { concepts.add(getConceptName(element.attr(DATA_CONCEPT_TAG))); } return new ArrayList<>(concepts); } }
HTMLConceptParser { public List<String> parse(String html) { Set<String> concepts = new HashSet<>(); Document htmlDoc = Jsoup.parse(html); Elements elements = htmlDoc.select("*:not(div)[" + DATA_CONCEPT_TAG + "]"); for (Element element : elements) { concepts.add(getConceptName(element.attr(DATA_CONCEPT_TAG))); } return new ArrayList<>(concepts); } List<String> parse(String html); }
HTMLConceptParser { public List<String> parse(String html) { Set<String> concepts = new HashSet<>(); Document htmlDoc = Jsoup.parse(html); Elements elements = htmlDoc.select("*:not(div)[" + DATA_CONCEPT_TAG + "]"); for (Element element : elements) { concepts.add(getConceptName(element.attr(DATA_CONCEPT_TAG))); } return new ArrayList<>(concepts); } List<String> parse(String html); }
@Test public void shouldParseConcept() { List<String> conceptNames = utils.parse(getModel("concept.xml")); assertThat(conceptNames, hasItem("PULSE")); }
public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } ConceptParser(); ConceptParser(XmlPullParser parser); }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } ConceptParser(); ConceptParser(XmlPullParser parser); List<String> parse(String model); }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } ConceptParser(); ConceptParser(XmlPullParser parser); List<String> parse(String model); }
@Test public void shouldParseConceptInObs() { List<String> conceptNames = utils.parse(getModel("concept_in_obs.xml")); assertThat(conceptNames, hasItem("WEIGHT (KG)")); }
public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } ConceptParser(); ConceptParser(XmlPullParser parser); }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } ConceptParser(); ConceptParser(XmlPullParser parser); List<String> parse(String model); }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } ConceptParser(); ConceptParser(XmlPullParser parser); List<String> parse(String model); }
@Test public void shouldNotAddItToConceptUnLessBothDateAndTimeArePresentInChildren() { List<String> conceptNames = utils.parse(getModel("concepts_in_concept.xml")); assertThat(conceptNames.size(), is(2)); assertThat(conceptNames, hasItem("PROBLEM ADDED")); assertThat(conceptNames, hasItem("PROBLEM RESOLVED")); }
public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } ConceptParser(); ConceptParser(XmlPullParser parser); }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } ConceptParser(); ConceptParser(XmlPullParser parser); List<String> parse(String model); }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } ConceptParser(); ConceptParser(XmlPullParser parser); List<String> parse(String model); }
@Test public void shouldNotConsiderOptionsAsConcepts() { List<String> conceptNames = utils.parse(getModel("concepts_with_options.xml")); assertThat(conceptNames.size(), is(1)); assertThat(conceptNames, hasItem("MOST RECENT PAPANICOLAOU SMEAR RESULT")); }
public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } ConceptParser(); ConceptParser(XmlPullParser parser); }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } ConceptParser(); ConceptParser(XmlPullParser parser); List<String> parse(String model); }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } ConceptParser(); ConceptParser(XmlPullParser parser); List<String> parse(String model); }
@Test(expected = ConceptParser.ParseConceptException.class) public void shouldThrowParseConceptExceptionWhenTheModelHasNoEndTag() { utils.parse(getModel("concept_no_end_tag.xml")); }
public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } ConceptParser(); ConceptParser(XmlPullParser parser); }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } ConceptParser(); ConceptParser(XmlPullParser parser); List<String> parse(String model); }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } ConceptParser(); ConceptParser(XmlPullParser parser); List<String> parse(String model); }
@Test public void shouldParseConceptTM() { List<String> conceptNames = utils.parse(getModel("dispensary_concept_in_obs.xml")); assertThat(conceptNames, hasItem("START TIME")); assertThat(conceptNames, hasItem("END TIME")); }
public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } ConceptParser(); ConceptParser(XmlPullParser parser); }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } ConceptParser(); ConceptParser(XmlPullParser parser); List<String> parse(String model); }
ConceptParser { public List<String> parse(String model) { try { if (StringUtils.isEmpty(model)) { return new ArrayList<>(); } parser.setInput(new ByteArrayInputStream(model.getBytes()), null); parser.nextTag(); return readConceptName(parser); } catch (Exception e) { throw new ParseConceptException(e); } } ConceptParser(); ConceptParser(XmlPullParser parser); List<String> parse(String model); }
@Test public void shouldPutEncounterWithNullDateAtTheTopWhenItsAtTheTop() { final Observation observation1 = createObservation(createEncounter("c1", null), "01"); final Observation observation2 = createObservation(createEncounter("c2", new Date(1)), "02"); final Encounters encounters = new Encounters(observation1, observation2); encounters.sortByDate(); final Encounters expectedOrderedConcept = new Encounters() {{ add(encounterWithObservations(observation1)); add(encounterWithObservations(observation2)); }}; assertThat(encounters, is(expectedOrderedConcept)); }
public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); }
Encounters extends ArrayList<EncounterWithObservations> { public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); } }
Encounters extends ArrayList<EncounterWithObservations> { public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); } Encounters(); Encounters(Observation... observations); Encounters(List<Observation> observationsByPatient); }
Encounters extends ArrayList<EncounterWithObservations> { public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); } Encounters(); Encounters(Observation... observations); Encounters(List<Observation> observationsByPatient); void sortByDate(); }
Encounters extends ArrayList<EncounterWithObservations> { public void sortByDate() { Collections.sort(this, new Comparator<EncounterWithObservations>() { @Override public int compare(EncounterWithObservations lhs, EncounterWithObservations rhs) { if (lhs.getEncounter().getEncounterDatetime()==null) return -1; if (rhs.getEncounter().getEncounterDatetime()==null) return 1; return -(lhs.getEncounter().getEncounterDatetime() .compareTo(rhs.getEncounter().getEncounterDatetime())); } }); } Encounters(); Encounters(Observation... observations); Encounters(List<Observation> observationsByPatient); void sortByDate(); }
@Test public void shouldGetLastSyncTimeOfEncounter() throws Exception, EncounterController.DownloadEncounterException { List<String> patientUuids = asList("patientUuid1", "patientUuid2"); Date aDate = mock(Date.class); when(lastSyncTimeService.getLastSyncTimeFor(DOWNLOAD_ENCOUNTERS,"patientUuid1,patientUuid2")).thenReturn(aDate); encounterController.downloadEncountersByPatientUuids(patientUuids, activeSetupConfigUuid); verify(lastSyncTimeService).getLastSyncTimeFor(DOWNLOAD_ENCOUNTERS,"patientUuid1,patientUuid2"); verify(lastSyncTimeService, never()).getFullLastSyncTimeInfoFor(DOWNLOAD_ENCOUNTERS); }
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); }
@Test public void shouldUseTheLastSyncTimeWhenDownloadingEncounters() throws Exception, EncounterController.DownloadEncounterException { Date lastSyncDate = mock(Date.class); when(lastSyncTimeService.getLastSyncTimeFor(DOWNLOAD_ENCOUNTERS,"patientUuid1,patientUuid2")).thenReturn(lastSyncDate); List<String> patientUuids = asList("patientUuid1", "patientUuid2"); encounterController.downloadEncountersByPatientUuids(patientUuids, activeSetupConfigUuid); verify(encounterService, never()).downloadEncountersByPatientUuids(anyList()); verify(encounterService).downloadEncountersByPatientUuidsAndSyncDateAndSetupConfig(patientUuids, lastSyncDate, activeSetupConfigUuid); }
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); }
@Test public void shouldSaveTheUpdatedLastSyncTime() throws Exception, EncounterController.DownloadEncounterException { List<String> patientUuids = asList("patientUuid1", "patientUuid2"); Date updatedDate = mock(Date.class); when(sntpService.getTimePerDeviceTimeZone()).thenReturn(updatedDate); Date lastSyncDate = mock(Date.class); when(lastSyncTimeService.getLastSyncTimeFor(DOWNLOAD_ENCOUNTERS,"patientUuid1,patientUuid2")).thenReturn(lastSyncDate); encounterController.downloadEncountersByPatientUuids(patientUuids, activeSetupConfigUuid); ArgumentCaptor<LastSyncTime> argumentCaptor = ArgumentCaptor.forClass(LastSyncTime.class); verify(lastSyncTimeService).saveLastSyncTime(argumentCaptor.capture()); LastSyncTime savedLastSyncTime = argumentCaptor.getValue(); assertThat(savedLastSyncTime.getApiName(), is(DOWNLOAD_ENCOUNTERS)); assertThat(savedLastSyncTime.getLastSyncDate(), is(updatedDate)); assertThat(savedLastSyncTime.getParamSignature(), is("patientUuid1,patientUuid2")); }
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); }
@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); }
@Test public void getAllPatients_shouldReturnAllAvailablePatients() throws IOException, PatientController.PatientLoadException { List<Patient> patients = new ArrayList<>(); when(patientService.getAllPatients()).thenReturn(patients); assertThat(patientController.getAllPatients(), is(patients)); }
public List<Patient> getAllPatients() throws PatientLoadException { try { return patientService.getAllPatients(); } catch (IOException e) { throw new PatientLoadException(e); } }
PatientController { public List<Patient> getAllPatients() throws PatientLoadException { try { return patientService.getAllPatients(); } catch (IOException e) { throw new PatientLoadException(e); } } }
PatientController { public List<Patient> getAllPatients() throws PatientLoadException { try { return patientService.getAllPatients(); } catch (IOException e) { throw new PatientLoadException(e); } } PatientController(PatientService patientService, CohortService cohortService, FormService formService,PatientTagService patientTagService); }
PatientController { public List<Patient> getAllPatients() throws PatientLoadException { try { return patientService.getAllPatients(); } catch (IOException 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); }
PatientController { public List<Patient> getAllPatients() throws PatientLoadException { try { return patientService.getAllPatients(); } catch (IOException 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); }
@Test(expected = PatientController.PatientLoadException.class) public void getAllForms_shouldThrowFormFetchExceptionIfExceptionThrownByFormService() throws IOException, PatientController.PatientLoadException { doThrow(new IOException()).when(patientService).getAllPatients(); patientController.getAllPatients(); }
public List<Patient> getAllPatients() throws PatientLoadException { try { return patientService.getAllPatients(); } catch (IOException e) { throw new PatientLoadException(e); } }
PatientController { public List<Patient> getAllPatients() throws PatientLoadException { try { return patientService.getAllPatients(); } catch (IOException e) { throw new PatientLoadException(e); } } }
PatientController { public List<Patient> getAllPatients() throws PatientLoadException { try { return patientService.getAllPatients(); } catch (IOException e) { throw new PatientLoadException(e); } } PatientController(PatientService patientService, CohortService cohortService, FormService formService,PatientTagService patientTagService); }
PatientController { public List<Patient> getAllPatients() throws PatientLoadException { try { return patientService.getAllPatients(); } catch (IOException 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); }
PatientController { public List<Patient> getAllPatients() throws PatientLoadException { try { return patientService.getAllPatients(); } catch (IOException 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); }
@Test public void getTotalPatientsCount_shouldReturnPatientsCount() throws IOException, PatientController.PatientLoadException { when(patientService.countAllPatients()).thenReturn(2); assertThat(patientController.countAllPatients(), is(2)); }
public int countAllPatients() throws PatientLoadException { try { return patientService.countAllPatients(); } catch (IOException e) { throw new PatientLoadException(e); } }
PatientController { public int countAllPatients() throws PatientLoadException { try { return patientService.countAllPatients(); } catch (IOException e) { throw new PatientLoadException(e); } } }
PatientController { public int countAllPatients() throws PatientLoadException { try { return patientService.countAllPatients(); } catch (IOException e) { throw new PatientLoadException(e); } } PatientController(PatientService patientService, CohortService cohortService, FormService formService,PatientTagService patientTagService); }
PatientController { public int countAllPatients() throws PatientLoadException { try { return patientService.countAllPatients(); } catch (IOException 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); }
PatientController { public int countAllPatients() throws PatientLoadException { try { return patientService.countAllPatients(); } catch (IOException 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); }
@Test public void replacePatients_shouldReplaceAllExistingPatientsAndAddNewPatients() throws IOException, PatientController.PatientSaveException { List<Patient> patients = buildPatients(); patientController.replacePatients(patients); verify(patientService).updatePatients(patients); verifyNoMoreInteractions(patientService); }
public void replacePatients(List<Patient> patients) throws PatientSaveException { try { patientService.updatePatients(patients); } catch (IOException e) { throw new PatientSaveException(e); } }
PatientController { public void replacePatients(List<Patient> patients) throws PatientSaveException { try { patientService.updatePatients(patients); } catch (IOException e) { throw new PatientSaveException(e); } } }
PatientController { public void replacePatients(List<Patient> patients) throws PatientSaveException { try { patientService.updatePatients(patients); } catch (IOException e) { throw new PatientSaveException(e); } } PatientController(PatientService patientService, CohortService cohortService, FormService formService,PatientTagService patientTagService); }
PatientController { public void replacePatients(List<Patient> patients) throws PatientSaveException { try { patientService.updatePatients(patients); } catch (IOException e) { throw new PatientSaveException(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); }
PatientController { public void replacePatients(List<Patient> patients) throws PatientSaveException { try { patientService.updatePatients(patients); } catch (IOException e) { throw new PatientSaveException(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); }
@Test(expected = PatientController.PatientSaveException.class) public void replacePatients_shouldThrowPatientReplaceExceptionIfExceptionThrownByService() throws IOException, PatientController.PatientSaveException { List<Patient> patients = buildPatients(); doThrow(new IOException()).when(patientService).updatePatients(patients); patientController.replacePatients(patients); }
public void replacePatients(List<Patient> patients) throws PatientSaveException { try { patientService.updatePatients(patients); } catch (IOException e) { throw new PatientSaveException(e); } }
PatientController { public void replacePatients(List<Patient> patients) throws PatientSaveException { try { patientService.updatePatients(patients); } catch (IOException e) { throw new PatientSaveException(e); } } }
PatientController { public void replacePatients(List<Patient> patients) throws PatientSaveException { try { patientService.updatePatients(patients); } catch (IOException e) { throw new PatientSaveException(e); } } PatientController(PatientService patientService, CohortService cohortService, FormService formService,PatientTagService patientTagService); }
PatientController { public void replacePatients(List<Patient> patients) throws PatientSaveException { try { patientService.updatePatients(patients); } catch (IOException e) { throw new PatientSaveException(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); }
PatientController { public void replacePatients(List<Patient> patients) throws PatientSaveException { try { patientService.updatePatients(patients); } catch (IOException e) { throw new PatientSaveException(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); }
@Test public void getPatientsInCohort_shouldReturnThePatientsInTheCohort() throws IOException, PatientController.PatientLoadException { String cohortId = "cohortId"; List<CohortMember> members = buildCohortMembers(cohortId); when(cohortService.getCohortMembers(cohortId)).thenReturn(members); Patient patient = new Patient(); patient.setUuid(members.get(0).getPatientUuid()); when(patientService.getPatientsFromCohortMembers(members)).thenReturn(Collections.singletonList(patient)); List<Patient> patients = patientController.getPatients(cohortId); assertThat(patients.size(), is(1)); }
public List<Patient> getPatients(String cohortId) throws PatientLoadException { try { List<CohortMember> cohortMembers = cohortService.getCohortMembers(cohortId); return patientService.getPatientsFromCohortMembers(cohortMembers); } catch (IOException e) { throw new PatientLoadException(e); } }
PatientController { public List<Patient> getPatients(String cohortId) throws PatientLoadException { try { List<CohortMember> cohortMembers = cohortService.getCohortMembers(cohortId); return patientService.getPatientsFromCohortMembers(cohortMembers); } catch (IOException e) { throw new PatientLoadException(e); } } }
PatientController { public List<Patient> getPatients(String cohortId) throws PatientLoadException { try { List<CohortMember> cohortMembers = cohortService.getCohortMembers(cohortId); return patientService.getPatientsFromCohortMembers(cohortMembers); } catch (IOException e) { throw new PatientLoadException(e); } } PatientController(PatientService patientService, CohortService cohortService, FormService formService,PatientTagService patientTagService); }
PatientController { public List<Patient> getPatients(String cohortId) throws PatientLoadException { try { List<CohortMember> cohortMembers = cohortService.getCohortMembers(cohortId); return patientService.getPatientsFromCohortMembers(cohortMembers); } catch (IOException 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); }
PatientController { public List<Patient> getPatients(String cohortId) throws PatientLoadException { try { List<CohortMember> cohortMembers = cohortService.getCohortMembers(cohortId); return patientService.getPatientsFromCohortMembers(cohortMembers); } catch (IOException 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); }
@Test public void shouldGetObservationsByPatientUUID() throws ObservationController.LoadObservationException { ObservationController controller = mock(ObservationController.class); ConceptController conceptController = mock(ConceptController.class); ConceptsByPatient byPatient = new ConceptsByPatient(conceptController,controller, "uuid"); byPatient.get(); verify(controller).getConceptWithObservations("uuid"); }
@Override Concepts get() throws ObservationController.LoadObservationException { return controller.getConceptWithObservations(patientUuid); }
ConceptsByPatient extends ConceptAction { @Override Concepts get() throws ObservationController.LoadObservationException { return controller.getConceptWithObservations(patientUuid); } }
ConceptsByPatient extends ConceptAction { @Override Concepts get() throws ObservationController.LoadObservationException { return controller.getConceptWithObservations(patientUuid); } ConceptsByPatient(ConceptController conceptController, ObservationController controller, String patientUuid); }
ConceptsByPatient extends ConceptAction { @Override Concepts get() throws ObservationController.LoadObservationException { return controller.getConceptWithObservations(patientUuid); } ConceptsByPatient(ConceptController conceptController, ObservationController controller, String patientUuid); @Override String toString(); }
ConceptsByPatient extends ConceptAction { @Override Concepts get() throws ObservationController.LoadObservationException { return controller.getConceptWithObservations(patientUuid); } ConceptsByPatient(ConceptController conceptController, ObservationController controller, String patientUuid); @Override String toString(); }
@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); }
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 { 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 { 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); }
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); }
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); }
@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); }
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 { 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 { 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); }
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); }
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); }
@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); }
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 { 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 { 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); }
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); }
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); }
@Test public void getPatientByUuid_shouldReturnPatientForId() throws Exception, PatientController.PatientLoadException { Patient patient = new Patient(); String uuid = "uuid"; when(patientService.getPatientByUuid(uuid)).thenReturn(patient); assertThat(patientController.getPatientByUuid(uuid), is(patient)); }
public Patient getPatientByUuid(String uuid) throws PatientLoadException { try { return patientService.getPatientByUuid(uuid); } catch (IOException e) { throw new PatientLoadException(e); } }
PatientController { public Patient getPatientByUuid(String uuid) throws PatientLoadException { try { return patientService.getPatientByUuid(uuid); } catch (IOException e) { throw new PatientLoadException(e); } } }
PatientController { public Patient getPatientByUuid(String uuid) throws PatientLoadException { try { return patientService.getPatientByUuid(uuid); } catch (IOException e) { throw new PatientLoadException(e); } } PatientController(PatientService patientService, CohortService cohortService, FormService formService,PatientTagService patientTagService); }
PatientController { public Patient getPatientByUuid(String uuid) throws PatientLoadException { try { return patientService.getPatientByUuid(uuid); } catch (IOException 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); }
PatientController { public Patient getPatientByUuid(String uuid) throws PatientLoadException { try { return patientService.getPatientByUuid(uuid); } catch (IOException 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); }
@Test public void shouldSearchOnServerForPatientByNames() throws Exception { String name = "name"; List<Patient> patients = new ArrayList<>(); when(patientService.downloadPatientsByName(name)).thenReturn(patients); assertThat(patientController.searchPatientOnServer(name), is(patients)); verify(patientService).downloadPatientsByName(name); }
public List<Patient> searchPatientOnServer(String name) { try { return patientService.downloadPatientsByName(name); } catch (IOException e) { Log.e(getClass().getSimpleName(), "Error while searching for patients in the server", e); } return new ArrayList<>(); }
PatientController { public List<Patient> searchPatientOnServer(String name) { try { return patientService.downloadPatientsByName(name); } catch (IOException e) { Log.e(getClass().getSimpleName(), "Error while searching for patients in the server", e); } return new ArrayList<>(); } }
PatientController { public List<Patient> searchPatientOnServer(String name) { try { return patientService.downloadPatientsByName(name); } catch (IOException e) { Log.e(getClass().getSimpleName(), "Error while searching for patients in the server", e); } return new ArrayList<>(); } PatientController(PatientService patientService, CohortService cohortService, FormService formService,PatientTagService patientTagService); }
PatientController { public List<Patient> searchPatientOnServer(String name) { try { return patientService.downloadPatientsByName(name); } catch (IOException e) { Log.e(getClass().getSimpleName(), "Error while searching for patients in the server", e); } return new ArrayList<>(); } 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); }
PatientController { public List<Patient> searchPatientOnServer(String name) { try { return patientService.downloadPatientsByName(name); } catch (IOException e) { Log.e(getClass().getSimpleName(), "Error while searching for patients in the server", e); } return new ArrayList<>(); } 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); }
@Test public void shouldReturnEmptyListIsExceptionThrown() throws Exception { String searchString = "name"; doThrow(new IOException()).when(patientService).downloadPatientsByName(searchString); assertThat(patientController.searchPatientOnServer(searchString).size(), is(0)); }
public List<Patient> searchPatientOnServer(String name) { try { return patientService.downloadPatientsByName(name); } catch (IOException e) { Log.e(getClass().getSimpleName(), "Error while searching for patients in the server", e); } return new ArrayList<>(); }
PatientController { public List<Patient> searchPatientOnServer(String name) { try { return patientService.downloadPatientsByName(name); } catch (IOException e) { Log.e(getClass().getSimpleName(), "Error while searching for patients in the server", e); } return new ArrayList<>(); } }
PatientController { public List<Patient> searchPatientOnServer(String name) { try { return patientService.downloadPatientsByName(name); } catch (IOException e) { Log.e(getClass().getSimpleName(), "Error while searching for patients in the server", e); } return new ArrayList<>(); } PatientController(PatientService patientService, CohortService cohortService, FormService formService,PatientTagService patientTagService); }
PatientController { public List<Patient> searchPatientOnServer(String name) { try { return patientService.downloadPatientsByName(name); } catch (IOException e) { Log.e(getClass().getSimpleName(), "Error while searching for patients in the server", e); } return new ArrayList<>(); } 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); }
PatientController { public List<Patient> searchPatientOnServer(String name) { try { return patientService.downloadPatientsByName(name); } catch (IOException e) { Log.e(getClass().getSimpleName(), "Error while searching for patients in the server", e); } return new ArrayList<>(); } 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); }
@Test public void shouldConsolidatePatients() throws Exception { Patient tempPatient = mock(Patient.class); Patient patient = mock(Patient.class); when(patientService.consolidateTemporaryPatient(tempPatient)).thenReturn(patient); assertThat(patient, is(patientController.consolidateTemporaryPatient(tempPatient))); }
public Patient consolidateTemporaryPatient(Patient patient) { try { return patientService.consolidateTemporaryPatient(patient); } catch (IOException e) { Log.e(getClass().getSimpleName(), "Error while consolidating the temporary patient.", e); } return null; }
PatientController { public Patient consolidateTemporaryPatient(Patient patient) { try { return patientService.consolidateTemporaryPatient(patient); } catch (IOException e) { Log.e(getClass().getSimpleName(), "Error while consolidating the temporary patient.", e); } return null; } }
PatientController { public Patient consolidateTemporaryPatient(Patient patient) { try { return patientService.consolidateTemporaryPatient(patient); } catch (IOException e) { Log.e(getClass().getSimpleName(), "Error while consolidating the temporary patient.", e); } return null; } PatientController(PatientService patientService, CohortService cohortService, FormService formService,PatientTagService patientTagService); }
PatientController { public Patient consolidateTemporaryPatient(Patient patient) { try { return patientService.consolidateTemporaryPatient(patient); } catch (IOException e) { Log.e(getClass().getSimpleName(), "Error while consolidating the temporary patient.", e); } return null; } 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); }
PatientController { public Patient consolidateTemporaryPatient(Patient patient) { try { return patientService.consolidateTemporaryPatient(patient); } catch (IOException e) { Log.e(getClass().getSimpleName(), "Error while consolidating the temporary patient.", e); } return null; } 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); }
@Test public void getTotalFormCount_shouldReturnTotalAvailableForms() throws IOException, FormController.FormFetchException { when(formService.countAllForms()).thenReturn(2); assertThat(formController.getTotalFormCount(), is(2)); }
public int getTotalFormCount() throws FormFetchException { try { return formService.countAllForms(); } catch (IOException e) { throw new FormFetchException(e); } }
FormController { public int getTotalFormCount() throws FormFetchException { try { return formService.countAllForms(); } catch (IOException e) { throw new FormFetchException(e); } } }
FormController { public int getTotalFormCount() throws FormFetchException { try { return formService.countAllForms(); } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); }
FormController { public int getTotalFormCount() throws FormFetchException { try { return formService.countAllForms(); } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public int getTotalFormCount() throws FormFetchException { try { return formService.countAllForms(); } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test public void getAllFormByTags_shouldFetchAllFormsWithGivenTags() throws IOException, FormController.FormFetchException { List<Form> forms = buildForms(); when(formService.getAllForms()).thenReturn(forms); when(formService.isFormTemplateDownloaded(forms.get(0).getUuid())).thenReturn(false); when(formService.isFormTemplateDownloaded(forms.get(1).getUuid())).thenReturn(true); when(formService.isFormTemplateDownloaded(forms.get(2).getUuid())).thenReturn(false); AvailableForms availableForms = formController.getAvailableFormByTags(Collections.singletonList("tag2")); assertThat(availableForms.size(), is(2)); assertTrue(containsFormWithUuid(availableForms, forms.get(0).getUuid())); assertTrue(containsFormWithUuid(availableForms, forms.get(2).getUuid())); availableForms = formController.getAvailableFormByTags(Collections.singletonList("tag1")); assertThat(availableForms.size(), is(2)); assertTrue(containsFormWithUuid(availableForms, forms.get(0).getUuid())); assertTrue(containsFormWithUuid(availableForms, forms.get(1).getUuid())); }
public AvailableForms getAvailableFormByTags(List<String> tagsUuid) throws FormFetchException { return getAvailableFormByTags(tagsUuid, false); }
FormController { public AvailableForms getAvailableFormByTags(List<String> tagsUuid) throws FormFetchException { return getAvailableFormByTags(tagsUuid, false); } }
FormController { public AvailableForms getAvailableFormByTags(List<String> tagsUuid) throws FormFetchException { return getAvailableFormByTags(tagsUuid, false); } FormController(MuzimaApplication muzimaApplication); }
FormController { public AvailableForms getAvailableFormByTags(List<String> tagsUuid) throws FormFetchException { return getAvailableFormByTags(tagsUuid, false); } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public AvailableForms getAvailableFormByTags(List<String> tagsUuid) throws FormFetchException { return getAvailableFormByTags(tagsUuid, false); } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test public void getAllFormByTags_shouldAssignDownloadStatusToForms() throws IOException, FormController.FormFetchException { List<Form> forms = buildForms(); when(formService.getAllForms()).thenReturn(forms); when(formService.isFormTemplateDownloaded(forms.get(0).getUuid())).thenReturn(false); when(formService.isFormTemplateDownloaded(forms.get(1).getUuid())).thenReturn(true); when(formService.isFormTemplateDownloaded(forms.get(2).getUuid())).thenReturn(false); AvailableForms availableForms = formController.getAvailableFormByTags(Collections.singletonList("tag2")); assertThat(getAvailableFormWithUuid(availableForms, forms.get(0).getUuid()).isDownloaded(), is(false)); assertThat(getAvailableFormWithUuid(availableForms, forms.get(2).getUuid()).isDownloaded(), is(false)); availableForms = formController.getAvailableFormByTags(Collections.singletonList("tag1")); assertThat(getAvailableFormWithUuid(availableForms, forms.get(0).getUuid()).isDownloaded(), is(false)); assertThat(getAvailableFormWithUuid(availableForms, forms.get(1).getUuid()).isDownloaded(), is(true)); }
public AvailableForms getAvailableFormByTags(List<String> tagsUuid) throws FormFetchException { return getAvailableFormByTags(tagsUuid, false); }
FormController { public AvailableForms getAvailableFormByTags(List<String> tagsUuid) throws FormFetchException { return getAvailableFormByTags(tagsUuid, false); } }
FormController { public AvailableForms getAvailableFormByTags(List<String> tagsUuid) throws FormFetchException { return getAvailableFormByTags(tagsUuid, false); } FormController(MuzimaApplication muzimaApplication); }
FormController { public AvailableForms getAvailableFormByTags(List<String> tagsUuid) throws FormFetchException { return getAvailableFormByTags(tagsUuid, false); } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public AvailableForms getAvailableFormByTags(List<String> tagsUuid) throws FormFetchException { return getAvailableFormByTags(tagsUuid, false); } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test public void shouldSearchObservationsByUuidAndTerm() throws ObservationController.LoadObservationException { ObservationController controller = mock(ObservationController.class); ConceptController conceptController = mock(ConceptController.class); ConceptsBySearch conceptsBySearch = new ConceptsBySearch(conceptController,controller, "uuid", "term"); conceptsBySearch.get(); verify(controller).searchObservationsGroupedByConcepts("term", "uuid"); }
@Override Concepts get() throws ObservationController.LoadObservationException { return controller.searchObservationsGroupedByConcepts(term, patientUuid); }
ConceptsBySearch extends ConceptAction { @Override Concepts get() throws ObservationController.LoadObservationException { return controller.searchObservationsGroupedByConcepts(term, patientUuid); } }
ConceptsBySearch extends ConceptAction { @Override Concepts get() throws ObservationController.LoadObservationException { return controller.searchObservationsGroupedByConcepts(term, patientUuid); } ConceptsBySearch(ConceptController conceptController, ObservationController controller, String patientUuid, String term); }
ConceptsBySearch extends ConceptAction { @Override Concepts get() throws ObservationController.LoadObservationException { return controller.searchObservationsGroupedByConcepts(term, patientUuid); } ConceptsBySearch(ConceptController conceptController, ObservationController controller, String patientUuid, String term); @Override String toString(); }
ConceptsBySearch extends ConceptAction { @Override Concepts get() throws ObservationController.LoadObservationException { return controller.searchObservationsGroupedByConcepts(term, patientUuid); } ConceptsBySearch(ConceptController conceptController, ObservationController controller, String patientUuid, String term); @Override String toString(); }
@Test public void getAllFormByTags_shouldFetchAllFormsIfNoTagsAreProvided() throws IOException, FormController.FormFetchException { List<Form> forms = buildForms(); when(formService.getAllForms()).thenReturn(forms); AvailableForms availableFormByTags = formController.getAvailableFormByTags(new ArrayList<String>()); assertThat(availableFormByTags.size(), is(5)); }
public AvailableForms getAvailableFormByTags(List<String> tagsUuid) throws FormFetchException { return getAvailableFormByTags(tagsUuid, false); }
FormController { public AvailableForms getAvailableFormByTags(List<String> tagsUuid) throws FormFetchException { return getAvailableFormByTags(tagsUuid, false); } }
FormController { public AvailableForms getAvailableFormByTags(List<String> tagsUuid) throws FormFetchException { return getAvailableFormByTags(tagsUuid, false); } FormController(MuzimaApplication muzimaApplication); }
FormController { public AvailableForms getAvailableFormByTags(List<String> tagsUuid) throws FormFetchException { return getAvailableFormByTags(tagsUuid, false); } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public AvailableForms getAvailableFormByTags(List<String> tagsUuid) throws FormFetchException { return getAvailableFormByTags(tagsUuid, false); } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test public void downloadAllForms_shouldDownloadAllForms() throws IOException, FormController.FormFetchException { List<Form> forms = new ArrayList<>(); when(formService.downloadFormsByName(StringUtils.EMPTY)).thenReturn(forms); when(lastSyncTimeService.getLastSyncTimeFor(DOWNLOAD_FORMS)).thenReturn(mockDate); assertThat(formController.downloadAllForms(), is(forms)); }
public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } }
FormController { public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } } }
FormController { public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); }
FormController { public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test public void shouldCheckForLastSynTimeOfFormWhenDownloadingAllForms() throws Exception, FormController.FormFetchException { when(lastSyncTimeService.getLastSyncTimeFor(DOWNLOAD_FORMS)).thenReturn(mockDate); formController.downloadAllForms(); verify(lastSyncTimeService).getLastSyncTimeFor(DOWNLOAD_FORMS); verify(formService, never()).downloadFormsByName(StringUtils.EMPTY); verify(formService).downloadFormsByName(StringUtils.EMPTY, mockDate); }
public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } }
FormController { public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } } }
FormController { public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); }
FormController { public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test public void shouldUpdateLastSyncTimeAfterDownloadingAllForms() throws Exception, FormController.FormFetchException { Date mockDate = mock(Date.class); when(lastSyncTimeService.getLastSyncTimeFor(DOWNLOAD_FORMS)).thenReturn(mockDate); Date otherMockDate = mock(Date.class); when(sntpService.getTimePerDeviceTimeZone()).thenReturn(otherMockDate); formController.downloadAllForms(); ArgumentCaptor<LastSyncTime> argumentCaptor = ArgumentCaptor.forClass(LastSyncTime.class); verify(lastSyncTimeService).saveLastSyncTime(argumentCaptor.capture()); LastSyncTime savedLastSyncTime = argumentCaptor.getValue(); assertThat(savedLastSyncTime.getApiName(), is(DOWNLOAD_FORMS)); assertThat(savedLastSyncTime.getParamSignature(), nullValue()); assertThat(savedLastSyncTime.getLastSyncDate(), is(otherMockDate)); }
public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } }
FormController { public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } } }
FormController { public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); }
FormController { public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test(expected = FormController.FormFetchException.class) public void downloadAllForms_shouldThrowExceptionThrownByFormService() throws IOException, FormController.FormFetchException { when(lastSyncTimeService.getLastSyncTimeFor(DOWNLOAD_FORMS)).thenReturn(mockDate); doThrow(new IOException()).when(formService).downloadFormsByName(StringUtils.EMPTY, mockDate); formController.downloadAllForms(); }
public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } }
FormController { public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } } }
FormController { public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); }
FormController { public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public List<Form> downloadAllForms() throws FormFetchException { try { Date lastSyncDate = lastSyncTimeService.getLastSyncTimeFor(APIName.DOWNLOAD_FORMS); List<Form> forms = formService.downloadFormsByName(StringUtils.EMPTY, lastSyncDate); LastSyncTime lastSyncTime = new LastSyncTime(APIName.DOWNLOAD_FORMS, sntpService.getTimePerDeviceTimeZone()); lastSyncTimeService.saveLastSyncTime(lastSyncTime); return forms; } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test public void downloadFormTemplateByUuid_shouldDownloadFormByUuid() throws IOException, FormController.FormFetchException { FormTemplate formTemplate = new FormTemplate(); String uuid = "uuid"; when(formService.downloadFormTemplateByUuid(uuid)).thenReturn(formTemplate); assertThat(formController.downloadFormTemplateByUuid(uuid), is(formTemplate)); }
public FormTemplate downloadFormTemplateByUuid(String uuid) throws FormFetchException { try { return formService.downloadFormTemplateByUuid(uuid); } catch (IOException e) { throw new FormFetchException(e); } }
FormController { public FormTemplate downloadFormTemplateByUuid(String uuid) throws FormFetchException { try { return formService.downloadFormTemplateByUuid(uuid); } catch (IOException e) { throw new FormFetchException(e); } } }
FormController { public FormTemplate downloadFormTemplateByUuid(String uuid) throws FormFetchException { try { return formService.downloadFormTemplateByUuid(uuid); } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); }
FormController { public FormTemplate downloadFormTemplateByUuid(String uuid) throws FormFetchException { try { return formService.downloadFormTemplateByUuid(uuid); } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public FormTemplate downloadFormTemplateByUuid(String uuid) throws FormFetchException { try { return formService.downloadFormTemplateByUuid(uuid); } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test(expected = FormController.FormFetchException.class) public void downloadFormTemplateByUuid_shouldThrowFormFetchExceptionIfExceptionThrownByFormService() throws IOException, FormController.FormFetchException { String uuid = "uuid"; doThrow(new IOException()).when(formService).downloadFormTemplateByUuid(uuid); formController.downloadFormTemplateByUuid(uuid); }
public FormTemplate downloadFormTemplateByUuid(String uuid) throws FormFetchException { try { return formService.downloadFormTemplateByUuid(uuid); } catch (IOException e) { throw new FormFetchException(e); } }
FormController { public FormTemplate downloadFormTemplateByUuid(String uuid) throws FormFetchException { try { return formService.downloadFormTemplateByUuid(uuid); } catch (IOException e) { throw new FormFetchException(e); } } }
FormController { public FormTemplate downloadFormTemplateByUuid(String uuid) throws FormFetchException { try { return formService.downloadFormTemplateByUuid(uuid); } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); }
FormController { public FormTemplate downloadFormTemplateByUuid(String uuid) throws FormFetchException { try { return formService.downloadFormTemplateByUuid(uuid); } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public FormTemplate downloadFormTemplateByUuid(String uuid) throws FormFetchException { try { return formService.downloadFormTemplateByUuid(uuid); } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test public void saveAllForms_shouldSaveAllForm() throws FormController.FormSaveException, IOException { List<Form> forms = buildForms(); formController.saveAllForms(forms); verify(formService).saveForms(forms); verifyNoMoreInteractions(formService); }
public void saveAllForms(List<Form> forms) throws FormSaveException { try { formService.saveForms(forms); } catch (IOException e) { throw new FormSaveException(e); } }
FormController { public void saveAllForms(List<Form> forms) throws FormSaveException { try { formService.saveForms(forms); } catch (IOException e) { throw new FormSaveException(e); } } }
FormController { public void saveAllForms(List<Form> forms) throws FormSaveException { try { formService.saveForms(forms); } catch (IOException e) { throw new FormSaveException(e); } } FormController(MuzimaApplication muzimaApplication); }
FormController { public void saveAllForms(List<Form> forms) throws FormSaveException { try { formService.saveForms(forms); } catch (IOException e) { throw new FormSaveException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public void saveAllForms(List<Form> forms) throws FormSaveException { try { formService.saveForms(forms); } catch (IOException e) { throw new FormSaveException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test(expected = FormController.FormSaveException.class) public void saveAllForms_shouldThrowFormSaveExceptionIfExceptionThrownByFormService() throws FormController.FormSaveException, IOException { List<Form> forms = buildForms(); doThrow(new IOException()).when(formService).saveForms(forms); formController.saveAllForms(forms); }
public void saveAllForms(List<Form> forms) throws FormSaveException { try { formService.saveForms(forms); } catch (IOException e) { throw new FormSaveException(e); } }
FormController { public void saveAllForms(List<Form> forms) throws FormSaveException { try { formService.saveForms(forms); } catch (IOException e) { throw new FormSaveException(e); } } }
FormController { public void saveAllForms(List<Form> forms) throws FormSaveException { try { formService.saveForms(forms); } catch (IOException e) { throw new FormSaveException(e); } } FormController(MuzimaApplication muzimaApplication); }
FormController { public void saveAllForms(List<Form> forms) throws FormSaveException { try { formService.saveForms(forms); } catch (IOException e) { throw new FormSaveException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public void saveAllForms(List<Form> forms) throws FormSaveException { try { formService.saveForms(forms); } catch (IOException e) { throw new FormSaveException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test public void getAllTags_shouldFetchAllUsedTags() throws FormController.FormFetchException, IOException { when(formService.getAllForms()).thenReturn(buildForms()); List<Tag> allTags = formController.getAllTags(); assertThat(allTags.size(), is(5)); assertThat(allTags.get(0).getUuid(), is("tag1")); assertThat(allTags.get(1).getUuid(), is("tag2")); assertThat(allTags.get(2).getUuid(), is("tag3")); assertThat(allTags.get(3).getUuid(), is("tag4")); assertThat(allTags.get(4).getUuid(), is("tag5")); }
public List<Tag> getAllTags() throws FormFetchException { List<Tag> allTags = new ArrayList<>(); List<Form> allForms = null; try { allForms = formService.getAllForms(); } catch (IOException e) { throw new FormFetchException(e); } for (Form form : allForms) { for (Tag tag : form.getTags()) { if (!allTags.contains(tag)) { allTags.add(tag); } } } return allTags; }
FormController { public List<Tag> getAllTags() throws FormFetchException { List<Tag> allTags = new ArrayList<>(); List<Form> allForms = null; try { allForms = formService.getAllForms(); } catch (IOException e) { throw new FormFetchException(e); } for (Form form : allForms) { for (Tag tag : form.getTags()) { if (!allTags.contains(tag)) { allTags.add(tag); } } } return allTags; } }
FormController { public List<Tag> getAllTags() throws FormFetchException { List<Tag> allTags = new ArrayList<>(); List<Form> allForms = null; try { allForms = formService.getAllForms(); } catch (IOException e) { throw new FormFetchException(e); } for (Form form : allForms) { for (Tag tag : form.getTags()) { if (!allTags.contains(tag)) { allTags.add(tag); } } } return allTags; } FormController(MuzimaApplication muzimaApplication); }
FormController { public List<Tag> getAllTags() throws FormFetchException { List<Tag> allTags = new ArrayList<>(); List<Form> allForms = null; try { allForms = formService.getAllForms(); } catch (IOException e) { throw new FormFetchException(e); } for (Form form : allForms) { for (Tag tag : form.getTags()) { if (!allTags.contains(tag)) { allTags.add(tag); } } } return allTags; } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public List<Tag> getAllTags() throws FormFetchException { List<Tag> allTags = new ArrayList<>(); List<Form> allForms = null; try { allForms = formService.getAllForms(); } catch (IOException e) { throw new FormFetchException(e); } for (Form form : allForms) { for (Tag tag : form.getTags()) { if (!allTags.contains(tag)) { allTags.add(tag); } } } return allTags; } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test public void authenticate_shouldReturnSuccessStatusIfAuthenticated() { String[] credentials = new String[]{"username", "password", "url"}; assertThat(muzimaSyncService.authenticate(credentials), is(SyncStatusConstants.AUTHENTICATION_SUCCESS)); }
public int authenticate(String[] credentials) { return authenticate(credentials, false); }
MuzimaSyncService { public int authenticate(String[] credentials) { return authenticate(credentials, false); } }
MuzimaSyncService { public int authenticate(String[] credentials) { return authenticate(credentials, false); } MuzimaSyncService(MuzimaApplication muzimaContext); }
MuzimaSyncService { public int authenticate(String[] credentials) { return authenticate(credentials, false); } 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 authenticate(String[] credentials) { return authenticate(credentials, false); } 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(); }
@Test public void getAllDownloadedForms_shouldReturnOnlyDownloadedForms() throws IOException, FormController.FormFetchException { List<Form> forms = buildForms(); when(formService.getAllForms()).thenReturn(forms); when(formService.isFormTemplateDownloaded(forms.get(0).getUuid())).thenReturn(true); DownloadedForms allDownloadedForms = formController.getAllDownloadedForms(); assertThat(allDownloadedForms.size(), is(1)); }
public DownloadedForms getAllDownloadedForms() throws FormFetchException { DownloadedForms downloadedFormsByTags = new DownloadedForms(); try { List<Form> allForms = formService.getAllForms(); ArrayList<String> formUuids = getFormListAsPerConfigOrder(); for (String formUuid : formUuids) { Form form = formService.getFormByUuid(formUuid); if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } for (Form form : allForms) { if (!formUuids.contains(form.getUuid())) { if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } } } catch (IOException e) { throw new FormFetchException(e); } return downloadedFormsByTags; }
FormController { public DownloadedForms getAllDownloadedForms() throws FormFetchException { DownloadedForms downloadedFormsByTags = new DownloadedForms(); try { List<Form> allForms = formService.getAllForms(); ArrayList<String> formUuids = getFormListAsPerConfigOrder(); for (String formUuid : formUuids) { Form form = formService.getFormByUuid(formUuid); if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } for (Form form : allForms) { if (!formUuids.contains(form.getUuid())) { if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } } } catch (IOException e) { throw new FormFetchException(e); } return downloadedFormsByTags; } }
FormController { public DownloadedForms getAllDownloadedForms() throws FormFetchException { DownloadedForms downloadedFormsByTags = new DownloadedForms(); try { List<Form> allForms = formService.getAllForms(); ArrayList<String> formUuids = getFormListAsPerConfigOrder(); for (String formUuid : formUuids) { Form form = formService.getFormByUuid(formUuid); if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } for (Form form : allForms) { if (!formUuids.contains(form.getUuid())) { if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } } } catch (IOException e) { throw new FormFetchException(e); } return downloadedFormsByTags; } FormController(MuzimaApplication muzimaApplication); }
FormController { public DownloadedForms getAllDownloadedForms() throws FormFetchException { DownloadedForms downloadedFormsByTags = new DownloadedForms(); try { List<Form> allForms = formService.getAllForms(); ArrayList<String> formUuids = getFormListAsPerConfigOrder(); for (String formUuid : formUuids) { Form form = formService.getFormByUuid(formUuid); if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } for (Form form : allForms) { if (!formUuids.contains(form.getUuid())) { if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } } } catch (IOException e) { throw new FormFetchException(e); } return downloadedFormsByTags; } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public DownloadedForms getAllDownloadedForms() throws FormFetchException { DownloadedForms downloadedFormsByTags = new DownloadedForms(); try { List<Form> allForms = formService.getAllForms(); ArrayList<String> formUuids = getFormListAsPerConfigOrder(); for (String formUuid : formUuids) { Form form = formService.getFormByUuid(formUuid); if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } for (Form form : allForms) { if (!formUuids.contains(form.getUuid())) { if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } } } catch (IOException e) { throw new FormFetchException(e); } return downloadedFormsByTags; } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test public void getAllDownloadedForms_shouldReturnNoFormsIfNoTemplateIsDownloaded() throws IOException, FormController.FormFetchException { List<Form> forms = buildForms(); when(formService.getAllForms()).thenReturn(forms); when(formService.isFormTemplateDownloaded(anyString())).thenReturn(false); DownloadedForms allDownloadedForms = formController.getAllDownloadedForms(); assertThat(allDownloadedForms.size(), is(0)); }
public DownloadedForms getAllDownloadedForms() throws FormFetchException { DownloadedForms downloadedFormsByTags = new DownloadedForms(); try { List<Form> allForms = formService.getAllForms(); ArrayList<String> formUuids = getFormListAsPerConfigOrder(); for (String formUuid : formUuids) { Form form = formService.getFormByUuid(formUuid); if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } for (Form form : allForms) { if (!formUuids.contains(form.getUuid())) { if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } } } catch (IOException e) { throw new FormFetchException(e); } return downloadedFormsByTags; }
FormController { public DownloadedForms getAllDownloadedForms() throws FormFetchException { DownloadedForms downloadedFormsByTags = new DownloadedForms(); try { List<Form> allForms = formService.getAllForms(); ArrayList<String> formUuids = getFormListAsPerConfigOrder(); for (String formUuid : formUuids) { Form form = formService.getFormByUuid(formUuid); if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } for (Form form : allForms) { if (!formUuids.contains(form.getUuid())) { if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } } } catch (IOException e) { throw new FormFetchException(e); } return downloadedFormsByTags; } }
FormController { public DownloadedForms getAllDownloadedForms() throws FormFetchException { DownloadedForms downloadedFormsByTags = new DownloadedForms(); try { List<Form> allForms = formService.getAllForms(); ArrayList<String> formUuids = getFormListAsPerConfigOrder(); for (String formUuid : formUuids) { Form form = formService.getFormByUuid(formUuid); if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } for (Form form : allForms) { if (!formUuids.contains(form.getUuid())) { if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } } } catch (IOException e) { throw new FormFetchException(e); } return downloadedFormsByTags; } FormController(MuzimaApplication muzimaApplication); }
FormController { public DownloadedForms getAllDownloadedForms() throws FormFetchException { DownloadedForms downloadedFormsByTags = new DownloadedForms(); try { List<Form> allForms = formService.getAllForms(); ArrayList<String> formUuids = getFormListAsPerConfigOrder(); for (String formUuid : formUuids) { Form form = formService.getFormByUuid(formUuid); if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } for (Form form : allForms) { if (!formUuids.contains(form.getUuid())) { if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } } } catch (IOException e) { throw new FormFetchException(e); } return downloadedFormsByTags; } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public DownloadedForms getAllDownloadedForms() throws FormFetchException { DownloadedForms downloadedFormsByTags = new DownloadedForms(); try { List<Form> allForms = formService.getAllForms(); ArrayList<String> formUuids = getFormListAsPerConfigOrder(); for (String formUuid : formUuids) { Form form = formService.getFormByUuid(formUuid); if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } for (Form form : allForms) { if (!formUuids.contains(form.getUuid())) { if (formService.isFormTemplateDownloaded(form.getUuid())) { downloadedFormsByTags.add(new DownloadedFormBuilder().withDownloadedForm(form).build()); } } } } catch (IOException e) { throw new FormFetchException(e); } return downloadedFormsByTags; } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test public void isFormDownloaded_shouldReturnTrueIfFromIsDownloaded() throws IOException, FormController.FormFetchException { List<Form> forms = buildForms(); List<FormTemplate> formTemplates = buildFormTemplates(); when(formService.isFormTemplateDownloaded(anyString())).thenReturn(true); assertThat(formController.isFormDownloaded(forms.get(0)), is(true)); }
public boolean isFormDownloaded(Form form) throws FormFetchException { boolean downloaded; try { downloaded = formService.isFormTemplateDownloaded(form.getUuid()); } catch (IOException e) { throw new FormFetchException(e); } return downloaded; }
FormController { public boolean isFormDownloaded(Form form) throws FormFetchException { boolean downloaded; try { downloaded = formService.isFormTemplateDownloaded(form.getUuid()); } catch (IOException e) { throw new FormFetchException(e); } return downloaded; } }
FormController { public boolean isFormDownloaded(Form form) throws FormFetchException { boolean downloaded; try { downloaded = formService.isFormTemplateDownloaded(form.getUuid()); } catch (IOException e) { throw new FormFetchException(e); } return downloaded; } FormController(MuzimaApplication muzimaApplication); }
FormController { public boolean isFormDownloaded(Form form) throws FormFetchException { boolean downloaded; try { downloaded = formService.isFormTemplateDownloaded(form.getUuid()); } catch (IOException e) { throw new FormFetchException(e); } return downloaded; } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public boolean isFormDownloaded(Form form) throws FormFetchException { boolean downloaded; try { downloaded = formService.isFormTemplateDownloaded(form.getUuid()); } catch (IOException e) { throw new FormFetchException(e); } return downloaded; } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test public void isFormDownloaded_shouldReturnFalseIfFromIsNotDownloaded() throws IOException, FormController.FormFetchException { List<Form> forms = buildForms(); List<FormTemplate> formTemplates = buildFormTemplates(); when(formService.isFormTemplateDownloaded(anyString())).thenReturn(false); assertThat(formController.isFormDownloaded(forms.get(0)), is(false)); }
public boolean isFormDownloaded(Form form) throws FormFetchException { boolean downloaded; try { downloaded = formService.isFormTemplateDownloaded(form.getUuid()); } catch (IOException e) { throw new FormFetchException(e); } return downloaded; }
FormController { public boolean isFormDownloaded(Form form) throws FormFetchException { boolean downloaded; try { downloaded = formService.isFormTemplateDownloaded(form.getUuid()); } catch (IOException e) { throw new FormFetchException(e); } return downloaded; } }
FormController { public boolean isFormDownloaded(Form form) throws FormFetchException { boolean downloaded; try { downloaded = formService.isFormTemplateDownloaded(form.getUuid()); } catch (IOException e) { throw new FormFetchException(e); } return downloaded; } FormController(MuzimaApplication muzimaApplication); }
FormController { public boolean isFormDownloaded(Form form) throws FormFetchException { boolean downloaded; try { downloaded = formService.isFormTemplateDownloaded(form.getUuid()); } catch (IOException e) { throw new FormFetchException(e); } return downloaded; } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public boolean isFormDownloaded(Form form) throws FormFetchException { boolean downloaded; try { downloaded = formService.isFormTemplateDownloaded(form.getUuid()); } catch (IOException e) { throw new FormFetchException(e); } return downloaded; } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test public void getFormTemplateByUuid_shouldReturnForm() throws IOException, FormController.FormFetchException { List<FormTemplate> formTemplates = buildFormTemplates(); String uuid = formTemplates.get(0).getUuid(); when(formService.getFormTemplateByUuid(uuid)).thenReturn(formTemplates.get(0)); assertThat(formController.getFormTemplateByUuid(uuid), is(formTemplates.get(0))); }
public FormTemplate getFormTemplateByUuid(String formId) throws FormFetchException { try { return formService.getFormTemplateByUuid(formId); } catch (IOException e) { throw new FormFetchException(e); } }
FormController { public FormTemplate getFormTemplateByUuid(String formId) throws FormFetchException { try { return formService.getFormTemplateByUuid(formId); } catch (IOException e) { throw new FormFetchException(e); } } }
FormController { public FormTemplate getFormTemplateByUuid(String formId) throws FormFetchException { try { return formService.getFormTemplateByUuid(formId); } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); }
FormController { public FormTemplate getFormTemplateByUuid(String formId) throws FormFetchException { try { return formService.getFormTemplateByUuid(formId); } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public FormTemplate getFormTemplateByUuid(String formId) throws FormFetchException { try { return formService.getFormTemplateByUuid(formId); } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test public void getFormByUuid_shouldReturnForm() throws IOException, FormController.FormFetchException { List<Form> forms = buildForms(); String uuid = forms.get(0).getUuid(); when(formService.getFormByUuid(uuid)).thenReturn(forms.get(0)); assertThat(formController.getFormByUuid(uuid), is(forms.get(0))); }
public Form getFormByUuid(String formId) throws FormFetchException { try { return formService.getFormByUuid(formId); } catch (IOException e) { throw new FormFetchException(e); } }
FormController { public Form getFormByUuid(String formId) throws FormFetchException { try { return formService.getFormByUuid(formId); } catch (IOException e) { throw new FormFetchException(e); } } }
FormController { public Form getFormByUuid(String formId) throws FormFetchException { try { return formService.getFormByUuid(formId); } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); }
FormController { public Form getFormByUuid(String formId) throws FormFetchException { try { return formService.getFormByUuid(formId); } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public Form getFormByUuid(String formId) throws FormFetchException { try { return formService.getFormByUuid(formId); } catch (IOException e) { throw new FormFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test public void getFormDataByUuid_shouldReturnFormDataForAGivenId() throws Exception, FormController.FormDataFetchException { FormData formData = new FormData(); String uuid = "uuid"; when(formService.getFormDataByUuid(uuid)).thenReturn(formData); assertThat(formController.getFormDataByUuid(uuid), is(formData)); }
public FormData getFormDataByUuid(String formDataUuid) throws FormDataFetchException { try { return formService.getFormDataByUuid(formDataUuid); } catch (IOException e) { throw new FormDataFetchException(e); } }
FormController { public FormData getFormDataByUuid(String formDataUuid) throws FormDataFetchException { try { return formService.getFormDataByUuid(formDataUuid); } catch (IOException e) { throw new FormDataFetchException(e); } } }
FormController { public FormData getFormDataByUuid(String formDataUuid) throws FormDataFetchException { try { return formService.getFormDataByUuid(formDataUuid); } catch (IOException e) { throw new FormDataFetchException(e); } } FormController(MuzimaApplication muzimaApplication); }
FormController { public FormData getFormDataByUuid(String formDataUuid) throws FormDataFetchException { try { return formService.getFormDataByUuid(formDataUuid); } catch (IOException e) { throw new FormDataFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public FormData getFormDataByUuid(String formDataUuid) throws FormDataFetchException { try { return formService.getFormDataByUuid(formDataUuid); } catch (IOException e) { throw new FormDataFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test(expected = FormController.FormDataFetchException.class) public void getFormDataByUuid_shouldThrowFormDataFetchExceptionIfFormServiceThrowAnException() throws Exception, FormController.FormDataFetchException { String uuid = "uuid"; doThrow(new IOException()).when(formService).getFormDataByUuid(uuid); formController.getFormDataByUuid(uuid); }
public FormData getFormDataByUuid(String formDataUuid) throws FormDataFetchException { try { return formService.getFormDataByUuid(formDataUuid); } catch (IOException e) { throw new FormDataFetchException(e); } }
FormController { public FormData getFormDataByUuid(String formDataUuid) throws FormDataFetchException { try { return formService.getFormDataByUuid(formDataUuid); } catch (IOException e) { throw new FormDataFetchException(e); } } }
FormController { public FormData getFormDataByUuid(String formDataUuid) throws FormDataFetchException { try { return formService.getFormDataByUuid(formDataUuid); } catch (IOException e) { throw new FormDataFetchException(e); } } FormController(MuzimaApplication muzimaApplication); }
FormController { public FormData getFormDataByUuid(String formDataUuid) throws FormDataFetchException { try { return formService.getFormDataByUuid(formDataUuid); } catch (IOException e) { throw new FormDataFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public FormData getFormDataByUuid(String formDataUuid) throws FormDataFetchException { try { return formService.getFormDataByUuid(formDataUuid); } catch (IOException e) { throw new FormDataFetchException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test public void saveFormData_shouldSaveFormData() throws Exception, FormController.FormDataSaveException { FormData formData = new FormData(); formController.saveFormData(formData); verify(formService).saveFormData(formData); }
public void saveFormData(FormData formData) throws FormDataSaveException { try { formData.setSaveTime(new Date()); formService.saveFormData(formData); } catch (IOException e) { throw new FormDataSaveException(e); } }
FormController { public void saveFormData(FormData formData) throws FormDataSaveException { try { formData.setSaveTime(new Date()); formService.saveFormData(formData); } catch (IOException e) { throw new FormDataSaveException(e); } } }
FormController { public void saveFormData(FormData formData) throws FormDataSaveException { try { formData.setSaveTime(new Date()); formService.saveFormData(formData); } catch (IOException e) { throw new FormDataSaveException(e); } } FormController(MuzimaApplication muzimaApplication); }
FormController { public void saveFormData(FormData formData) throws FormDataSaveException { try { formData.setSaveTime(new Date()); formService.saveFormData(formData); } catch (IOException e) { throw new FormDataSaveException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public void saveFormData(FormData formData) throws FormDataSaveException { try { formData.setSaveTime(new Date()); formService.saveFormData(formData); } catch (IOException e) { throw new FormDataSaveException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test(expected = FormController.FormDataSaveException.class) public void saveFormData_shouldThrowFormDataSaveExceptionIfExceptionThrownByFormService() throws Exception, FormController.FormDataSaveException { FormData formData = new FormData(); doThrow(new IOException()).when(formService).saveFormData(formData); formController.saveFormData(formData); }
public void saveFormData(FormData formData) throws FormDataSaveException { try { formData.setSaveTime(new Date()); formService.saveFormData(formData); } catch (IOException e) { throw new FormDataSaveException(e); } }
FormController { public void saveFormData(FormData formData) throws FormDataSaveException { try { formData.setSaveTime(new Date()); formService.saveFormData(formData); } catch (IOException e) { throw new FormDataSaveException(e); } } }
FormController { public void saveFormData(FormData formData) throws FormDataSaveException { try { formData.setSaveTime(new Date()); formService.saveFormData(formData); } catch (IOException e) { throw new FormDataSaveException(e); } } FormController(MuzimaApplication muzimaApplication); }
FormController { public void saveFormData(FormData formData) throws FormDataSaveException { try { formData.setSaveTime(new Date()); formService.saveFormData(formData); } catch (IOException e) { throw new FormDataSaveException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
FormController { public void saveFormData(FormData formData) throws FormDataSaveException { try { formData.setSaveTime(new Date()); formService.saveFormData(formData); } catch (IOException e) { throw new FormDataSaveException(e); } } FormController(MuzimaApplication muzimaApplication); int getTotalFormCount(); Form getFormByUuid(String formId); FormTemplate getFormTemplateByUuid(String formId); AvailableForms getAvailableFormByTags(List<String> tagsUuid); List<Form> getAllAvailableForms(); AvailableForms getAvailableFormByTags(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); List<Tag> getAllTags(); List<Tag> getAllTagsExcludingRegistrationTag(); DownloadedForms getAllDownloadedForms(); List<Form> downloadAllForms(); List<FormTemplate> downloadFormTemplates(String[] formUuids); FormTemplate downloadFormTemplateByUuid(String uuid); void saveAllForms(List<Form> forms); void updateAllForms(List<Form> forms); void deleteAllForms(); void deleteAllFormTemplates(); void deleteForms(List<Form> forms); void deleteFormTemplatesByUUID(List<String> formTemplateUUIDs); void replaceFormTemplates(List<FormTemplate> formTemplates); void saveFormTemplates(List<FormTemplate> formTemplates); boolean isFormDownloaded(Form form); int getTagColor(String uuid); void resetTagColors(); List<Tag> getSelectedTags(); void setSelectedTags(List<Tag> selectedTags); FormData getFormDataByUuid(String formDataUuid); List<FormData> getFormDataByUuids(List<String> formDataUuids); CompleteFormWithPatientData getCompleteFormDataByUuid(String formDataUuid); void saveFormData(FormData formData); List<FormData> getAllFormData(String status); List<FormData> getAllFormDataByPatientUuid(String patientUuid, String status); IncompleteFormsWithPatientData getAllIncompleteFormsWithPatientData(); CompleteFormsWithPatientData getAllCompleteFormsWithPatientData(Context context); IncompleteForms getAllIncompleteFormsForPatientUuid(String patientUuid); CompleteForms getAllCompleteFormsForPatientUuid(String patientUuid); int countAllIncompleteForms(); int countAllCompleteForms(); int getCompleteFormsCountForPatient(String patientId); int getIncompleteFormsCountForPatient(String patientId); AvailableForms getDownloadedRegistrationForms(); Patient createNewPatient(MuzimaApplication muzimaApplication, FormData formData); boolean uploadAllCompletedForms(); AvailableForms getRecommendedForms(); AvailableForms getProviderReports(); int getRecommendedFormsCount(); void deleteCompleteAndIncompleteEncounterFormData(List<String> formDataUuids); List<FormData> getNonUploadedFormData(String templateUUID); void markFormDataAsIncompleteAndDeleteRelatedEncountersAndObs(final FormData formData); void deleteFormDataAndRelatedEncountersAndObs(List<FormData> formData); List<FormData> getArchivedFormData(); FormDataStatus downloadFormDataStatus(FormData formData); boolean isFormAlreadyExist(String jsonPayload, FormData formData); boolean isRegistrationFormDataWithEncounterForm(String formUuid); boolean isRegistrationFormData(FormData formData); boolean isGenericRegistrationHTMLFormData(FormData formData); boolean isEncounterFormData(FormData formData); Map<String, List<FormData>> getFormDataGroupedByPatient(List<String> uuids); Map<String, List<FormData>> deleteFormDataWithNoRelatedCompleteRegistrationFormDataInGroup( Map<String, List<FormData>> groupedFormData); Map<String, List<FormData>> deleteRegistrationFormDataWithAllRelatedEncountersInGroup(Map<String, List<FormData>> groupedFormData); AvailableForms getAvailableFormByTagsSortedByConfigOrder(List<String> tagsUuid, boolean alwaysIncludeRegistrationForms); AvailableForms getDownloadedRelationshipForms(); AvailableForm getAvailableFormByFormUuid(String uuid); ArrayList<String> getFormListAsPerConfigOrder(); AvailableForms getAvailableFormsPerConfigOrder(ArrayList<String> formUuids, List<Form> filteredForms); }
@Test public void authenticate_shouldAuthenticateIfNotAlreadyAuthenticated() throws Exception { String[] credentials = new String[]{"username", "password", "url"}; when(muzimaContext.isAuthenticated()).thenReturn(true); verify(muzimaContext, times(0)).authenticate(anyString(), anyString(), anyString(), anyBoolean()); assertThat(muzimaSyncService.authenticate(credentials), is(SyncStatusConstants.AUTHENTICATION_SUCCESS)); }
public int authenticate(String[] credentials) { return authenticate(credentials, false); }
MuzimaSyncService { public int authenticate(String[] credentials) { return authenticate(credentials, false); } }
MuzimaSyncService { public int authenticate(String[] credentials) { return authenticate(credentials, false); } MuzimaSyncService(MuzimaApplication muzimaContext); }
MuzimaSyncService { public int authenticate(String[] credentials) { return authenticate(credentials, false); } 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 authenticate(String[] credentials) { return authenticate(credentials, false); } 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(); }
@Test public void should_find_id_property_class() { Class<? extends Serializable> pkClass = EntityUtils.primaryKeyClass(Tee.class); Assert.assertEquals(TeeId.class, pkClass); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public static Class<? extends Serializable> primaryKeyClass(Class<?> entityClass) { if (entityClass.isAnnotationPresent(IdClass.class)) { return entityClass.getAnnotation(IdClass.class).value(); } Class clazz = PersistenceUnitDescriptorProvider.getInstance().primaryKeyIdClass(entityClass); if (clazz != null) { return clazz; } Property<Serializable> property = primaryKeyProperty(entityClass); return property.getJavaClass(); }
EntityUtils { @SuppressWarnings({ "unchecked", "rawtypes" }) public static Class<? extends Serializable> primaryKeyClass(Class<?> entityClass) { if (entityClass.isAnnotationPresent(IdClass.class)) { return entityClass.getAnnotation(IdClass.class).value(); } Class clazz = PersistenceUnitDescriptorProvider.getInstance().primaryKeyIdClass(entityClass); if (clazz != null) { return clazz; } Property<Serializable> property = primaryKeyProperty(entityClass); return property.getJavaClass(); } }
EntityUtils { @SuppressWarnings({ "unchecked", "rawtypes" }) public static Class<? extends Serializable> primaryKeyClass(Class<?> entityClass) { if (entityClass.isAnnotationPresent(IdClass.class)) { return entityClass.getAnnotation(IdClass.class).value(); } Class clazz = PersistenceUnitDescriptorProvider.getInstance().primaryKeyIdClass(entityClass); if (clazz != null) { return clazz; } Property<Serializable> property = primaryKeyProperty(entityClass); return property.getJavaClass(); } private EntityUtils(); }
EntityUtils { @SuppressWarnings({ "unchecked", "rawtypes" }) public static Class<? extends Serializable> primaryKeyClass(Class<?> entityClass) { if (entityClass.isAnnotationPresent(IdClass.class)) { return entityClass.getAnnotation(IdClass.class).value(); } Class clazz = PersistenceUnitDescriptorProvider.getInstance().primaryKeyIdClass(entityClass); if (clazz != null) { return clazz; } Property<Serializable> property = primaryKeyProperty(entityClass); return property.getJavaClass(); } private EntityUtils(); @SuppressWarnings({ "unchecked", "rawtypes" }) static Class<? extends Serializable> primaryKeyClass(Class<?> entityClass); static Object primaryKeyValue(Object entity); static Object primaryKeyValue(Object entity, Property<Serializable> primaryKeyProperty); static String entityName(Class<?> entityClass); static String tableName(Class<?> entityClass, EntityManager entityManager); static boolean isEntityClass(Class<?> entityClass); static Property<Serializable> primaryKeyProperty(Class<?> entityClass); static Property<Serializable> getVersionProperty(Class<?> entityClass); }
EntityUtils { @SuppressWarnings({ "unchecked", "rawtypes" }) public static Class<? extends Serializable> primaryKeyClass(Class<?> entityClass) { if (entityClass.isAnnotationPresent(IdClass.class)) { return entityClass.getAnnotation(IdClass.class).value(); } Class clazz = PersistenceUnitDescriptorProvider.getInstance().primaryKeyIdClass(entityClass); if (clazz != null) { return clazz; } Property<Serializable> property = primaryKeyProperty(entityClass); return property.getJavaClass(); } private EntityUtils(); @SuppressWarnings({ "unchecked", "rawtypes" }) static Class<? extends Serializable> primaryKeyClass(Class<?> entityClass); static Object primaryKeyValue(Object entity); static Object primaryKeyValue(Object entity, Property<Serializable> primaryKeyProperty); static String entityName(Class<?> entityClass); static String tableName(Class<?> entityClass, EntityManager entityManager); static boolean isEntityClass(Class<?> entityClass); static Property<Serializable> primaryKeyProperty(Class<?> entityClass); static Property<Serializable> getVersionProperty(Class<?> entityClass); }
@Test public void should_find_by_pk() throws Exception { Simple simple = testData.createSimple("testFindByPk"); Simple find = repo.findBy(simple.getId()); assertEquals(simple.getName(), find.getName()); }
@Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
@Test public void should_find__by_pk() throws Exception { Simple simple = testData.createSimple("testFindByPk"); Optional<Simple> find = repo.findOptionalBy(simple.getId()); assertEquals(simple.getName(), find.get().getName()); }
@Override public Optional<E> findOptionalBy(PK primaryKey) { E found = null; try { found = findBy(primaryKey); } catch (Exception e) { } return Optional.ofNullable(found); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Optional<E> findOptionalBy(PK primaryKey) { E found = null; try { found = findBy(primaryKey); } catch (Exception e) { } return Optional.ofNullable(found); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Optional<E> findOptionalBy(PK primaryKey) { E found = null; try { found = findBy(primaryKey); } catch (Exception e) { } return Optional.ofNullable(found); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Optional<E> findOptionalBy(PK primaryKey) { E found = null; try { found = findBy(primaryKey); } catch (Exception e) { } return Optional.ofNullable(found); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Optional<E> findOptionalBy(PK primaryKey) { E found = null; try { found = findBy(primaryKey); } catch (Exception e) { } return Optional.ofNullable(found); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
@Test @SuppressWarnings("unchecked") public void should_find_by_example() throws Exception { Simple simple = testData.createSimple("testFindByExample"); List<Simple> find = repo.findBy(simple, Simple_.name); assertNotNull(find); assertFalse(find.isEmpty()); assertEquals(simple.getName(), find.get(0).getName()); }
@Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
@Test @SuppressWarnings("unchecked") public void should_find_by_example_with_start_and_max() throws Exception { Simple simple = testData.createSimple("testFindByExample1", Integer.valueOf(10)); testData.createSimple("testFindByExample1", Integer.valueOf(10)); List<Simple> find = repo.findBy(simple, 0, 1, Simple_.name, Simple_.counter); assertNotNull(find); assertFalse(find.isEmpty()); assertEquals(1, find.size()); assertEquals(simple.getName(), find.get(0).getName()); }
@Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
@Test @SuppressWarnings("unchecked") public void should_find_by_example_with_no_attributes() throws Exception { Simple simple = testData.createSimple("testFindByExample"); SingularAttribute<Simple, ?>[] attributes = new SingularAttribute[] {}; List<Simple> find = repo.findBy(simple, attributes); assertNotNull(find); assertFalse(find.isEmpty()); assertEquals(simple.getName(), find.get(0).getName()); }
@Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public E findBy(PK primaryKey) { Query query = context.getMethod().getAnnotation(Query.class); if (query != null && query.hints().length > 0) { Map<String, Object> hints = new HashMap<String, Object>(); for (QueryHint hint : query.hints()) { hints.put(hint.name(), hint.value()); } return entityManager().find(entityClass(), primaryKey, hints); } else { return entityManager().find(entityClass(), primaryKey); } } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
@Test public void should_find_all() { testData.createSimple("testFindAll1"); testData.createSimple("testFindAll2"); List<Simple> find = repo.findAll(); assertEquals(2, find.size()); }
@SuppressWarnings("unchecked") @Override public List<E> findAll() { return context.applyRestrictions(entityManager().createQuery(allQuery(), entityClass())).getResultList(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public List<E> findAll() { return context.applyRestrictions(entityManager().createQuery(allQuery(), entityClass())).getResultList(); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public List<E> findAll() { return context.applyRestrictions(entityManager().createQuery(allQuery(), entityClass())).getResultList(); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public List<E> findAll() { return context.applyRestrictions(entityManager().createQuery(allQuery(), entityClass())).getResultList(); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public List<E> findAll() { return context.applyRestrictions(entityManager().createQuery(allQuery(), entityClass())).getResultList(); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
@Test public void should_find_by_all_with_start_and_max() { testData.createSimple("testFindAll1"); testData.createSimple("testFindAll2"); List<Simple> find = repo.findAll(0, 1); assertEquals(1, find.size()); }
@SuppressWarnings("unchecked") @Override public List<E> findAll() { return context.applyRestrictions(entityManager().createQuery(allQuery(), entityClass())).getResultList(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public List<E> findAll() { return context.applyRestrictions(entityManager().createQuery(allQuery(), entityClass())).getResultList(); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public List<E> findAll() { return context.applyRestrictions(entityManager().createQuery(allQuery(), entityClass())).getResultList(); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public List<E> findAll() { return context.applyRestrictions(entityManager().createQuery(allQuery(), entityClass())).getResultList(); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public List<E> findAll() { return context.applyRestrictions(entityManager().createQuery(allQuery(), entityClass())).getResultList(); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
@Test @SuppressWarnings({ "unchecked" }) public void should_find_by_like() { testData.createSimple("testFindAll1"); testData.createSimple("testFindAll2"); Simple example = new Simple("test"); List<Simple> find = repo.findByLike(example, Simple_.name); assertEquals(2, find.size()); }
@Override public List<E> findByLike(E example, SingularAttribute<E, ?>... attributes) { return findByLike(example, -1, -1, attributes); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public List<E> findByLike(E example, SingularAttribute<E, ?>... attributes) { return findByLike(example, -1, -1, attributes); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public List<E> findByLike(E example, SingularAttribute<E, ?>... attributes) { return findByLike(example, -1, -1, attributes); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public List<E> findByLike(E example, SingularAttribute<E, ?>... attributes) { return findByLike(example, -1, -1, attributes); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public List<E> findByLike(E example, SingularAttribute<E, ?>... attributes) { return findByLike(example, -1, -1, attributes); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
@Test @SuppressWarnings("unchecked") public void should_find_by_like_with_start_and_max() { testData.createSimple("testFindAll1"); testData.createSimple("testFindAll2"); Simple example = new Simple("test"); List<Simple> find = repo.findByLike(example, 1, 10, Simple_.name); assertEquals(1, find.size()); }
@Override public List<E> findByLike(E example, SingularAttribute<E, ?>... attributes) { return findByLike(example, -1, -1, attributes); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public List<E> findByLike(E example, SingularAttribute<E, ?>... attributes) { return findByLike(example, -1, -1, attributes); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public List<E> findByLike(E example, SingularAttribute<E, ?>... attributes) { return findByLike(example, -1, -1, attributes); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public List<E> findByLike(E example, SingularAttribute<E, ?>... attributes) { return findByLike(example, -1, -1, attributes); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public List<E> findByLike(E example, SingularAttribute<E, ?>... attributes) { return findByLike(example, -1, -1, attributes); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
@Test @SuppressWarnings("unchecked") public void should_find_by_like_non_string() { testData.createSimple("testFindAll1", 1); testData.createSimple("testFindAll2", 2); Simple example = new Simple("test"); example.setCounter(1); List<Simple> find = repo.findByLike(example, Simple_.name, Simple_.counter); assertEquals(1, find.size()); }
@Override public List<E> findByLike(E example, SingularAttribute<E, ?>... attributes) { return findByLike(example, -1, -1, attributes); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public List<E> findByLike(E example, SingularAttribute<E, ?>... attributes) { return findByLike(example, -1, -1, attributes); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public List<E> findByLike(E example, SingularAttribute<E, ?>... attributes) { return findByLike(example, -1, -1, attributes); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public List<E> findByLike(E example, SingularAttribute<E, ?>... attributes) { return findByLike(example, -1, -1, attributes); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public List<E> findByLike(E example, SingularAttribute<E, ?>... attributes) { return findByLike(example, -1, -1, attributes); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
@Test public void should_find_id_class() { Class<? extends Serializable> pkClass = EntityUtils.primaryKeyClass(Tee2.class); Assert.assertEquals(TeeId.class, pkClass); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public static Class<? extends Serializable> primaryKeyClass(Class<?> entityClass) { if (entityClass.isAnnotationPresent(IdClass.class)) { return entityClass.getAnnotation(IdClass.class).value(); } Class clazz = PersistenceUnitDescriptorProvider.getInstance().primaryKeyIdClass(entityClass); if (clazz != null) { return clazz; } Property<Serializable> property = primaryKeyProperty(entityClass); return property.getJavaClass(); }
EntityUtils { @SuppressWarnings({ "unchecked", "rawtypes" }) public static Class<? extends Serializable> primaryKeyClass(Class<?> entityClass) { if (entityClass.isAnnotationPresent(IdClass.class)) { return entityClass.getAnnotation(IdClass.class).value(); } Class clazz = PersistenceUnitDescriptorProvider.getInstance().primaryKeyIdClass(entityClass); if (clazz != null) { return clazz; } Property<Serializable> property = primaryKeyProperty(entityClass); return property.getJavaClass(); } }
EntityUtils { @SuppressWarnings({ "unchecked", "rawtypes" }) public static Class<? extends Serializable> primaryKeyClass(Class<?> entityClass) { if (entityClass.isAnnotationPresent(IdClass.class)) { return entityClass.getAnnotation(IdClass.class).value(); } Class clazz = PersistenceUnitDescriptorProvider.getInstance().primaryKeyIdClass(entityClass); if (clazz != null) { return clazz; } Property<Serializable> property = primaryKeyProperty(entityClass); return property.getJavaClass(); } private EntityUtils(); }
EntityUtils { @SuppressWarnings({ "unchecked", "rawtypes" }) public static Class<? extends Serializable> primaryKeyClass(Class<?> entityClass) { if (entityClass.isAnnotationPresent(IdClass.class)) { return entityClass.getAnnotation(IdClass.class).value(); } Class clazz = PersistenceUnitDescriptorProvider.getInstance().primaryKeyIdClass(entityClass); if (clazz != null) { return clazz; } Property<Serializable> property = primaryKeyProperty(entityClass); return property.getJavaClass(); } private EntityUtils(); @SuppressWarnings({ "unchecked", "rawtypes" }) static Class<? extends Serializable> primaryKeyClass(Class<?> entityClass); static Object primaryKeyValue(Object entity); static Object primaryKeyValue(Object entity, Property<Serializable> primaryKeyProperty); static String entityName(Class<?> entityClass); static String tableName(Class<?> entityClass, EntityManager entityManager); static boolean isEntityClass(Class<?> entityClass); static Property<Serializable> primaryKeyProperty(Class<?> entityClass); static Property<Serializable> getVersionProperty(Class<?> entityClass); }
EntityUtils { @SuppressWarnings({ "unchecked", "rawtypes" }) public static Class<? extends Serializable> primaryKeyClass(Class<?> entityClass) { if (entityClass.isAnnotationPresent(IdClass.class)) { return entityClass.getAnnotation(IdClass.class).value(); } Class clazz = PersistenceUnitDescriptorProvider.getInstance().primaryKeyIdClass(entityClass); if (clazz != null) { return clazz; } Property<Serializable> property = primaryKeyProperty(entityClass); return property.getJavaClass(); } private EntityUtils(); @SuppressWarnings({ "unchecked", "rawtypes" }) static Class<? extends Serializable> primaryKeyClass(Class<?> entityClass); static Object primaryKeyValue(Object entity); static Object primaryKeyValue(Object entity, Property<Serializable> primaryKeyProperty); static String entityName(Class<?> entityClass); static String tableName(Class<?> entityClass, EntityManager entityManager); static boolean isEntityClass(Class<?> entityClass); static Property<Serializable> primaryKeyProperty(Class<?> entityClass); static Property<Serializable> getVersionProperty(Class<?> entityClass); }
@Test public void should_count_all() { testData.createSimple("testCountAll"); Long result = repo.count(); assertEquals(Long.valueOf(1), result); }
@Override public Long count() { return (Long) context.applyRestrictions(entityManager().createQuery(countQuery(), Long.class)) .getSingleResult(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Long count() { return (Long) context.applyRestrictions(entityManager().createQuery(countQuery(), Long.class)) .getSingleResult(); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Long count() { return (Long) context.applyRestrictions(entityManager().createQuery(countQuery(), Long.class)) .getSingleResult(); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Long count() { return (Long) context.applyRestrictions(entityManager().createQuery(countQuery(), Long.class)) .getSingleResult(); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Long count() { return (Long) context.applyRestrictions(entityManager().createQuery(countQuery(), Long.class)) .getSingleResult(); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
@Test @SuppressWarnings("unchecked") public void should_count_with_attributes() { Simple simple = testData.createSimple("testFindAll1", Integer.valueOf(55)); testData.createSimple("testFindAll2", Integer.valueOf(55)); Long result = repo.count(simple, Simple_.name, Simple_.counter); assertEquals(Long.valueOf(1), result); }
@Override public Long count() { return (Long) context.applyRestrictions(entityManager().createQuery(countQuery(), Long.class)) .getSingleResult(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Long count() { return (Long) context.applyRestrictions(entityManager().createQuery(countQuery(), Long.class)) .getSingleResult(); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Long count() { return (Long) context.applyRestrictions(entityManager().createQuery(countQuery(), Long.class)) .getSingleResult(); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Long count() { return (Long) context.applyRestrictions(entityManager().createQuery(countQuery(), Long.class)) .getSingleResult(); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Long count() { return (Long) context.applyRestrictions(entityManager().createQuery(countQuery(), Long.class)) .getSingleResult(); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
@Test @SuppressWarnings("unchecked") public void should_count_with_no_attributes() { Simple simple = testData.createSimple("testFindAll1"); testData.createSimple("testFindAll2"); SingularAttribute<Simple, Object>[] attributes = new SingularAttribute[] {}; Long result = repo.count(simple, attributes); assertEquals(Long.valueOf(2), result); }
@Override public Long count() { return (Long) context.applyRestrictions(entityManager().createQuery(countQuery(), Long.class)) .getSingleResult(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Long count() { return (Long) context.applyRestrictions(entityManager().createQuery(countQuery(), Long.class)) .getSingleResult(); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Long count() { return (Long) context.applyRestrictions(entityManager().createQuery(countQuery(), Long.class)) .getSingleResult(); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Long count() { return (Long) context.applyRestrictions(entityManager().createQuery(countQuery(), Long.class)) .getSingleResult(); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Long count() { return (Long) context.applyRestrictions(entityManager().createQuery(countQuery(), Long.class)) .getSingleResult(); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
@Test @SuppressWarnings("unchecked") public void should_count_by_like() { testData.createSimple("testFindAll1"); testData.createSimple("testFindAll2"); Simple example = new Simple("test"); Long count = repo.countLike(example, Simple_.name); assertEquals(Long.valueOf(2), count); }
@Override public Long countLike(E example, SingularAttribute<E, ?>... attributes) { return executeCountQuery(example, true, attributes); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Long countLike(E example, SingularAttribute<E, ?>... attributes) { return executeCountQuery(example, true, attributes); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Long countLike(E example, SingularAttribute<E, ?>... attributes) { return executeCountQuery(example, true, attributes); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Long countLike(E example, SingularAttribute<E, ?>... attributes) { return executeCountQuery(example, true, attributes); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Long countLike(E example, SingularAttribute<E, ?>... attributes) { return executeCountQuery(example, true, attributes); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
@Test public void should_remove_and_flush() { Simple simple = testData.createSimple("testRemoveAndFlush"); repo.removeAndFlush(simple); Simple lookup = getEntityManager().find(Simple.class, simple.getId()); assertNull(lookup); }
@Override @RequiresTransaction public void removeAndFlush(E entity) { entityManager().remove(entity); flush(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override @RequiresTransaction public void removeAndFlush(E entity) { entityManager().remove(entity); flush(); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override @RequiresTransaction public void removeAndFlush(E entity) { entityManager().remove(entity); flush(); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override @RequiresTransaction public void removeAndFlush(E entity) { entityManager().remove(entity); flush(); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override @RequiresTransaction public void removeAndFlush(E entity) { entityManager().remove(entity); flush(); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
@Test public void should_return_entity_primary_key() { Simple simple = testData.createSimple("should_return_entity_primary_key"); Long id = simple.getId(); Long primaryKey = repo.getPrimaryKey(simple); assertNotNull(primaryKey); assertEquals(id, primaryKey); }
@SuppressWarnings("unchecked") @Override public PK getPrimaryKey(E entity) { return (PK) persistenceUnitUtil().getIdentifier(entity); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public PK getPrimaryKey(E entity) { return (PK) persistenceUnitUtil().getIdentifier(entity); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public PK getPrimaryKey(E entity) { return (PK) persistenceUnitUtil().getIdentifier(entity); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public PK getPrimaryKey(E entity) { return (PK) persistenceUnitUtil().getIdentifier(entity); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public PK getPrimaryKey(E entity) { return (PK) persistenceUnitUtil().getIdentifier(entity); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
@Test public void should_return_null_primary_key() { Simple simple = new Simple("should_return_null_primary_key"); Long primaryKey = repo.getPrimaryKey(simple); assertNull(primaryKey); }
@SuppressWarnings("unchecked") @Override public PK getPrimaryKey(E entity) { return (PK) persistenceUnitUtil().getIdentifier(entity); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public PK getPrimaryKey(E entity) { return (PK) persistenceUnitUtil().getIdentifier(entity); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public PK getPrimaryKey(E entity) { return (PK) persistenceUnitUtil().getIdentifier(entity); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public PK getPrimaryKey(E entity) { return (PK) persistenceUnitUtil().getIdentifier(entity); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public PK getPrimaryKey(E entity) { return (PK) persistenceUnitUtil().getIdentifier(entity); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
@Test public void should_return_entity_primary_key_detached_entity() { Simple simple = testData.createSimple("should_return_entity_primary_key"); Long id = simple.getId(); getEntityManager().detach(simple); Long primaryKey = repo.getPrimaryKey(simple); assertNotNull(primaryKey); assertEquals(id, primaryKey); }
@SuppressWarnings("unchecked") @Override public PK getPrimaryKey(E entity) { return (PK) persistenceUnitUtil().getIdentifier(entity); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public PK getPrimaryKey(E entity) { return (PK) persistenceUnitUtil().getIdentifier(entity); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public PK getPrimaryKey(E entity) { return (PK) persistenceUnitUtil().getIdentifier(entity); } }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public PK getPrimaryKey(E entity) { return (PK) persistenceUnitUtil().getIdentifier(entity); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public PK getPrimaryKey(E entity) { return (PK) persistenceUnitUtil().getIdentifier(entity); } @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName(); }
@Test public void should_set_creation_date() throws Exception { AuditedEntity entity = new AuditedEntity(); getEntityManager().persist(entity); getEntityManager().flush(); assertNotNull(entity.getCreated()); assertNotNull(entity.getModified()); assertEquals(entity.getCreated().getTime(), entity.getModified()); }
@PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } } }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } } }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } } @PrePersist void persist(Object entity); @PreUpdate void update(Object entity); }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } } @PrePersist void persist(Object entity); @PreUpdate void update(Object entity); }
@Test public void should_set_modification_date() throws Exception { AuditedEntity entity = new AuditedEntity(); getEntityManager().persist(entity); getEntityManager().flush(); entity = getEntityManager().find(AuditedEntity.class, entity.getId()); entity.setName("test"); getEntityManager().flush(); assertNotNull(entity.getGregorianModified()); assertNotNull(entity.getTimestamp()); }
@PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } } }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } } }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } } @PrePersist void persist(Object entity); @PreUpdate void update(Object entity); }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } } @PrePersist void persist(Object entity); @PreUpdate void update(Object entity); }
@Test public void should_accept_entity_class() { boolean isValid = EntityUtils.isEntityClass(Simple.class); Assert.assertTrue(isValid); }
public static boolean isEntityClass(Class<?> entityClass) { return entityClass.isAnnotationPresent(Entity.class) || PersistenceUnitDescriptorProvider.getInstance().isEntity(entityClass); }
EntityUtils { public static boolean isEntityClass(Class<?> entityClass) { return entityClass.isAnnotationPresent(Entity.class) || PersistenceUnitDescriptorProvider.getInstance().isEntity(entityClass); } }
EntityUtils { public static boolean isEntityClass(Class<?> entityClass) { return entityClass.isAnnotationPresent(Entity.class) || PersistenceUnitDescriptorProvider.getInstance().isEntity(entityClass); } private EntityUtils(); }
EntityUtils { public static boolean isEntityClass(Class<?> entityClass) { return entityClass.isAnnotationPresent(Entity.class) || PersistenceUnitDescriptorProvider.getInstance().isEntity(entityClass); } private EntityUtils(); @SuppressWarnings({ "unchecked", "rawtypes" }) static Class<? extends Serializable> primaryKeyClass(Class<?> entityClass); static Object primaryKeyValue(Object entity); static Object primaryKeyValue(Object entity, Property<Serializable> primaryKeyProperty); static String entityName(Class<?> entityClass); static String tableName(Class<?> entityClass, EntityManager entityManager); static boolean isEntityClass(Class<?> entityClass); static Property<Serializable> primaryKeyProperty(Class<?> entityClass); static Property<Serializable> getVersionProperty(Class<?> entityClass); }
EntityUtils { public static boolean isEntityClass(Class<?> entityClass) { return entityClass.isAnnotationPresent(Entity.class) || PersistenceUnitDescriptorProvider.getInstance().isEntity(entityClass); } private EntityUtils(); @SuppressWarnings({ "unchecked", "rawtypes" }) static Class<? extends Serializable> primaryKeyClass(Class<?> entityClass); static Object primaryKeyValue(Object entity); static Object primaryKeyValue(Object entity, Property<Serializable> primaryKeyProperty); static String entityName(Class<?> entityClass); static String tableName(Class<?> entityClass, EntityManager entityManager); static boolean isEntityClass(Class<?> entityClass); static Property<Serializable> primaryKeyProperty(Class<?> entityClass); static Property<Serializable> getVersionProperty(Class<?> entityClass); }
@Test public void should_set_changing_principal() { AuditedEntity entity = new AuditedEntity(); getEntityManager().persist(entity); getEntityManager().flush(); entity = getEntityManager().find(AuditedEntity.class, entity.getId()); entity.setName("test"); getEntityManager().flush(); assertNotNull(entity.getChanger()); assertEquals(who, entity.getChanger()); assertNotNull(entity.getPrincipal()); assertEquals(who, entity.getPrincipal().getName()); assertNotNull(entity.getChangerOnly()); assertEquals(who, entity.getChangerOnly()); assertNotNull(entity.getChangerOnlyPrincipal()); assertEquals(who, entity.getChangerOnlyPrincipal().getName()); }
@PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } } }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } } }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } } @PrePersist void persist(Object entity); @PreUpdate void update(Object entity); }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } } @PrePersist void persist(Object entity); @PreUpdate void update(Object entity); }
@Test public void should_set_creating_principal() { AuditedEntity entity = new AuditedEntity(); getEntityManager().persist(entity); getEntityManager().flush(); assertNotNull(entity.getCreator()); assertEquals(who, entity.getCreator()); assertNotNull(entity.getCreatorPrincipal()); assertEquals(who, entity.getCreatorPrincipal().getName()); assertNotNull(entity.getChanger()); assertEquals(who, entity.getChanger()); assertNotNull(entity.getPrincipal()); assertEquals(who, entity.getPrincipal().getName()); assertNull(entity.getChangerOnly()); assertNull(entity.getChangerOnlyPrincipal()); }
@PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } } }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } } }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } } @PrePersist void persist(Object entity); @PreUpdate void update(Object entity); }
AuditEntityListener { @PrePersist public void persist(Object entity) { BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager(); Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class); for (Bean<?> bean : beans) { PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference( bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean)); result.prePersist(entity); } } @PrePersist void persist(Object entity); @PreUpdate void update(Object entity); }
@Test public void should_set_users_for_creation() { String creator = "creator"; MockPrincipalProvider provider = new MockPrincipalProvider(creator); AuditedEntity entity = new AuditedEntity(); provider.prePersist(entity); assertNotNull(entity.getCreator()); assertNotNull(entity.getCreatorPrincipal()); assertNotNull(entity.getChanger()); assertEquals(entity.getCreator(), creator); assertEquals(entity.getCreatorPrincipal().getName(), creator); assertEquals(entity.getChanger(), creator); assertNull(entity.getChangerOnly()); assertNull(entity.getChangerOnlyPrincipal()); }
@Override public void prePersist(Object entity) { updatePrincipal(entity, true); }
PrincipalProvider extends AuditProvider { @Override public void prePersist(Object entity) { updatePrincipal(entity, true); } }
PrincipalProvider extends AuditProvider { @Override public void prePersist(Object entity) { updatePrincipal(entity, true); } }
PrincipalProvider extends AuditProvider { @Override public void prePersist(Object entity) { updatePrincipal(entity, true); } @Override void prePersist(Object entity); @Override void preUpdate(Object entity); }
PrincipalProvider extends AuditProvider { @Override public void prePersist(Object entity) { updatePrincipal(entity, true); } @Override void prePersist(Object entity); @Override void preUpdate(Object entity); }
@Test public void should_set_users_for_update() { String changer = "changer"; MockPrincipalProvider provider = new MockPrincipalProvider(changer); AuditedEntity entity = new AuditedEntity(); provider.preUpdate(entity); assertNotNull(entity.getChanger()); assertNotNull(entity.getChangerOnly()); assertNotNull(entity.getChangerOnlyPrincipal()); assertEquals(entity.getChanger(), changer); assertEquals(entity.getChangerOnly(), changer); assertEquals(entity.getChangerOnlyPrincipal().getName(), changer); assertNull(entity.getCreator()); assertNull(entity.getCreatorPrincipal()); }
@Override public void preUpdate(Object entity) { updatePrincipal(entity, false); }
PrincipalProvider extends AuditProvider { @Override public void preUpdate(Object entity) { updatePrincipal(entity, false); } }
PrincipalProvider extends AuditProvider { @Override public void preUpdate(Object entity) { updatePrincipal(entity, false); } }
PrincipalProvider extends AuditProvider { @Override public void preUpdate(Object entity) { updatePrincipal(entity, false); } @Override void prePersist(Object entity); @Override void preUpdate(Object entity); }
PrincipalProvider extends AuditProvider { @Override public void preUpdate(Object entity) { updatePrincipal(entity, false); } @Override void prePersist(Object entity); @Override void preUpdate(Object entity); }
@Test(expected = AuditPropertyException.class) public void should_fail_on_invalid_entity() { PrincipalProviderTest.InvalidEntity entity = new PrincipalProviderTest.InvalidEntity(); new MockPrincipalProvider("").prePersist(entity); fail(); }
@Override public void prePersist(Object entity) { updatePrincipal(entity, true); }
PrincipalProvider extends AuditProvider { @Override public void prePersist(Object entity) { updatePrincipal(entity, true); } }
PrincipalProvider extends AuditProvider { @Override public void prePersist(Object entity) { updatePrincipal(entity, true); } }
PrincipalProvider extends AuditProvider { @Override public void prePersist(Object entity) { updatePrincipal(entity, true); } @Override void prePersist(Object entity); @Override void preUpdate(Object entity); }
PrincipalProvider extends AuditProvider { @Override public void prePersist(Object entity) { updatePrincipal(entity, true); } @Override void prePersist(Object entity); @Override void preUpdate(Object entity); }
@Test public void should_set_dates_for_creation() { AuditedEntity entity = new AuditedEntity(); new TimestampsProvider().prePersist(entity); assertNotNull(entity.getCreated()); assertNotNull(entity.getModified()); assertNull(entity.getGregorianModified()); assertNull(entity.getTimestamp()); }
@Override public void prePersist(Object entity) { updateTimestamps(entity, true); }
TimestampsProvider extends AuditProvider { @Override public void prePersist(Object entity) { updateTimestamps(entity, true); } }
TimestampsProvider extends AuditProvider { @Override public void prePersist(Object entity) { updateTimestamps(entity, true); } }
TimestampsProvider extends AuditProvider { @Override public void prePersist(Object entity) { updateTimestamps(entity, true); } @Override void prePersist(Object entity); @Override void preUpdate(Object entity); }
TimestampsProvider extends AuditProvider { @Override public void prePersist(Object entity) { updateTimestamps(entity, true); } @Override void prePersist(Object entity); @Override void preUpdate(Object entity); }
@Test public void should_set_dates_for_update() { AuditedEntity entity = new AuditedEntity(); new TimestampsProvider().preUpdate(entity); assertNull(entity.getCreated()); assertNotNull(entity.getModified()); assertNotNull(entity.getGregorianModified()); assertNotNull(entity.getTimestamp()); }
@Override public void preUpdate(Object entity) { updateTimestamps(entity, false); }
TimestampsProvider extends AuditProvider { @Override public void preUpdate(Object entity) { updateTimestamps(entity, false); } }
TimestampsProvider extends AuditProvider { @Override public void preUpdate(Object entity) { updateTimestamps(entity, false); } }
TimestampsProvider extends AuditProvider { @Override public void preUpdate(Object entity) { updateTimestamps(entity, false); } @Override void prePersist(Object entity); @Override void preUpdate(Object entity); }
TimestampsProvider extends AuditProvider { @Override public void preUpdate(Object entity) { updateTimestamps(entity, false); } @Override void prePersist(Object entity); @Override void preUpdate(Object entity); }