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 testIsUserInValidGroupShouldReturnFalseOnError() throws Exception { Whitebox.setInternalState(userService, "keyStore", keyStore); Whitebox.setInternalState(keyStore, "initialized", true); Whitebox.setInternalState(keyStore, "keyStoreSpi", keyStoreSpi); String user = "johndoe"; when(keyStore.containsAl... | public boolean isUserInValidGroup(final String userName, final char[] password) { if (keyStore != null && userName != null && password != null && !allSharedPreferences.fetchForceRemoteLogin(userName)) { byte[] storedHash = null; byte[] passwordHash = null; try { storedHash = getLocalAuthenticationCredentials(userName);... | UserService { public boolean isUserInValidGroup(final String userName, final char[] password) { if (keyStore != null && userName != null && password != null && !allSharedPreferences.fetchForceRemoteLogin(userName)) { byte[] storedHash = null; byte[] passwordHash = null; try { storedHash = getLocalAuthenticationCredenti... | UserService { public boolean isUserInValidGroup(final String userName, final char[] password) { if (keyStore != null && userName != null && password != null && !allSharedPreferences.fetchForceRemoteLogin(userName)) { byte[] storedHash = null; byte[] passwordHash = null; try { storedHash = getLocalAuthenticationCredenti... | UserService { public boolean isUserInValidGroup(final String userName, final char[] password) { if (keyStore != null && userName != null && password != null && !allSharedPreferences.fetchForceRemoteLogin(userName)) { byte[] storedHash = null; byte[] passwordHash = null; try { storedHash = getLocalAuthenticationCredenti... | UserService { public boolean isUserInValidGroup(final String userName, final char[] password) { if (keyStore != null && userName != null && password != null && !allSharedPreferences.fetchForceRemoteLogin(userName)) { byte[] storedHash = null; byte[] passwordHash = null; try { storedHash = getLocalAuthenticationCredenti... |
@Test public void testIsUserInPioneerGroupShouldReturnTrueForPioneerUser() throws Exception { userService = spy(userService); Whitebox.setInternalState(userService, "keyStore", keyStore); Whitebox.setInternalState(keyStore, "initialized", true); Whitebox.setInternalState(keyStore, "keyStoreSpi", keyStoreSpi); String us... | public boolean isUserInPioneerGroup(String userName) { String pioneerUser = allSharedPreferences.fetchPioneerUser(); if (userName.equals(pioneerUser)) { return true; } else { byte[] currentUserSecretKey = getDecryptedPassphraseValue(userName); byte[] pioneerUserSecretKey = getDecryptedPassphraseValue(pioneerUser); if (... | UserService { public boolean isUserInPioneerGroup(String userName) { String pioneerUser = allSharedPreferences.fetchPioneerUser(); if (userName.equals(pioneerUser)) { return true; } else { byte[] currentUserSecretKey = getDecryptedPassphraseValue(userName); byte[] pioneerUserSecretKey = getDecryptedPassphraseValue(pion... | UserService { public boolean isUserInPioneerGroup(String userName) { String pioneerUser = allSharedPreferences.fetchPioneerUser(); if (userName.equals(pioneerUser)) { return true; } else { byte[] currentUserSecretKey = getDecryptedPassphraseValue(userName); byte[] pioneerUserSecretKey = getDecryptedPassphraseValue(pion... | UserService { public boolean isUserInPioneerGroup(String userName) { String pioneerUser = allSharedPreferences.fetchPioneerUser(); if (userName.equals(pioneerUser)) { return true; } else { byte[] currentUserSecretKey = getDecryptedPassphraseValue(userName); byte[] pioneerUserSecretKey = getDecryptedPassphraseValue(pion... | UserService { public boolean isUserInPioneerGroup(String userName) { String pioneerUser = allSharedPreferences.fetchPioneerUser(); if (userName.equals(pioneerUser)) { return true; } else { byte[] currentUserSecretKey = getDecryptedPassphraseValue(userName); byte[] pioneerUserSecretKey = getDecryptedPassphraseValue(pion... |
@Test public void testIsUserInPioneerGroupShouldReturnFalseForOthers() throws Exception { when(allSharedPreferences.fetchPioneerUser()).thenReturn("user"); assertFalse(userService.isUserInPioneerGroup("john")); } | public boolean isUserInPioneerGroup(String userName) { String pioneerUser = allSharedPreferences.fetchPioneerUser(); if (userName.equals(pioneerUser)) { return true; } else { byte[] currentUserSecretKey = getDecryptedPassphraseValue(userName); byte[] pioneerUserSecretKey = getDecryptedPassphraseValue(pioneerUser); if (... | UserService { public boolean isUserInPioneerGroup(String userName) { String pioneerUser = allSharedPreferences.fetchPioneerUser(); if (userName.equals(pioneerUser)) { return true; } else { byte[] currentUserSecretKey = getDecryptedPassphraseValue(userName); byte[] pioneerUserSecretKey = getDecryptedPassphraseValue(pion... | UserService { public boolean isUserInPioneerGroup(String userName) { String pioneerUser = allSharedPreferences.fetchPioneerUser(); if (userName.equals(pioneerUser)) { return true; } else { byte[] currentUserSecretKey = getDecryptedPassphraseValue(userName); byte[] pioneerUserSecretKey = getDecryptedPassphraseValue(pion... | UserService { public boolean isUserInPioneerGroup(String userName) { String pioneerUser = allSharedPreferences.fetchPioneerUser(); if (userName.equals(pioneerUser)) { return true; } else { byte[] currentUserSecretKey = getDecryptedPassphraseValue(userName); byte[] pioneerUserSecretKey = getDecryptedPassphraseValue(pion... | UserService { public boolean isUserInPioneerGroup(String userName) { String pioneerUser = allSharedPreferences.fetchPioneerUser(); if (userName.equals(pioneerUser)) { return true; } else { byte[] currentUserSecretKey = getDecryptedPassphraseValue(userName); byte[] pioneerUserSecretKey = getDecryptedPassphraseValue(pion... |
@Test public void testSaveEventAndClientsWithNullEC() { recreateECUtil.saveEventAndClients(null, database); verifyZeroInteractions(database); } | public void saveEventAndClients(Pair<List<Event>, List<Client>> eventClients, SQLiteDatabase sqLiteDatabase) { if (eventClients == null) { return; } if (eventClients.first != null) { JSONArray events; try { events = new JSONArray(gson.toJson(eventClients.first)); Timber.d("saving %d events, %s ", eventClients.first.siz... | RecreateECUtil { public void saveEventAndClients(Pair<List<Event>, List<Client>> eventClients, SQLiteDatabase sqLiteDatabase) { if (eventClients == null) { return; } if (eventClients.first != null) { JSONArray events; try { events = new JSONArray(gson.toJson(eventClients.first)); Timber.d("saving %d events, %s ", event... | RecreateECUtil { public void saveEventAndClients(Pair<List<Event>, List<Client>> eventClients, SQLiteDatabase sqLiteDatabase) { if (eventClients == null) { return; } if (eventClients.first != null) { JSONArray events; try { events = new JSONArray(gson.toJson(eventClients.first)); Timber.d("saving %d events, %s ", event... | RecreateECUtil { public void saveEventAndClients(Pair<List<Event>, List<Client>> eventClients, SQLiteDatabase sqLiteDatabase) { if (eventClients == null) { return; } if (eventClients.first != null) { JSONArray events; try { events = new JSONArray(gson.toJson(eventClients.first)); Timber.d("saving %d events, %s ", event... | RecreateECUtil { public void saveEventAndClients(Pair<List<Event>, List<Client>> eventClients, SQLiteDatabase sqLiteDatabase) { if (eventClients == null) { return; } if (eventClients.first != null) { JSONArray events; try { events = new JSONArray(gson.toJson(eventClients.first)); Timber.d("saving %d events, %s ", event... |
@Test public void shouldUpdateEveryOnlyNewlyBornChildrenWhileRegistering() throws Exception { Child firstChild = new Child("Child X", "Mother X", "female", EasyMap.create("weight", "3").put("immunizationsGiven", "bcg opv_0").map()); Child secondChild = new Child("Child Y", "Mother X", "female", EasyMap.create("weight",... | public void register(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.DeliveryOutcomeFields.CHILD_REGISTRATION_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.DeliveryOutcomeFields.REFERENCE_DATE... | ChildService { public void register(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.DeliveryOutcomeFields.CHILD_REGISTRATION_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.DeliveryOutcomeFields... | ChildService { public void register(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.DeliveryOutcomeFields.CHILD_REGISTRATION_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.DeliveryOutcomeFields... | ChildService { public void register(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.DeliveryOutcomeFields.CHILD_REGISTRATION_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.DeliveryOutcomeFields... | ChildService { public void register(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.DeliveryOutcomeFields.CHILD_REGISTRATION_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.DeliveryOutcomeFields... |
@Test public void shouldDeleteRegisteredChildWhenDeliveryOutcomeIsStillBirth() throws Exception { FormSubmission submission = Mockito.mock(FormSubmission.class); SubForm subForm = Mockito.mock(SubForm.class); Mockito.when(submission.entityId()).thenReturn("Mother X"); Mockito.when(submission.getFieldValue("referenceDat... | public void register(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.DeliveryOutcomeFields.CHILD_REGISTRATION_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.DeliveryOutcomeFields.REFERENCE_DATE... | ChildService { public void register(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.DeliveryOutcomeFields.CHILD_REGISTRATION_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.DeliveryOutcomeFields... | ChildService { public void register(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.DeliveryOutcomeFields.CHILD_REGISTRATION_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.DeliveryOutcomeFields... | ChildService { public void register(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.DeliveryOutcomeFields.CHILD_REGISTRATION_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.DeliveryOutcomeFields... | ChildService { public void register(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.DeliveryOutcomeFields.CHILD_REGISTRATION_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.DeliveryOutcomeFields... |
@Test public void shouldUpdateNewlyRegisteredChildrenDuringPNCRegistrationOA() throws Exception { Child firstChild = new Child("Child X", "Mother X", "female", EasyMap.create("weight", "3").put("immunizationsGiven", "bcg opv_0").map()); Child secondChild = new Child("Child Y", "Mother X", "female", EasyMap.create("weig... | public void pncRegistrationOA(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.PNCRegistrationOAFields.CHILD_REGISTRATION_OA_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.DeliveryOutcomeFields.... | ChildService { public void pncRegistrationOA(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.PNCRegistrationOAFields.CHILD_REGISTRATION_OA_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.Deliver... | ChildService { public void pncRegistrationOA(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.PNCRegistrationOAFields.CHILD_REGISTRATION_OA_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.Deliver... | ChildService { public void pncRegistrationOA(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.PNCRegistrationOAFields.CHILD_REGISTRATION_OA_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.Deliver... | ChildService { public void pncRegistrationOA(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.PNCRegistrationOAFields.CHILD_REGISTRATION_OA_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.Deliver... |
@Test public void shouldDeleteRegisteredChildWhenPNCRegistrationOAIsHandledAndDeliveryOutcomeIsStillBirth() throws Exception { FormSubmission submission = Mockito.mock(FormSubmission.class); SubForm subForm = Mockito.mock(SubForm.class); Mockito.when(submission.entityId()).thenReturn("Mother X"); Mockito.when(submissio... | public void pncRegistrationOA(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.PNCRegistrationOAFields.CHILD_REGISTRATION_OA_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.DeliveryOutcomeFields.... | ChildService { public void pncRegistrationOA(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.PNCRegistrationOAFields.CHILD_REGISTRATION_OA_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.Deliver... | ChildService { public void pncRegistrationOA(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.PNCRegistrationOAFields.CHILD_REGISTRATION_OA_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.Deliver... | ChildService { public void pncRegistrationOA(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.PNCRegistrationOAFields.CHILD_REGISTRATION_OA_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.Deliver... | ChildService { public void pncRegistrationOA(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.PNCRegistrationOAFields.CHILD_REGISTRATION_OA_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.Deliver... |
@Test public void shouldCheckForEmptyInstanceInTheCaseOfStillBirth() throws Exception { FormSubmission submission = Mockito.mock(FormSubmission.class); SubForm subForm = Mockito.mock(SubForm.class); Mockito.when(submission.entityId()).thenReturn("Mother X"); Mockito.when(submission.getFieldValue("referenceDate")).thenR... | public void pncRegistrationOA(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.PNCRegistrationOAFields.CHILD_REGISTRATION_OA_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.DeliveryOutcomeFields.... | ChildService { public void pncRegistrationOA(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.PNCRegistrationOAFields.CHILD_REGISTRATION_OA_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.Deliver... | ChildService { public void pncRegistrationOA(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.PNCRegistrationOAFields.CHILD_REGISTRATION_OA_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.Deliver... | ChildService { public void pncRegistrationOA(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.PNCRegistrationOAFields.CHILD_REGISTRATION_OA_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.Deliver... | ChildService { public void pncRegistrationOA(FormSubmission submission) { SubForm subForm = submission.getSubFormByName( AllConstants.PNCRegistrationOAFields.CHILD_REGISTRATION_OA_SUB_FORM_NAME); if (handleStillBirth(submission, subForm)) { return; } String referenceDate = submission .getFieldValue(AllConstants.Deliver... |
@Test public void shouldAddTimelineEventsWhenChildImmunizationsAreUpdated() throws Exception { FormSubmission submission = Mockito.mock(FormSubmission.class); Mockito.when(submission.entityId()).thenReturn("child id 1"); Mockito.when(submission.getFieldValue("previousImmunizations")).thenReturn("bcg"); Mockito.when(sub... | public void updateImmunizations(FormSubmission submission) { String immunizationDate = submission .getFieldValue(AllConstants.ChildImmunizationsFields.IMMUNIZATION_DATE); List<String> immunizationsGivenList = splitFieldValueBySpace(submission, AllConstants.ChildImmunizationsFields.IMMUNIZATIONS_GIVEN); List<String> pre... | ChildService { public void updateImmunizations(FormSubmission submission) { String immunizationDate = submission .getFieldValue(AllConstants.ChildImmunizationsFields.IMMUNIZATION_DATE); List<String> immunizationsGivenList = splitFieldValueBySpace(submission, AllConstants.ChildImmunizationsFields.IMMUNIZATIONS_GIVEN); L... | ChildService { public void updateImmunizations(FormSubmission submission) { String immunizationDate = submission .getFieldValue(AllConstants.ChildImmunizationsFields.IMMUNIZATION_DATE); List<String> immunizationsGivenList = splitFieldValueBySpace(submission, AllConstants.ChildImmunizationsFields.IMMUNIZATIONS_GIVEN); L... | ChildService { public void updateImmunizations(FormSubmission submission) { String immunizationDate = submission .getFieldValue(AllConstants.ChildImmunizationsFields.IMMUNIZATION_DATE); List<String> immunizationsGivenList = splitFieldValueBySpace(submission, AllConstants.ChildImmunizationsFields.IMMUNIZATIONS_GIVEN); L... | ChildService { public void updateImmunizations(FormSubmission submission) { String immunizationDate = submission .getFieldValue(AllConstants.ChildImmunizationsFields.IMMUNIZATION_DATE); List<String> immunizationsGivenList = splitFieldValueBySpace(submission, AllConstants.ChildImmunizationsFields.IMMUNIZATIONS_GIVEN); L... |
@Test public void shouldAddServiceProvidedWhenChildImmunizationsAreUpdated() throws Exception { FormSubmission submission = Mockito.mock(FormSubmission.class); Mockito.when(submission.entityId()).thenReturn("child id 1"); Mockito.when(submission.getFieldValue("previousImmunizations")).thenReturn("bcg"); Mockito.when(su... | public void updateImmunizations(FormSubmission submission) { String immunizationDate = submission .getFieldValue(AllConstants.ChildImmunizationsFields.IMMUNIZATION_DATE); List<String> immunizationsGivenList = splitFieldValueBySpace(submission, AllConstants.ChildImmunizationsFields.IMMUNIZATIONS_GIVEN); List<String> pre... | ChildService { public void updateImmunizations(FormSubmission submission) { String immunizationDate = submission .getFieldValue(AllConstants.ChildImmunizationsFields.IMMUNIZATION_DATE); List<String> immunizationsGivenList = splitFieldValueBySpace(submission, AllConstants.ChildImmunizationsFields.IMMUNIZATIONS_GIVEN); L... | ChildService { public void updateImmunizations(FormSubmission submission) { String immunizationDate = submission .getFieldValue(AllConstants.ChildImmunizationsFields.IMMUNIZATION_DATE); List<String> immunizationsGivenList = splitFieldValueBySpace(submission, AllConstants.ChildImmunizationsFields.IMMUNIZATIONS_GIVEN); L... | ChildService { public void updateImmunizations(FormSubmission submission) { String immunizationDate = submission .getFieldValue(AllConstants.ChildImmunizationsFields.IMMUNIZATION_DATE); List<String> immunizationsGivenList = splitFieldValueBySpace(submission, AllConstants.ChildImmunizationsFields.IMMUNIZATIONS_GIVEN); L... | ChildService { public void updateImmunizations(FormSubmission submission) { String immunizationDate = submission .getFieldValue(AllConstants.ChildImmunizationsFields.IMMUNIZATION_DATE); List<String> immunizationsGivenList = splitFieldValueBySpace(submission, AllConstants.ChildImmunizationsFields.IMMUNIZATIONS_GIVEN); L... |
@Test public void shouldMarkRemindersAsInProcessWhenImmunizationsAreProvided() throws Exception { FormSubmission submission = Mockito.mock(FormSubmission.class); Mockito.when(submission.entityId()).thenReturn("child id 1"); Mockito.when(submission.getFieldValue("previousImmunizations")).thenReturn("bcg"); Mockito.when(... | public void updateImmunizations(FormSubmission submission) { String immunizationDate = submission .getFieldValue(AllConstants.ChildImmunizationsFields.IMMUNIZATION_DATE); List<String> immunizationsGivenList = splitFieldValueBySpace(submission, AllConstants.ChildImmunizationsFields.IMMUNIZATIONS_GIVEN); List<String> pre... | ChildService { public void updateImmunizations(FormSubmission submission) { String immunizationDate = submission .getFieldValue(AllConstants.ChildImmunizationsFields.IMMUNIZATION_DATE); List<String> immunizationsGivenList = splitFieldValueBySpace(submission, AllConstants.ChildImmunizationsFields.IMMUNIZATIONS_GIVEN); L... | ChildService { public void updateImmunizations(FormSubmission submission) { String immunizationDate = submission .getFieldValue(AllConstants.ChildImmunizationsFields.IMMUNIZATION_DATE); List<String> immunizationsGivenList = splitFieldValueBySpace(submission, AllConstants.ChildImmunizationsFields.IMMUNIZATIONS_GIVEN); L... | ChildService { public void updateImmunizations(FormSubmission submission) { String immunizationDate = submission .getFieldValue(AllConstants.ChildImmunizationsFields.IMMUNIZATION_DATE); List<String> immunizationsGivenList = splitFieldValueBySpace(submission, AllConstants.ChildImmunizationsFields.IMMUNIZATIONS_GIVEN); L... | ChildService { public void updateImmunizations(FormSubmission submission) { String immunizationDate = submission .getFieldValue(AllConstants.ChildImmunizationsFields.IMMUNIZATION_DATE); List<String> immunizationsGivenList = splitFieldValueBySpace(submission, AllConstants.ChildImmunizationsFields.IMMUNIZATIONS_GIVEN); L... |
@Test public void shouldAddTimelineEventWhenChildIsRegisteredForEC() throws Exception { FormSubmission submission = Mockito.mock(FormSubmission.class); Mother mother = new Mother("mother id 1", "ec id 1", "thayi card number", "2013-01-01"); Mockito.when(submission.entityId()).thenReturn("ec id 1"); Mockito.when(submiss... | public void registerForEC(FormSubmission submission) { if (shouldCloseMother(submission.getFieldValue(SHOULD_CLOSE_MOTHER))) { closeMother(submission.getFieldValue(AllConstants.ChildRegistrationFields.MOTHER_ID)); } Map<String, String> immunizationDateFieldMap = createImmunizationDateFieldMap(); allTimelines.add(forChi... | ChildService { public void registerForEC(FormSubmission submission) { if (shouldCloseMother(submission.getFieldValue(SHOULD_CLOSE_MOTHER))) { closeMother(submission.getFieldValue(AllConstants.ChildRegistrationFields.MOTHER_ID)); } Map<String, String> immunizationDateFieldMap = createImmunizationDateFieldMap(); allTimel... | ChildService { public void registerForEC(FormSubmission submission) { if (shouldCloseMother(submission.getFieldValue(SHOULD_CLOSE_MOTHER))) { closeMother(submission.getFieldValue(AllConstants.ChildRegistrationFields.MOTHER_ID)); } Map<String, String> immunizationDateFieldMap = createImmunizationDateFieldMap(); allTimel... | ChildService { public void registerForEC(FormSubmission submission) { if (shouldCloseMother(submission.getFieldValue(SHOULD_CLOSE_MOTHER))) { closeMother(submission.getFieldValue(AllConstants.ChildRegistrationFields.MOTHER_ID)); } Map<String, String> immunizationDateFieldMap = createImmunizationDateFieldMap(); allTimel... | ChildService { public void registerForEC(FormSubmission submission) { if (shouldCloseMother(submission.getFieldValue(SHOULD_CLOSE_MOTHER))) { closeMother(submission.getFieldValue(AllConstants.ChildRegistrationFields.MOTHER_ID)); } Map<String, String> immunizationDateFieldMap = createImmunizationDateFieldMap(); allTimel... |
@Test public void shouldNotCloseMotherWhenAnOpenANCAlreadyExistWhileRegisteringAChildForEC() throws Exception { FormSubmission submission = Mockito.mock(FormSubmission.class); Mockito.when(submission.entityId()).thenReturn("ec id 1"); Mockito.when(submission.getFieldValue("motherId")).thenReturn("mother id 1"); Mockito... | public void registerForEC(FormSubmission submission) { if (shouldCloseMother(submission.getFieldValue(SHOULD_CLOSE_MOTHER))) { closeMother(submission.getFieldValue(AllConstants.ChildRegistrationFields.MOTHER_ID)); } Map<String, String> immunizationDateFieldMap = createImmunizationDateFieldMap(); allTimelines.add(forChi... | ChildService { public void registerForEC(FormSubmission submission) { if (shouldCloseMother(submission.getFieldValue(SHOULD_CLOSE_MOTHER))) { closeMother(submission.getFieldValue(AllConstants.ChildRegistrationFields.MOTHER_ID)); } Map<String, String> immunizationDateFieldMap = createImmunizationDateFieldMap(); allTimel... | ChildService { public void registerForEC(FormSubmission submission) { if (shouldCloseMother(submission.getFieldValue(SHOULD_CLOSE_MOTHER))) { closeMother(submission.getFieldValue(AllConstants.ChildRegistrationFields.MOTHER_ID)); } Map<String, String> immunizationDateFieldMap = createImmunizationDateFieldMap(); allTimel... | ChildService { public void registerForEC(FormSubmission submission) { if (shouldCloseMother(submission.getFieldValue(SHOULD_CLOSE_MOTHER))) { closeMother(submission.getFieldValue(AllConstants.ChildRegistrationFields.MOTHER_ID)); } Map<String, String> immunizationDateFieldMap = createImmunizationDateFieldMap(); allTimel... | ChildService { public void registerForEC(FormSubmission submission) { if (shouldCloseMother(submission.getFieldValue(SHOULD_CLOSE_MOTHER))) { closeMother(submission.getFieldValue(AllConstants.ChildRegistrationFields.MOTHER_ID)); } Map<String, String> immunizationDateFieldMap = createImmunizationDateFieldMap(); allTimel... |
@Test public void testSaveEventAndClients() throws IOException { when(database.rawQuery(query, params)).thenReturn(getECCursor()); when(clientProcessor.getColumnMappings(tableName)).thenReturn(getEcConfig()); Whitebox.setInternalState(recreateECUtil, "eventClientRepository", eventClientRepository); Pair<List<Event>, Li... | public void saveEventAndClients(Pair<List<Event>, List<Client>> eventClients, SQLiteDatabase sqLiteDatabase) { if (eventClients == null) { return; } if (eventClients.first != null) { JSONArray events; try { events = new JSONArray(gson.toJson(eventClients.first)); Timber.d("saving %d events, %s ", eventClients.first.siz... | RecreateECUtil { public void saveEventAndClients(Pair<List<Event>, List<Client>> eventClients, SQLiteDatabase sqLiteDatabase) { if (eventClients == null) { return; } if (eventClients.first != null) { JSONArray events; try { events = new JSONArray(gson.toJson(eventClients.first)); Timber.d("saving %d events, %s ", event... | RecreateECUtil { public void saveEventAndClients(Pair<List<Event>, List<Client>> eventClients, SQLiteDatabase sqLiteDatabase) { if (eventClients == null) { return; } if (eventClients.first != null) { JSONArray events; try { events = new JSONArray(gson.toJson(eventClients.first)); Timber.d("saving %d events, %s ", event... | RecreateECUtil { public void saveEventAndClients(Pair<List<Event>, List<Client>> eventClients, SQLiteDatabase sqLiteDatabase) { if (eventClients == null) { return; } if (eventClients.first != null) { JSONArray events; try { events = new JSONArray(gson.toJson(eventClients.first)); Timber.d("saving %d events, %s ", event... | RecreateECUtil { public void saveEventAndClients(Pair<List<Event>, List<Client>> eventClients, SQLiteDatabase sqLiteDatabase) { if (eventClients == null) { return; } if (eventClients.first != null) { JSONArray events; try { events = new JSONArray(gson.toJson(eventClients.first)); Timber.d("saving %d events, %s ", event... |
@Test public void assertTryParseWithValidValue() { Assert.assertEquals(FloatUtil.tryParse("1", 1.0f), 1.0f); Assert.assertEquals(FloatUtil.tryParse("1", "1"), "1.0"); } | public static Float tryParse(String value, Float defaultValue) { try { return Float.parseFloat(value); } catch (NumberFormatException e) { return defaultValue; } } | FloatUtil { public static Float tryParse(String value, Float defaultValue) { try { return Float.parseFloat(value); } catch (NumberFormatException e) { return defaultValue; } } } | FloatUtil { public static Float tryParse(String value, Float defaultValue) { try { return Float.parseFloat(value); } catch (NumberFormatException e) { return defaultValue; } } } | FloatUtil { public static Float tryParse(String value, Float defaultValue) { try { return Float.parseFloat(value); } catch (NumberFormatException e) { return defaultValue; } } static Float tryParse(String value, Float defaultValue); static String tryParse(String value, String defaultValue); } | FloatUtil { public static Float tryParse(String value, Float defaultValue) { try { return Float.parseFloat(value); } catch (NumberFormatException e) { return defaultValue; } } static Float tryParse(String value, Float defaultValue); static String tryParse(String value, String defaultValue); } |
@Test public void shouldAddPNCVisitTimelineEventWhenPNCVisitHappens() throws Exception { FormSubmission submission = Mockito.mock(FormSubmission.class); SubForm subForm = Mockito.mock(SubForm.class); Mockito.when(submission.entityId()).thenReturn("mother id 1"); Mockito.when(submission.getFieldValue("pncVisitDay")).the... | public void pncVisitHappened(FormSubmission submission) { String pncVisitDate = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE); String pncVisitDay = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY); SubForm subForm = submission .getSubFormByName(AllConstants.PNCVisitFields.CHILD... | ChildService { public void pncVisitHappened(FormSubmission submission) { String pncVisitDate = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE); String pncVisitDay = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY); SubForm subForm = submission .getSubFormByName(AllConstants.PNCVi... | ChildService { public void pncVisitHappened(FormSubmission submission) { String pncVisitDate = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE); String pncVisitDay = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY); SubForm subForm = submission .getSubFormByName(AllConstants.PNCVi... | ChildService { public void pncVisitHappened(FormSubmission submission) { String pncVisitDate = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE); String pncVisitDay = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY); SubForm subForm = submission .getSubFormByName(AllConstants.PNCVi... | ChildService { public void pncVisitHappened(FormSubmission submission) { String pncVisitDate = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE); String pncVisitDay = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY); SubForm subForm = submission .getSubFormByName(AllConstants.PNCVi... |
@Test public void shouldHandleStillBirthWhenPNCVisitHappens() throws Exception { FormSubmission submission = Mockito.mock(FormSubmission.class); SubForm subForm = Mockito.mock(SubForm.class); Mockito.when(submission.entityId()).thenReturn("mother id 1"); Mockito.when(submission.getFieldValue("pncVisitDay")).thenReturn(... | public void pncVisitHappened(FormSubmission submission) { String pncVisitDate = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE); String pncVisitDay = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY); SubForm subForm = submission .getSubFormByName(AllConstants.PNCVisitFields.CHILD... | ChildService { public void pncVisitHappened(FormSubmission submission) { String pncVisitDate = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE); String pncVisitDay = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY); SubForm subForm = submission .getSubFormByName(AllConstants.PNCVi... | ChildService { public void pncVisitHappened(FormSubmission submission) { String pncVisitDate = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE); String pncVisitDay = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY); SubForm subForm = submission .getSubFormByName(AllConstants.PNCVi... | ChildService { public void pncVisitHappened(FormSubmission submission) { String pncVisitDate = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE); String pncVisitDay = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY); SubForm subForm = submission .getSubFormByName(AllConstants.PNCVi... | ChildService { public void pncVisitHappened(FormSubmission submission) { String pncVisitDate = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE); String pncVisitDay = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY); SubForm subForm = submission .getSubFormByName(AllConstants.PNCVi... |
@Test public void shouldAddPNCVisitServiceProvidedWhenPNCVisitHappens() throws Exception { FormSubmission submission = Mockito.mock(FormSubmission.class); SubForm subForm = Mockito.mock(SubForm.class); Mockito.when(submission.entityId()).thenReturn("mother id 1"); Mockito.when(submission.getFieldValue("pncVisitDay")).t... | public void pncVisitHappened(FormSubmission submission) { String pncVisitDate = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE); String pncVisitDay = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY); SubForm subForm = submission .getSubFormByName(AllConstants.PNCVisitFields.CHILD... | ChildService { public void pncVisitHappened(FormSubmission submission) { String pncVisitDate = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE); String pncVisitDay = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY); SubForm subForm = submission .getSubFormByName(AllConstants.PNCVi... | ChildService { public void pncVisitHappened(FormSubmission submission) { String pncVisitDate = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE); String pncVisitDay = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY); SubForm subForm = submission .getSubFormByName(AllConstants.PNCVi... | ChildService { public void pncVisitHappened(FormSubmission submission) { String pncVisitDate = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE); String pncVisitDay = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY); SubForm subForm = submission .getSubFormByName(AllConstants.PNCVi... | ChildService { public void pncVisitHappened(FormSubmission submission) { String pncVisitDate = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE); String pncVisitDay = submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY); SubForm subForm = submission .getSubFormByName(AllConstants.PNCVi... |
@Test public void shouldCloseChildRecordForDeleteChildAction() throws Exception { FormSubmission submission = Mockito.mock(FormSubmission.class); Mockito.when(submission.entityId()).thenReturn("child id 1"); service.close(submission); Mockito.verify(allBeneficiaries).closeChild("child id 1"); } | public void close(FormSubmission submission) { allBeneficiaries.closeChild(submission.entityId()); } | ChildService { public void close(FormSubmission submission) { allBeneficiaries.closeChild(submission.entityId()); } } | ChildService { public void close(FormSubmission submission) { allBeneficiaries.closeChild(submission.entityId()); } ChildService(AllBeneficiaries allBeneficiariesArg, MotherRepository
motherRepositoryArg, ChildRepository childRepositoryArg, AllTimelineEvents
allTimelineEvents... | ChildService { public void close(FormSubmission submission) { allBeneficiaries.closeChild(submission.entityId()); } ChildService(AllBeneficiaries allBeneficiariesArg, MotherRepository
motherRepositoryArg, ChildRepository childRepositoryArg, AllTimelineEvents
allTimelineEvents... | ChildService { public void close(FormSubmission submission) { allBeneficiaries.closeChild(submission.entityId()); } ChildService(AllBeneficiaries allBeneficiariesArg, MotherRepository
motherRepositoryArg, ChildRepository childRepositoryArg, AllTimelineEvents
allTimelineEvents... |
@Test public void shouldUpdateIllnessForUpdateIllnessAction() throws Exception { FormSubmission submission = Mockito.mock(FormSubmission.class); Mockito.when(submission.entityId()).thenReturn("child id 1"); Mockito.when(submission.getFieldValue("submissionDate")).thenReturn("2012-01-02"); Mockito.when(submission.getFie... | public void updateIllnessStatus(FormSubmission submission) { String sickVisitDate = submission.getFieldValue(SICK_VISIT_DATE); String date = sickVisitDate != null ? sickVisitDate : submission.getFieldValue(REPORT_CHILD_DISEASE_DATE); serviceProvidedService.add(ServiceProvided.forChildIllnessVisit(submission.entityId(),... | ChildService { public void updateIllnessStatus(FormSubmission submission) { String sickVisitDate = submission.getFieldValue(SICK_VISIT_DATE); String date = sickVisitDate != null ? sickVisitDate : submission.getFieldValue(REPORT_CHILD_DISEASE_DATE); serviceProvidedService.add(ServiceProvided.forChildIllnessVisit(submiss... | ChildService { public void updateIllnessStatus(FormSubmission submission) { String sickVisitDate = submission.getFieldValue(SICK_VISIT_DATE); String date = sickVisitDate != null ? sickVisitDate : submission.getFieldValue(REPORT_CHILD_DISEASE_DATE); serviceProvidedService.add(ServiceProvided.forChildIllnessVisit(submiss... | ChildService { public void updateIllnessStatus(FormSubmission submission) { String sickVisitDate = submission.getFieldValue(SICK_VISIT_DATE); String date = sickVisitDate != null ? sickVisitDate : submission.getFieldValue(REPORT_CHILD_DISEASE_DATE); serviceProvidedService.add(ServiceProvided.forChildIllnessVisit(submiss... | ChildService { public void updateIllnessStatus(FormSubmission submission) { String sickVisitDate = submission.getFieldValue(SICK_VISIT_DATE); String date = sickVisitDate != null ? sickVisitDate : submission.getFieldValue(REPORT_CHILD_DISEASE_DATE); serviceProvidedService.add(ServiceProvided.forChildIllnessVisit(submiss... |
@Test public void shouldUpdateVitaminADosagesForUpdateVitaminAProvidedAction() throws Exception { FormSubmission submission = Mockito.mock(FormSubmission.class); Mockito.when(submission.entityId()).thenReturn("child id 1"); Mockito.when(submission.getFieldValue("vitaminADate")).thenReturn("2012-01-01"); Mockito.when(su... | public void updateVitaminAProvided(FormSubmission submission) { serviceProvidedService.add(ServiceProvided.forVitaminAProvided(submission.entityId(), submission.getFieldValue(AllConstants.VitaminAFields.VITAMIN_A_DATE), submission.getFieldValue(AllConstants.VitaminAFields.VITAMIN_A_DOSE), submission.getFieldValue(AllCo... | ChildService { public void updateVitaminAProvided(FormSubmission submission) { serviceProvidedService.add(ServiceProvided.forVitaminAProvided(submission.entityId(), submission.getFieldValue(AllConstants.VitaminAFields.VITAMIN_A_DATE), submission.getFieldValue(AllConstants.VitaminAFields.VITAMIN_A_DOSE), submission.getF... | ChildService { public void updateVitaminAProvided(FormSubmission submission) { serviceProvidedService.add(ServiceProvided.forVitaminAProvided(submission.entityId(), submission.getFieldValue(AllConstants.VitaminAFields.VITAMIN_A_DATE), submission.getFieldValue(AllConstants.VitaminAFields.VITAMIN_A_DOSE), submission.getF... | ChildService { public void updateVitaminAProvided(FormSubmission submission) { serviceProvidedService.add(ServiceProvided.forVitaminAProvided(submission.entityId(), submission.getFieldValue(AllConstants.VitaminAFields.VITAMIN_A_DATE), submission.getFieldValue(AllConstants.VitaminAFields.VITAMIN_A_DOSE), submission.getF... | ChildService { public void updateVitaminAProvided(FormSubmission submission) { serviceProvidedService.add(ServiceProvided.forVitaminAProvided(submission.entityId(), submission.getFieldValue(AllConstants.VitaminAFields.VITAMIN_A_DATE), submission.getFieldValue(AllConstants.VitaminAFields.VITAMIN_A_DOSE), submission.getF... |
@Test public void shouldAddTimelineEventWhenChildIsRegisteredForOA() throws Exception { FormSubmission submission = Mockito.mock(FormSubmission.class); Mockito.when(submission.entityId()).thenReturn("ec id 1"); Mockito.when(submission.getFieldValue("motherId")).thenReturn("mother id 1"); Mockito.when(submission.getFiel... | public void registerForOA(FormSubmission submission) { Child child = allBeneficiaries.findChild(submission.getFieldValue(CHILD_ID)); child.setThayiCardNumber(submission.getFieldValue(THAYI_CARD_NUMBER)); allBeneficiaries.updateChild(child); Map<String, String> immunizationDateFieldMap = createImmunizationDateFieldMap()... | ChildService { public void registerForOA(FormSubmission submission) { Child child = allBeneficiaries.findChild(submission.getFieldValue(CHILD_ID)); child.setThayiCardNumber(submission.getFieldValue(THAYI_CARD_NUMBER)); allBeneficiaries.updateChild(child); Map<String, String> immunizationDateFieldMap = createImmunizatio... | ChildService { public void registerForOA(FormSubmission submission) { Child child = allBeneficiaries.findChild(submission.getFieldValue(CHILD_ID)); child.setThayiCardNumber(submission.getFieldValue(THAYI_CARD_NUMBER)); allBeneficiaries.updateChild(child); Map<String, String> immunizationDateFieldMap = createImmunizatio... | ChildService { public void registerForOA(FormSubmission submission) { Child child = allBeneficiaries.findChild(submission.getFieldValue(CHILD_ID)); child.setThayiCardNumber(submission.getFieldValue(THAYI_CARD_NUMBER)); allBeneficiaries.updateChild(child); Map<String, String> immunizationDateFieldMap = createImmunizatio... | ChildService { public void registerForOA(FormSubmission submission) { Child child = allBeneficiaries.findChild(submission.getFieldValue(CHILD_ID)); child.setThayiCardNumber(submission.getFieldValue(THAYI_CARD_NUMBER)); allBeneficiaries.updateChild(child); Map<String, String> immunizationDateFieldMap = createImmunizatio... |
@Test public void shouldFetchAlertActionsAndNotSaveAnythingIfThereIsNothingNewToSave() throws Exception { setupActions(ResponseStatus.success, new ArrayList<Action>()); Assert.assertEquals(FetchStatus.nothingFetched, service.fetchNewActions()); Mockito.verify(drishtiService).fetchNewActions("ANM X", "1234"); Mockito.ve... | public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payload().isEmpty())... | ActionService { public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payl... | ActionService { public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payl... | ActionService { public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payl... | ActionService { public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payl... |
@Test public void shouldNotSaveAnythingIfTheDrishtiResponseStatusIsFailure() throws Exception { setupActions(ResponseStatus.failure, Arrays.asList(ActionBuilder.actionForCloseAlert("Case X", "ANC 1", "2012-01-01", "0"))); Assert.assertEquals(FetchStatus.fetchedFailed, service.fetchNewActions()); Mockito.verify(drishtiS... | public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payload().isEmpty())... | ActionService { public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payl... | ActionService { public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payl... | ActionService { public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payl... | ActionService { public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payl... |
@Test public void shouldFetchAlertActionsAndSaveThemToRepository() throws Exception { Action action = ActionBuilder.actionForCreateAlert("Case X", "normal", "mother", "Ante Natal Care - Normal", "ANC 1", "2012-01-01", null, "0"); setupActions(ResponseStatus.success, Arrays.asList(action)); Assert.assertEquals(FetchStat... | public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payload().isEmpty())... | ActionService { public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payl... | ActionService { public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payl... | ActionService { public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payl... | ActionService { public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payl... |
@Test public void assertretrieveValueForLinkedRecord() throws Exception { formUtils = new FormUtils(context_); Mockito.when(context_.getAssets()).thenReturn(assetManager); Mockito.when(assetManager.open(entityRelationShip)).thenAnswer(new Answer<InputStream>() { @Override public InputStream answer(InvocationOnMock invo... | public String retrieveValueForLinkedRecord(String link, JSONObject entityJson) { try { String entityRelationships = readFileFromAssetsFolder( "www/form/entity_relationship" + AllConstants.JSON_FILE_EXTENSION); JSONArray json = new JSONArray(entityRelationships); Timber.i(json.toString()); JSONObject rJson; if ((rJson =... | FormUtils { public String retrieveValueForLinkedRecord(String link, JSONObject entityJson) { try { String entityRelationships = readFileFromAssetsFolder( "www/form/entity_relationship" + AllConstants.JSON_FILE_EXTENSION); JSONArray json = new JSONArray(entityRelationships); Timber.i(json.toString()); JSONObject rJson; ... | FormUtils { public String retrieveValueForLinkedRecord(String link, JSONObject entityJson) { try { String entityRelationships = readFileFromAssetsFolder( "www/form/entity_relationship" + AllConstants.JSON_FILE_EXTENSION); JSONArray json = new JSONArray(entityRelationships); Timber.i(json.toString()); JSONObject rJson; ... | FormUtils { public String retrieveValueForLinkedRecord(String link, JSONObject entityJson) { try { String entityRelationships = readFileFromAssetsFolder( "www/form/entity_relationship" + AllConstants.JSON_FILE_EXTENSION); JSONArray json = new JSONArray(entityRelationships); Timber.i(json.toString()); JSONObject rJson; ... | FormUtils { public String retrieveValueForLinkedRecord(String link, JSONObject entityJson) { try { String entityRelationships = readFileFromAssetsFolder( "www/form/entity_relationship" + AllConstants.JSON_FILE_EXTENSION); JSONArray json = new JSONArray(entityRelationships); Timber.i(json.toString()); JSONObject rJson; ... |
@Test public void shouldUpdatePreviousIndexWithIndexOfEachActionThatIsHandled() throws Exception { Action firstAction = ActionBuilder.actionForCreateAlert("Case X", "normal", "mother", "Ante Natal Care - Normal", "ANC 1", "2012-01-01", "2012-01-22", "11111"); Action secondAction = ActionBuilder.actionForCreateAlert("Ca... | public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payload().isEmpty())... | ActionService { public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payl... | ActionService { public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payl... | ActionService { public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payl... | ActionService { public FetchStatus fetchNewActions() { String previousFetchIndex = allSettings.fetchPreviousFetchIndex(); Response<List<Action>> response = drishtiService .fetchNewActions(allSharedPreference.fetchRegisteredANM(), previousFetchIndex); if (response.isFailure()) { return fetchedFailed; } if (response.payl... |
@Test public void assertReplicationIntentServiceInitializationTest() { ReplicationIntentService replicationIntentService = new ReplicationIntentService(); Assert.assertNotNull(replicationIntentService); replicationIntentService.onHandleIntent(null); } | @Override protected void onHandleIntent(Intent intent) { } | ReplicationIntentService extends IntentService { @Override protected void onHandleIntent(Intent intent) { } } | ReplicationIntentService extends IntentService { @Override protected void onHandleIntent(Intent intent) { } ReplicationIntentService(String name); ReplicationIntentService(); } | ReplicationIntentService extends IntentService { @Override protected void onHandleIntent(Intent intent) { } ReplicationIntentService(String name); ReplicationIntentService(); } | ReplicationIntentService extends IntentService { @Override protected void onHandleIntent(Intent intent) { } ReplicationIntentService(String name); ReplicationIntentService(); } |
@Test public void assertReplicationIntentServiceInitializationTest2() { ReplicationIntentService replicationIntentService = new ReplicationIntentService("service_name"); Assert.assertNotNull(replicationIntentService); replicationIntentService.onHandleIntent(null); } | @Override protected void onHandleIntent(Intent intent) { } | ReplicationIntentService extends IntentService { @Override protected void onHandleIntent(Intent intent) { } } | ReplicationIntentService extends IntentService { @Override protected void onHandleIntent(Intent intent) { } ReplicationIntentService(String name); ReplicationIntentService(); } | ReplicationIntentService extends IntentService { @Override protected void onHandleIntent(Intent intent) { } ReplicationIntentService(String name); ReplicationIntentService(); } | ReplicationIntentService extends IntentService { @Override protected void onHandleIntent(Intent intent) { } ReplicationIntentService(String name); ReplicationIntentService(); } |
@Test public void shouldRegisterANC() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("motherId")).thenReturn("mother id 1"); when(submission.getFieldValue("thayiCardNumber")).thenReturn("thayi 1"); when(subm... | public void registerANC(FormSubmission submission) { addTimelineEventsForMotherRegistration(submission); } | MotherService { public void registerANC(FormSubmission submission) { addTimelineEventsForMotherRegistration(submission); } } | MotherService { public void registerANC(FormSubmission submission) { addTimelineEventsForMotherRegistration(submission); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
serv... | MotherService { public void registerANC(FormSubmission submission) { addTimelineEventsForMotherRegistration(submission); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
serv... | MotherService { public void registerANC(FormSubmission submission) { addTimelineEventsForMotherRegistration(submission); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
serv... |
@Test public void shouldRegisterOutOfAreaANC() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("motherId")).thenReturn("mother id 1"); when(submission.getFieldValue("thayiCardNumber")).thenReturn("thayi 1"); ... | public void registerOutOfAreaANC(FormSubmission submission) { addTimelineEventsForMotherRegistration(submission); } | MotherService { public void registerOutOfAreaANC(FormSubmission submission) { addTimelineEventsForMotherRegistration(submission); } } | MotherService { public void registerOutOfAreaANC(FormSubmission submission) { addTimelineEventsForMotherRegistration(submission); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... | MotherService { public void registerOutOfAreaANC(FormSubmission submission) { addTimelineEventsForMotherRegistration(submission); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... | MotherService { public void registerOutOfAreaANC(FormSubmission submission) { addTimelineEventsForMotherRegistration(submission); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... |
@Test public void shouldCreateTimelineEventsWhenANCVisitHappens() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("ancVisitDate")).thenReturn("2013-01-01"); when(submission.getFieldValue("ancVisitNumber")).th... | public void ancVisit(FormSubmission submission) { allTimelines.add(forANCCareProvided(submission.entityId(), submission.getFieldValue(ANC_VISIT_NUMBER), submission.getFieldValue(ANC_VISIT_DATE), create(BP_SYSTOLIC, submission.getFieldValue(BP_SYSTOLIC)) .put(BP_DIASTOLIC, submission.getFieldValue(BP_DIASTOLIC)) .put(TE... | MotherService { public void ancVisit(FormSubmission submission) { allTimelines.add(forANCCareProvided(submission.entityId(), submission.getFieldValue(ANC_VISIT_NUMBER), submission.getFieldValue(ANC_VISIT_DATE), create(BP_SYSTOLIC, submission.getFieldValue(BP_SYSTOLIC)) .put(BP_DIASTOLIC, submission.getFieldValue(BP_DIA... | MotherService { public void ancVisit(FormSubmission submission) { allTimelines.add(forANCCareProvided(submission.entityId(), submission.getFieldValue(ANC_VISIT_NUMBER), submission.getFieldValue(ANC_VISIT_DATE), create(BP_SYSTOLIC, submission.getFieldValue(BP_SYSTOLIC)) .put(BP_DIASTOLIC, submission.getFieldValue(BP_DIA... | MotherService { public void ancVisit(FormSubmission submission) { allTimelines.add(forANCCareProvided(submission.entityId(), submission.getFieldValue(ANC_VISIT_NUMBER), submission.getFieldValue(ANC_VISIT_DATE), create(BP_SYSTOLIC, submission.getFieldValue(BP_SYSTOLIC)) .put(BP_DIASTOLIC, submission.getFieldValue(BP_DIA... | MotherService { public void ancVisit(FormSubmission submission) { allTimelines.add(forANCCareProvided(submission.entityId(), submission.getFieldValue(ANC_VISIT_NUMBER), submission.getFieldValue(ANC_VISIT_DATE), create(BP_SYSTOLIC, submission.getFieldValue(BP_SYSTOLIC)) .put(BP_DIASTOLIC, submission.getFieldValue(BP_DIA... |
@Test public void shouldAddServiceProvidedWhenANCVisitHappens() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("ancVisitDate")).thenReturn("2013-01-01"); when(submission.getFieldValue("ancVisitNumber")).then... | public void ancVisit(FormSubmission submission) { allTimelines.add(forANCCareProvided(submission.entityId(), submission.getFieldValue(ANC_VISIT_NUMBER), submission.getFieldValue(ANC_VISIT_DATE), create(BP_SYSTOLIC, submission.getFieldValue(BP_SYSTOLIC)) .put(BP_DIASTOLIC, submission.getFieldValue(BP_DIASTOLIC)) .put(TE... | MotherService { public void ancVisit(FormSubmission submission) { allTimelines.add(forANCCareProvided(submission.entityId(), submission.getFieldValue(ANC_VISIT_NUMBER), submission.getFieldValue(ANC_VISIT_DATE), create(BP_SYSTOLIC, submission.getFieldValue(BP_SYSTOLIC)) .put(BP_DIASTOLIC, submission.getFieldValue(BP_DIA... | MotherService { public void ancVisit(FormSubmission submission) { allTimelines.add(forANCCareProvided(submission.entityId(), submission.getFieldValue(ANC_VISIT_NUMBER), submission.getFieldValue(ANC_VISIT_DATE), create(BP_SYSTOLIC, submission.getFieldValue(BP_SYSTOLIC)) .put(BP_DIASTOLIC, submission.getFieldValue(BP_DIA... | MotherService { public void ancVisit(FormSubmission submission) { allTimelines.add(forANCCareProvided(submission.entityId(), submission.getFieldValue(ANC_VISIT_NUMBER), submission.getFieldValue(ANC_VISIT_DATE), create(BP_SYSTOLIC, submission.getFieldValue(BP_SYSTOLIC)) .put(BP_DIASTOLIC, submission.getFieldValue(BP_DIA... | MotherService { public void ancVisit(FormSubmission submission) { allTimelines.add(forANCCareProvided(submission.entityId(), submission.getFieldValue(ANC_VISIT_NUMBER), submission.getFieldValue(ANC_VISIT_DATE), create(BP_SYSTOLIC, submission.getFieldValue(BP_SYSTOLIC)) .put(BP_DIASTOLIC, submission.getFieldValue(BP_DIA... |
@Test public void shouldNotDoAnythingWhenANCIsClosedAndMotherDoesNotExist() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(allBeneficiaries.findMotherWithOpenStatus("entity id 1")).thenReturn(null); service.close(submission); verify... | public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } } | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... |
@Test public void shouldCloseECWhenMotherIsClosedAndReasonIsDeath() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("closeReason")).thenReturn("death_of_mother"); when(allBeneficiaries.findMotherWithOpenStatu... | public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } } | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... |
@Test public void shouldCloseECWhenWomanIsClosedAndReasonIsDeath() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("closeReason")).thenReturn("death_of_woman"); when(allBeneficiaries.findMotherWithOpenStatus(... | public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } } | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... |
@Test public void assertgenerateXMLInputForFormWithEntityId() throws Exception { formUtils = new FormUtils(context_); Mockito.when(context_.getAssets()).thenReturn(assetManager); Mockito.when(assetManager.open(formDefinition)).thenAnswer(new Answer<InputStream>() { @Override public InputStream answer(InvocationOnMock i... | public String generateXMLInputForFormWithEntityId(String entityId, String formName, String overrides) { try { JSONObject fieldOverrides = new JSONObject(); if (overrides != null) { fieldOverrides = new JSONObject(overrides); String overridesStr = fieldOverrides.getString("fieldOverrides"); fieldOverrides = new JSONObje... | FormUtils { public String generateXMLInputForFormWithEntityId(String entityId, String formName, String overrides) { try { JSONObject fieldOverrides = new JSONObject(); if (overrides != null) { fieldOverrides = new JSONObject(overrides); String overridesStr = fieldOverrides.getString("fieldOverrides"); fieldOverrides = ... | FormUtils { public String generateXMLInputForFormWithEntityId(String entityId, String formName, String overrides) { try { JSONObject fieldOverrides = new JSONObject(); if (overrides != null) { fieldOverrides = new JSONObject(overrides); String overridesStr = fieldOverrides.getString("fieldOverrides"); fieldOverrides = ... | FormUtils { public String generateXMLInputForFormWithEntityId(String entityId, String formName, String overrides) { try { JSONObject fieldOverrides = new JSONObject(); if (overrides != null) { fieldOverrides = new JSONObject(overrides); String overridesStr = fieldOverrides.getString("fieldOverrides"); fieldOverrides = ... | FormUtils { public String generateXMLInputForFormWithEntityId(String entityId, String formName, String overrides) { try { JSONObject fieldOverrides = new JSONObject(); if (overrides != null) { fieldOverrides = new JSONObject(overrides); String overridesStr = fieldOverrides.getString("fieldOverrides"); fieldOverrides = ... |
@Test public void shouldCloseECWhenMotherIsClosedAndReasonIsPermanentRelocation() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("closeReason")).thenReturn("relocation_permanent"); when(allBeneficiaries.find... | public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } } | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... |
@Test public void shouldCloseECWhenMotherIsClosedUsingPNCCloseAndReasonIsPermanentRelocation() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("closeReason")).thenReturn("permanent_relocation"); when(allBenef... | public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } } | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... |
@Test public void shouldNotCloseECWhenMotherIsClosedForOtherReasons() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("closeReason")).thenReturn("other_reason"); when(allBeneficiaries.findMotherWithOpenStatus... | public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } } | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... | MotherService { public void close(FormSubmission submission) { close(submission.entityId(), submission.getFieldValue(CLOSE_REASON_FIELD_NAME)); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEvents allTimelineEvents, ServiceProvidedService
... |
@Test public void shouldHandleTTProvided() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("ttDose")).thenReturn("ttbooster"); when(submission.getFieldValue("ttDate")).thenReturn("2013-01-01"); service.ttProv... | public void ttProvided(FormSubmission submission) { allTimelines.add(forTTShotProvided(submission.entityId(), submission.getFieldValue(TT_DOSE), submission.getFieldValue(TT_DATE))); serviceProvidedService .add(forTTDose(submission.entityId(), submission.getFieldValue(TT_DOSE), submission.getFieldValue(TT_DATE))); } | MotherService { public void ttProvided(FormSubmission submission) { allTimelines.add(forTTShotProvided(submission.entityId(), submission.getFieldValue(TT_DOSE), submission.getFieldValue(TT_DATE))); serviceProvidedService .add(forTTDose(submission.entityId(), submission.getFieldValue(TT_DOSE), submission.getFieldValue(T... | MotherService { public void ttProvided(FormSubmission submission) { allTimelines.add(forTTShotProvided(submission.entityId(), submission.getFieldValue(TT_DOSE), submission.getFieldValue(TT_DATE))); serviceProvidedService .add(forTTDose(submission.entityId(), submission.getFieldValue(TT_DOSE), submission.getFieldValue(T... | MotherService { public void ttProvided(FormSubmission submission) { allTimelines.add(forTTShotProvided(submission.entityId(), submission.getFieldValue(TT_DOSE), submission.getFieldValue(TT_DATE))); serviceProvidedService .add(forTTDose(submission.entityId(), submission.getFieldValue(TT_DOSE), submission.getFieldValue(T... | MotherService { public void ttProvided(FormSubmission submission) { allTimelines.add(forTTShotProvided(submission.entityId(), submission.getFieldValue(TT_DOSE), submission.getFieldValue(TT_DATE))); serviceProvidedService .add(forTTDose(submission.entityId(), submission.getFieldValue(TT_DOSE), submission.getFieldValue(T... |
@Test public void shouldAddTimelineEventWhenIFATabletsAreGiven() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("numberOfIFATabletsGiven")).thenReturn("100"); when(submission.getFieldValue("ifaTabletsDate"))... | public void ifaTabletsGiven(FormSubmission submission) { String numberOfIFATabletsGiven = submission.getFieldValue(NUMBER_OF_IFA_TABLETS_GIVEN); if (tryParse(numberOfIFATabletsGiven, 0) > 0) { allTimelines.add(forIFATabletsGiven(submission.entityId(), numberOfIFATabletsGiven, submission.getFieldValue(IFA_TABLETS_DATE))... | MotherService { public void ifaTabletsGiven(FormSubmission submission) { String numberOfIFATabletsGiven = submission.getFieldValue(NUMBER_OF_IFA_TABLETS_GIVEN); if (tryParse(numberOfIFATabletsGiven, 0) > 0) { allTimelines.add(forIFATabletsGiven(submission.entityId(), numberOfIFATabletsGiven, submission.getFieldValue(IF... | MotherService { public void ifaTabletsGiven(FormSubmission submission) { String numberOfIFATabletsGiven = submission.getFieldValue(NUMBER_OF_IFA_TABLETS_GIVEN); if (tryParse(numberOfIFATabletsGiven, 0) > 0) { allTimelines.add(forIFATabletsGiven(submission.entityId(), numberOfIFATabletsGiven, submission.getFieldValue(IF... | MotherService { public void ifaTabletsGiven(FormSubmission submission) { String numberOfIFATabletsGiven = submission.getFieldValue(NUMBER_OF_IFA_TABLETS_GIVEN); if (tryParse(numberOfIFATabletsGiven, 0) > 0) { allTimelines.add(forIFATabletsGiven(submission.entityId(), numberOfIFATabletsGiven, submission.getFieldValue(IF... | MotherService { public void ifaTabletsGiven(FormSubmission submission) { String numberOfIFATabletsGiven = submission.getFieldValue(NUMBER_OF_IFA_TABLETS_GIVEN); if (tryParse(numberOfIFATabletsGiven, 0) > 0) { allTimelines.add(forIFATabletsGiven(submission.entityId(), numberOfIFATabletsGiven, submission.getFieldValue(IF... |
@Test public void shouldAddServiceProvidedWhenIFATabletsAreGiven() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("numberOfIFATabletsGiven")).thenReturn("100"); when(submission.getFieldValue("ifaTabletsDate"... | public void ifaTabletsGiven(FormSubmission submission) { String numberOfIFATabletsGiven = submission.getFieldValue(NUMBER_OF_IFA_TABLETS_GIVEN); if (tryParse(numberOfIFATabletsGiven, 0) > 0) { allTimelines.add(forIFATabletsGiven(submission.entityId(), numberOfIFATabletsGiven, submission.getFieldValue(IFA_TABLETS_DATE))... | MotherService { public void ifaTabletsGiven(FormSubmission submission) { String numberOfIFATabletsGiven = submission.getFieldValue(NUMBER_OF_IFA_TABLETS_GIVEN); if (tryParse(numberOfIFATabletsGiven, 0) > 0) { allTimelines.add(forIFATabletsGiven(submission.entityId(), numberOfIFATabletsGiven, submission.getFieldValue(IF... | MotherService { public void ifaTabletsGiven(FormSubmission submission) { String numberOfIFATabletsGiven = submission.getFieldValue(NUMBER_OF_IFA_TABLETS_GIVEN); if (tryParse(numberOfIFATabletsGiven, 0) > 0) { allTimelines.add(forIFATabletsGiven(submission.entityId(), numberOfIFATabletsGiven, submission.getFieldValue(IF... | MotherService { public void ifaTabletsGiven(FormSubmission submission) { String numberOfIFATabletsGiven = submission.getFieldValue(NUMBER_OF_IFA_TABLETS_GIVEN); if (tryParse(numberOfIFATabletsGiven, 0) > 0) { allTimelines.add(forIFATabletsGiven(submission.entityId(), numberOfIFATabletsGiven, submission.getFieldValue(IF... | MotherService { public void ifaTabletsGiven(FormSubmission submission) { String numberOfIFATabletsGiven = submission.getFieldValue(NUMBER_OF_IFA_TABLETS_GIVEN); if (tryParse(numberOfIFATabletsGiven, 0) > 0) { allTimelines.add(forIFATabletsGiven(submission.entityId(), numberOfIFATabletsGiven, submission.getFieldValue(IF... |
@Test public void shouldDoNothingWhenIFATabletsAreNotGiven() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("numberOfIFATabletsGiven")).thenReturn("0"); when(submission.getFieldValue("ifaTabletsDate")).thenR... | public void ifaTabletsGiven(FormSubmission submission) { String numberOfIFATabletsGiven = submission.getFieldValue(NUMBER_OF_IFA_TABLETS_GIVEN); if (tryParse(numberOfIFATabletsGiven, 0) > 0) { allTimelines.add(forIFATabletsGiven(submission.entityId(), numberOfIFATabletsGiven, submission.getFieldValue(IFA_TABLETS_DATE))... | MotherService { public void ifaTabletsGiven(FormSubmission submission) { String numberOfIFATabletsGiven = submission.getFieldValue(NUMBER_OF_IFA_TABLETS_GIVEN); if (tryParse(numberOfIFATabletsGiven, 0) > 0) { allTimelines.add(forIFATabletsGiven(submission.entityId(), numberOfIFATabletsGiven, submission.getFieldValue(IF... | MotherService { public void ifaTabletsGiven(FormSubmission submission) { String numberOfIFATabletsGiven = submission.getFieldValue(NUMBER_OF_IFA_TABLETS_GIVEN); if (tryParse(numberOfIFATabletsGiven, 0) > 0) { allTimelines.add(forIFATabletsGiven(submission.entityId(), numberOfIFATabletsGiven, submission.getFieldValue(IF... | MotherService { public void ifaTabletsGiven(FormSubmission submission) { String numberOfIFATabletsGiven = submission.getFieldValue(NUMBER_OF_IFA_TABLETS_GIVEN); if (tryParse(numberOfIFATabletsGiven, 0) > 0) { allTimelines.add(forIFATabletsGiven(submission.entityId(), numberOfIFATabletsGiven, submission.getFieldValue(IF... | MotherService { public void ifaTabletsGiven(FormSubmission submission) { String numberOfIFATabletsGiven = submission.getFieldValue(NUMBER_OF_IFA_TABLETS_GIVEN); if (tryParse(numberOfIFATabletsGiven, 0) > 0) { allTimelines.add(forIFATabletsGiven(submission.entityId(), numberOfIFATabletsGiven, submission.getFieldValue(IF... |
@Test public void shouldHandleHBTest() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("hbLevel")).thenReturn("11"); when(submission.getFieldValue("hbTestDate")).thenReturn("2013-01-01"); service.hbTest(submi... | public void hbTest(FormSubmission submission) { serviceProvidedService .add(forHBTest(submission.entityId(), submission.getFieldValue(HB_LEVEL), submission.getFieldValue(HB_TEST_DATE))); } | MotherService { public void hbTest(FormSubmission submission) { serviceProvidedService .add(forHBTest(submission.entityId(), submission.getFieldValue(HB_LEVEL), submission.getFieldValue(HB_TEST_DATE))); } } | MotherService { public void hbTest(FormSubmission submission) { serviceProvidedService .add(forHBTest(submission.entityId(), submission.getFieldValue(HB_LEVEL), submission.getFieldValue(HB_TEST_DATE))); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEven... | MotherService { public void hbTest(FormSubmission submission) { serviceProvidedService .add(forHBTest(submission.entityId(), submission.getFieldValue(HB_LEVEL), submission.getFieldValue(HB_TEST_DATE))); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEven... | MotherService { public void hbTest(FormSubmission submission) { serviceProvidedService .add(forHBTest(submission.entityId(), submission.getFieldValue(HB_LEVEL), submission.getFieldValue(HB_TEST_DATE))); } MotherService(AllBeneficiaries allBeneficiaries, AllEligibleCouples
allEligibleCouples, AllTimelineEven... |
@Test public void shouldHandleDeliveryOutcome() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("didWomanSurvive")).thenReturn("yes"); when(allBeneficiaries.findMotherWithOpenStatus("entity id 1")).thenReturn... | public void deliveryOutcome(FormSubmission submission) { Mother mother = allBeneficiaries.findMotherWithOpenStatus(submission.entityId()); if (mother == null) { logWarn("Failed to handle delivery outcome for mother. Entity ID: " + submission .entityId()); return; } if (BOOLEAN_FALSE.equals(submission.getFieldValue(DID_... | MotherService { public void deliveryOutcome(FormSubmission submission) { Mother mother = allBeneficiaries.findMotherWithOpenStatus(submission.entityId()); if (mother == null) { logWarn("Failed to handle delivery outcome for mother. Entity ID: " + submission .entityId()); return; } if (BOOLEAN_FALSE.equals(submission.ge... | MotherService { public void deliveryOutcome(FormSubmission submission) { Mother mother = allBeneficiaries.findMotherWithOpenStatus(submission.entityId()); if (mother == null) { logWarn("Failed to handle delivery outcome for mother. Entity ID: " + submission .entityId()); return; } if (BOOLEAN_FALSE.equals(submission.ge... | MotherService { public void deliveryOutcome(FormSubmission submission) { Mother mother = allBeneficiaries.findMotherWithOpenStatus(submission.entityId()); if (mother == null) { logWarn("Failed to handle delivery outcome for mother. Entity ID: " + submission .entityId()); return; } if (BOOLEAN_FALSE.equals(submission.ge... | MotherService { public void deliveryOutcome(FormSubmission submission) { Mother mother = allBeneficiaries.findMotherWithOpenStatus(submission.entityId()); if (mother == null) { logWarn("Failed to handle delivery outcome for mother. Entity ID: " + submission .entityId()); return; } if (BOOLEAN_FALSE.equals(submission.ge... |
@Test public void shouldAddPNCVisitTimelineEventWhenPNCVisitHappens() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("pncVisitDay")).thenReturn("2"); when(submission.getFieldValue("pncVisitDate")).thenReturn... | public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFields.BP_SYSTOLIC)... | MotherService { public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFie... | MotherService { public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFie... | MotherService { public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFie... | MotherService { public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFie... |
@Test public void assertgenerateFormSubmisionFromXMLString() throws Exception { formUtils = new FormUtils(context_); String formData = getStringFromStream(new FileInputStream(getFileFromPath(this, formSubmissionXML))); Mockito.when(context_.getAssets()).thenReturn(assetManager); Mockito.when(assetManager.open(formDefin... | public FormSubmission generateFormSubmisionFromXMLString(String entity_id, String formData, String formName, JSONObject overrides) throws Exception { JSONObject formSubmission = XML.toJSONObject(formData); System.out.println(formSubmission); String formDefinitionJson = readFileFromAssetsFolder( "www/form/" + formName +... | FormUtils { public FormSubmission generateFormSubmisionFromXMLString(String entity_id, String formData, String formName, JSONObject overrides) throws Exception { JSONObject formSubmission = XML.toJSONObject(formData); System.out.println(formSubmission); String formDefinitionJson = readFileFromAssetsFolder( "www/form/" ... | FormUtils { public FormSubmission generateFormSubmisionFromXMLString(String entity_id, String formData, String formName, JSONObject overrides) throws Exception { JSONObject formSubmission = XML.toJSONObject(formData); System.out.println(formSubmission); String formDefinitionJson = readFileFromAssetsFolder( "www/form/" ... | FormUtils { public FormSubmission generateFormSubmisionFromXMLString(String entity_id, String formData, String formName, JSONObject overrides) throws Exception { JSONObject formSubmission = XML.toJSONObject(formData); System.out.println(formSubmission); String formDefinitionJson = readFileFromAssetsFolder( "www/form/" ... | FormUtils { public FormSubmission generateFormSubmisionFromXMLString(String entity_id, String formData, String formName, JSONObject overrides) throws Exception { JSONObject formSubmission = XML.toJSONObject(formData); System.out.println(formSubmission); String formDefinitionJson = readFileFromAssetsFolder( "www/form/" ... |
@Test public void shouldAddIFATabletsGivenTimelineEventWhenPNCVisitHappens() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("pncVisitDay")).thenReturn("2"); when(submission.getFieldValue("pncVisitDate")).the... | public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFields.BP_SYSTOLIC)... | MotherService { public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFie... | MotherService { public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFie... | MotherService { public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFie... | MotherService { public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFie... |
@Test public void shouldAddPNCVisitServiceProvidedWhenPNCVisitHappens() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("pncVisitDay")).thenReturn("2"); when(submission.getFieldValue("pncVisitDate")).thenRetu... | public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFields.BP_SYSTOLIC)... | MotherService { public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFie... | MotherService { public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFie... | MotherService { public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFie... | MotherService { public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFie... |
@Test public void shouldNotAddIFATabletsGivenTimelineEventWhenPNCVisitHappensAndNoIFATabletsWereGiven() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("pncVisitDay")).thenReturn("2"); when(submission.getFiel... | public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFields.BP_SYSTOLIC)... | MotherService { public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFie... | MotherService { public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFie... | MotherService { public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFie... | MotherService { public void pncVisitHappened(FormSubmission submission) { allTimelines.add(forMotherPNCVisit(submission.entityId(), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DAY), submission.getFieldValue(AllConstants.PNCVisitFields.PNC_VISIT_DATE), submission.getFieldValue(AllConstants.PNCVisitFie... |
@Test public void shouldAddTimelineEventWhenDeliveryPlanHappens() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("deliveryFacilityName")).thenReturn("Delivery Facility Name"); when(submission.getFieldValue("... | public void deliveryPlan(FormSubmission submission) { allTimelines.add(forDeliveryPlan(submission.entityId(), submission.getFieldValue(DELIVERY_FACILITY_NAME), submission.getFieldValue(TRANSPORTATION_PLAN), submission.getFieldValue(BIRTH_COMPANION), submission.getFieldValue(ASHA_PHONE_NUMBER), submission.getFieldValue(... | MotherService { public void deliveryPlan(FormSubmission submission) { allTimelines.add(forDeliveryPlan(submission.entityId(), submission.getFieldValue(DELIVERY_FACILITY_NAME), submission.getFieldValue(TRANSPORTATION_PLAN), submission.getFieldValue(BIRTH_COMPANION), submission.getFieldValue(ASHA_PHONE_NUMBER), submissio... | MotherService { public void deliveryPlan(FormSubmission submission) { allTimelines.add(forDeliveryPlan(submission.entityId(), submission.getFieldValue(DELIVERY_FACILITY_NAME), submission.getFieldValue(TRANSPORTATION_PLAN), submission.getFieldValue(BIRTH_COMPANION), submission.getFieldValue(ASHA_PHONE_NUMBER), submissio... | MotherService { public void deliveryPlan(FormSubmission submission) { allTimelines.add(forDeliveryPlan(submission.entityId(), submission.getFieldValue(DELIVERY_FACILITY_NAME), submission.getFieldValue(TRANSPORTATION_PLAN), submission.getFieldValue(BIRTH_COMPANION), submission.getFieldValue(ASHA_PHONE_NUMBER), submissio... | MotherService { public void deliveryPlan(FormSubmission submission) { allTimelines.add(forDeliveryPlan(submission.entityId(), submission.getFieldValue(DELIVERY_FACILITY_NAME), submission.getFieldValue(TRANSPORTATION_PLAN), submission.getFieldValue(BIRTH_COMPANION), submission.getFieldValue(ASHA_PHONE_NUMBER), submissio... |
@Test public void shouldAddServiceProvidedWhenDeliveryPlanHappens() throws Exception { FormSubmission submission = mock(FormSubmission.class); when(submission.entityId()).thenReturn("entity id 1"); when(submission.getFieldValue("deliveryFacilityName")).thenReturn("Delivery Facility Name"); when(submission.getFieldValue... | public void deliveryPlan(FormSubmission submission) { allTimelines.add(forDeliveryPlan(submission.entityId(), submission.getFieldValue(DELIVERY_FACILITY_NAME), submission.getFieldValue(TRANSPORTATION_PLAN), submission.getFieldValue(BIRTH_COMPANION), submission.getFieldValue(ASHA_PHONE_NUMBER), submission.getFieldValue(... | MotherService { public void deliveryPlan(FormSubmission submission) { allTimelines.add(forDeliveryPlan(submission.entityId(), submission.getFieldValue(DELIVERY_FACILITY_NAME), submission.getFieldValue(TRANSPORTATION_PLAN), submission.getFieldValue(BIRTH_COMPANION), submission.getFieldValue(ASHA_PHONE_NUMBER), submissio... | MotherService { public void deliveryPlan(FormSubmission submission) { allTimelines.add(forDeliveryPlan(submission.entityId(), submission.getFieldValue(DELIVERY_FACILITY_NAME), submission.getFieldValue(TRANSPORTATION_PLAN), submission.getFieldValue(BIRTH_COMPANION), submission.getFieldValue(ASHA_PHONE_NUMBER), submissio... | MotherService { public void deliveryPlan(FormSubmission submission) { allTimelines.add(forDeliveryPlan(submission.entityId(), submission.getFieldValue(DELIVERY_FACILITY_NAME), submission.getFieldValue(TRANSPORTATION_PLAN), submission.getFieldValue(BIRTH_COMPANION), submission.getFieldValue(ASHA_PHONE_NUMBER), submissio... | MotherService { public void deliveryPlan(FormSubmission submission) { allTimelines.add(forDeliveryPlan(submission.entityId(), submission.getFieldValue(DELIVERY_FACILITY_NAME), submission.getFieldValue(TRANSPORTATION_PLAN), submission.getFieldValue(BIRTH_COMPANION), submission.getFieldValue(ASHA_PHONE_NUMBER), submissio... |
@Test public void testReadValueClearsEditableAfterReadingValue() { Mockito.doReturn(2).when(editable).length(); SecurityHelper.readValue(editable); ArgumentCaptor<Integer> lengthCaptor = ArgumentCaptor.forClass(Integer.class); ArgumentCaptor<char[]> charsCaptor = ArgumentCaptor.forClass(char[].class); ArgumentCaptor<In... | public static char[] readValue(Editable editable) { char[] chars = new char[editable.length()]; editable.getChars(0, editable.length(), chars, 0); return chars; } | SecurityHelper { public static char[] readValue(Editable editable) { char[] chars = new char[editable.length()]; editable.getChars(0, editable.length(), chars, 0); return chars; } } | SecurityHelper { public static char[] readValue(Editable editable) { char[] chars = new char[editable.length()]; editable.getChars(0, editable.length(), chars, 0); return chars; } } | SecurityHelper { public static char[] readValue(Editable editable) { char[] chars = new char[editable.length()]; editable.getChars(0, editable.length(), chars, 0); return chars; } static char[] readValue(Editable editable); static void clearArray(byte[] array); static void clearArray(char[] array); static byte[] toByt... | SecurityHelper { public static char[] readValue(Editable editable) { char[] chars = new char[editable.length()]; editable.getChars(0, editable.length(), chars, 0); return chars; } static char[] readValue(Editable editable); static void clearArray(byte[] array); static void clearArray(char[] array); static byte[] toByt... |
@Test public void clearArray() { byte[] sensitiveDataArray = SecurityHelper.toBytes(TEST_PASSWORD); SecurityHelper.clearArray(sensitiveDataArray); Assert.assertNotNull(sensitiveDataArray); for (byte c : sensitiveDataArray) { Assert.assertEquals((byte) 0, c); } } | public static void clearArray(byte[] array) { if (array != null) { Arrays.fill(array, (byte) 0); } } | SecurityHelper { public static void clearArray(byte[] array) { if (array != null) { Arrays.fill(array, (byte) 0); } } } | SecurityHelper { public static void clearArray(byte[] array) { if (array != null) { Arrays.fill(array, (byte) 0); } } } | SecurityHelper { public static void clearArray(byte[] array) { if (array != null) { Arrays.fill(array, (byte) 0); } } static char[] readValue(Editable editable); static void clearArray(byte[] array); static void clearArray(char[] array); static byte[] toBytes(StringBuffer stringBuffer); static byte[] toBytes(char[] ch... | SecurityHelper { public static void clearArray(byte[] array) { if (array != null) { Arrays.fill(array, (byte) 0); } } static char[] readValue(Editable editable); static void clearArray(byte[] array); static void clearArray(char[] array); static byte[] toBytes(StringBuffer stringBuffer); static byte[] toBytes(char[] ch... |
@Test public void testClearArrayOverwritesCharArrayValuesWithAsterisk() { char[] sensitiveDataArray = TEST_PASSWORD; SecurityHelper.clearArray(sensitiveDataArray); Assert.assertNotNull(sensitiveDataArray); for (char c : sensitiveDataArray) { Assert.assertEquals('*', c); } } | public static void clearArray(byte[] array) { if (array != null) { Arrays.fill(array, (byte) 0); } } | SecurityHelper { public static void clearArray(byte[] array) { if (array != null) { Arrays.fill(array, (byte) 0); } } } | SecurityHelper { public static void clearArray(byte[] array) { if (array != null) { Arrays.fill(array, (byte) 0); } } } | SecurityHelper { public static void clearArray(byte[] array) { if (array != null) { Arrays.fill(array, (byte) 0); } } static char[] readValue(Editable editable); static void clearArray(byte[] array); static void clearArray(char[] array); static byte[] toBytes(StringBuffer stringBuffer); static byte[] toBytes(char[] ch... | SecurityHelper { public static void clearArray(byte[] array) { if (array != null) { Arrays.fill(array, (byte) 0); } } static char[] readValue(Editable editable); static void clearArray(byte[] array); static void clearArray(char[] array); static byte[] toBytes(StringBuffer stringBuffer); static byte[] toBytes(char[] ch... |
@Test public void testToBytes() throws CharacterCodingException { StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append(TEST_PASSWORD); byte[] testPasswordBytes = SecurityHelper.toBytes(stringBuffer); Assert.assertNotNull(testPasswordBytes); Assert.assertEquals(TEST_PASSWORD.length + 1, testPasswordBytes.... | public static byte[] toBytes(StringBuffer stringBuffer) throws CharacterCodingException { CharsetEncoder encoder = CHARSET.newEncoder(); CharBuffer buffer = CharBuffer.wrap(stringBuffer); ByteBuffer bytesBuffer = encoder.encode(buffer); byte[] bytes = bytesBuffer.array(); clearArray(bytesBuffer.array()); clearStringBuf... | SecurityHelper { public static byte[] toBytes(StringBuffer stringBuffer) throws CharacterCodingException { CharsetEncoder encoder = CHARSET.newEncoder(); CharBuffer buffer = CharBuffer.wrap(stringBuffer); ByteBuffer bytesBuffer = encoder.encode(buffer); byte[] bytes = bytesBuffer.array(); clearArray(bytesBuffer.array()... | SecurityHelper { public static byte[] toBytes(StringBuffer stringBuffer) throws CharacterCodingException { CharsetEncoder encoder = CHARSET.newEncoder(); CharBuffer buffer = CharBuffer.wrap(stringBuffer); ByteBuffer bytesBuffer = encoder.encode(buffer); byte[] bytes = bytesBuffer.array(); clearArray(bytesBuffer.array()... | SecurityHelper { public static byte[] toBytes(StringBuffer stringBuffer) throws CharacterCodingException { CharsetEncoder encoder = CHARSET.newEncoder(); CharBuffer buffer = CharBuffer.wrap(stringBuffer); ByteBuffer bytesBuffer = encoder.encode(buffer); byte[] bytes = bytesBuffer.array(); clearArray(bytesBuffer.array()... | SecurityHelper { public static byte[] toBytes(StringBuffer stringBuffer) throws CharacterCodingException { CharsetEncoder encoder = CHARSET.newEncoder(); CharBuffer buffer = CharBuffer.wrap(stringBuffer); ByteBuffer bytesBuffer = encoder.encode(buffer); byte[] bytes = bytesBuffer.array(); clearArray(bytesBuffer.array()... |
@Test public void nullSafeBase64DecodeDoesNotThrowExceptionIfParameterIsNull() { PowerMockito.mockStatic(Base64.class); PowerMockito.when(Base64.decode(ArgumentMatchers.anyString(), ArgumentMatchers.eq(Base64.DEFAULT))).thenReturn(new byte[]{0, 1}); byte[] decoded = SecurityHelper.nullSafeBase64Decode(null); Assert.ass... | public static byte[] nullSafeBase64Decode(String base64EncodedValue) { if (!StringUtils.isBlank(base64EncodedValue)) { return Base64.decode(base64EncodedValue, Base64.DEFAULT); } else { return null; } } | SecurityHelper { public static byte[] nullSafeBase64Decode(String base64EncodedValue) { if (!StringUtils.isBlank(base64EncodedValue)) { return Base64.decode(base64EncodedValue, Base64.DEFAULT); } else { return null; } } } | SecurityHelper { public static byte[] nullSafeBase64Decode(String base64EncodedValue) { if (!StringUtils.isBlank(base64EncodedValue)) { return Base64.decode(base64EncodedValue, Base64.DEFAULT); } else { return null; } } } | SecurityHelper { public static byte[] nullSafeBase64Decode(String base64EncodedValue) { if (!StringUtils.isBlank(base64EncodedValue)) { return Base64.decode(base64EncodedValue, Base64.DEFAULT); } else { return null; } } static char[] readValue(Editable editable); static void clearArray(byte[] array); static void clear... | SecurityHelper { public static byte[] nullSafeBase64Decode(String base64EncodedValue) { if (!StringUtils.isBlank(base64EncodedValue)) { return Base64.decode(base64EncodedValue, Base64.DEFAULT); } else { return null; } } static char[] readValue(Editable editable); static void clearArray(byte[] array); static void clear... |
@Test public void getFormJsonShouldReturnCorrectFormWithSameLength() { Mockito.doReturn(RuntimeEnvironment.application.getResources()).when(context_).getResources(); Mockito.doReturn(RuntimeEnvironment.application.getApplicationContext()).when(context_).getApplicationContext(); Assert.assertEquals(10011, formUtils.getF... | public JSONObject getFormJson(String formIdentity) { if (mContext != null) { try { String locale = mContext.getResources().getConfiguration().locale.getLanguage(); locale = locale.equalsIgnoreCase(Locale.ENGLISH.getLanguage()) ? "" : "-" + locale; InputStream inputStream; try { inputStream = mContext.getApplicationCont... | FormUtils { public JSONObject getFormJson(String formIdentity) { if (mContext != null) { try { String locale = mContext.getResources().getConfiguration().locale.getLanguage(); locale = locale.equalsIgnoreCase(Locale.ENGLISH.getLanguage()) ? "" : "-" + locale; InputStream inputStream; try { inputStream = mContext.getApp... | FormUtils { public JSONObject getFormJson(String formIdentity) { if (mContext != null) { try { String locale = mContext.getResources().getConfiguration().locale.getLanguage(); locale = locale.equalsIgnoreCase(Locale.ENGLISH.getLanguage()) ? "" : "-" + locale; InputStream inputStream; try { inputStream = mContext.getApp... | FormUtils { public JSONObject getFormJson(String formIdentity) { if (mContext != null) { try { String locale = mContext.getResources().getConfiguration().locale.getLanguage(); locale = locale.equalsIgnoreCase(Locale.ENGLISH.getLanguage()) ? "" : "-" + locale; InputStream inputStream; try { inputStream = mContext.getApp... | FormUtils { public JSONObject getFormJson(String formIdentity) { if (mContext != null) { try { String locale = mContext.getResources().getConfiguration().locale.getLanguage(); locale = locale.equalsIgnoreCase(Locale.ENGLISH.getLanguage()) ? "" : "-" + locale; InputStream inputStream; try { inputStream = mContext.getApp... |
@Test public void testGenerateRandomPassphraseGeneratesAlphanumericArray() { char[] value = SecurityHelper.generateRandomPassphrase(); Assert.assertNotNull(value); Assert.assertTrue(StringUtils.isAlphanumeric(new StringBuilder().append(value).toString())); Assert.assertEquals(32, value.length); } | public static char[] generateRandomPassphrase() { return RandomStringUtils.randomAlphanumeric(PASSPHRASE_SIZE).toCharArray(); } | SecurityHelper { public static char[] generateRandomPassphrase() { return RandomStringUtils.randomAlphanumeric(PASSPHRASE_SIZE).toCharArray(); } } | SecurityHelper { public static char[] generateRandomPassphrase() { return RandomStringUtils.randomAlphanumeric(PASSPHRASE_SIZE).toCharArray(); } } | SecurityHelper { public static char[] generateRandomPassphrase() { return RandomStringUtils.randomAlphanumeric(PASSPHRASE_SIZE).toCharArray(); } static char[] readValue(Editable editable); static void clearArray(byte[] array); static void clearArray(char[] array); static byte[] toBytes(StringBuffer stringBuffer); stat... | SecurityHelper { public static char[] generateRandomPassphrase() { return RandomStringUtils.randomAlphanumeric(PASSPHRASE_SIZE).toCharArray(); } static char[] readValue(Editable editable); static void clearArray(byte[] array); static void clearArray(char[] array); static byte[] toBytes(StringBuffer stringBuffer); stat... |
@Test public void initP2pLibrary() { String expectedUsername = "nurse1"; String expectedTeamIdPassword = "908980dslkjfljsdlf"; Mockito.doReturn(RuntimeEnvironment.application) .when(context) .applicationContext(); AllSharedPreferences allSharedPreferences = new AllSharedPreferences( PreferenceManager.getDefaultSharedPr... | public void initP2pLibrary(@Nullable String username) { if (p2POptions != null && p2POptions.isEnableP2PLibrary()) { String p2pUsername = username; AllSharedPreferences allSharedPreferences = new AllSharedPreferences(getDefaultSharedPreferences(context.applicationContext())); if (p2pUsername == null) { p2pUsername = al... | CoreLibrary implements OnAccountsUpdateListener { public void initP2pLibrary(@Nullable String username) { if (p2POptions != null && p2POptions.isEnableP2PLibrary()) { String p2pUsername = username; AllSharedPreferences allSharedPreferences = new AllSharedPreferences(getDefaultSharedPreferences(context.applicationContex... | CoreLibrary implements OnAccountsUpdateListener { public void initP2pLibrary(@Nullable String username) { if (p2POptions != null && p2POptions.isEnableP2PLibrary()) { String p2pUsername = username; AllSharedPreferences allSharedPreferences = new AllSharedPreferences(getDefaultSharedPreferences(context.applicationContex... | CoreLibrary implements OnAccountsUpdateListener { public void initP2pLibrary(@Nullable String username) { if (p2POptions != null && p2POptions.isEnableP2PLibrary()) { String p2pUsername = username; AllSharedPreferences allSharedPreferences = new AllSharedPreferences(getDefaultSharedPreferences(context.applicationContex... | CoreLibrary implements OnAccountsUpdateListener { public void initP2pLibrary(@Nullable String username) { if (p2POptions != null && p2POptions.isEnableP2PLibrary()) { String p2pUsername = username; AllSharedPreferences allSharedPreferences = new AllSharedPreferences(getDefaultSharedPreferences(context.applicationContex... |
@Test public void testAddOrUpdateShouldAdd() { Campaign campaign = gson.fromJson(campaignJson, Campaign.class); campaignRepository.addOrUpdate(campaign); verify(sqLiteDatabase).replace(stringArgumentCaptor.capture(), stringArgumentCaptor.capture(), contentValuesArgumentCaptor.capture()); assertEquals(2, stringArgumentC... | public void addOrUpdate(Campaign campaign) { if (StringUtils.isBlank(campaign.getIdentifier())) throw new IllegalArgumentException("Identifier must be specified"); ContentValues contentValues = new ContentValues(); contentValues.put(ID, campaign.getIdentifier()); contentValues.put(TITLE, campaign.getTitle()); contentVa... | CampaignRepository extends BaseRepository { public void addOrUpdate(Campaign campaign) { if (StringUtils.isBlank(campaign.getIdentifier())) throw new IllegalArgumentException("Identifier must be specified"); ContentValues contentValues = new ContentValues(); contentValues.put(ID, campaign.getIdentifier()); contentValue... | CampaignRepository extends BaseRepository { public void addOrUpdate(Campaign campaign) { if (StringUtils.isBlank(campaign.getIdentifier())) throw new IllegalArgumentException("Identifier must be specified"); ContentValues contentValues = new ContentValues(); contentValues.put(ID, campaign.getIdentifier()); contentValue... | CampaignRepository extends BaseRepository { public void addOrUpdate(Campaign campaign) { if (StringUtils.isBlank(campaign.getIdentifier())) throw new IllegalArgumentException("Identifier must be specified"); ContentValues contentValues = new ContentValues(); contentValues.put(ID, campaign.getIdentifier()); contentValue... | CampaignRepository extends BaseRepository { public void addOrUpdate(Campaign campaign) { if (StringUtils.isBlank(campaign.getIdentifier())) throw new IllegalArgumentException("Identifier must be specified"); ContentValues contentValues = new ContentValues(); contentValues.put(ID, campaign.getIdentifier()); contentValue... |
@Test(expected = IllegalArgumentException.class) public void testAddOrUpdateShouldThrowException() { Campaign campaign = new Campaign(); campaignRepository.addOrUpdate(campaign); } | public void addOrUpdate(Campaign campaign) { if (StringUtils.isBlank(campaign.getIdentifier())) throw new IllegalArgumentException("Identifier must be specified"); ContentValues contentValues = new ContentValues(); contentValues.put(ID, campaign.getIdentifier()); contentValues.put(TITLE, campaign.getTitle()); contentVa... | CampaignRepository extends BaseRepository { public void addOrUpdate(Campaign campaign) { if (StringUtils.isBlank(campaign.getIdentifier())) throw new IllegalArgumentException("Identifier must be specified"); ContentValues contentValues = new ContentValues(); contentValues.put(ID, campaign.getIdentifier()); contentValue... | CampaignRepository extends BaseRepository { public void addOrUpdate(Campaign campaign) { if (StringUtils.isBlank(campaign.getIdentifier())) throw new IllegalArgumentException("Identifier must be specified"); ContentValues contentValues = new ContentValues(); contentValues.put(ID, campaign.getIdentifier()); contentValue... | CampaignRepository extends BaseRepository { public void addOrUpdate(Campaign campaign) { if (StringUtils.isBlank(campaign.getIdentifier())) throw new IllegalArgumentException("Identifier must be specified"); ContentValues contentValues = new ContentValues(); contentValues.put(ID, campaign.getIdentifier()); contentValue... | CampaignRepository extends BaseRepository { public void addOrUpdate(Campaign campaign) { if (StringUtils.isBlank(campaign.getIdentifier())) throw new IllegalArgumentException("Identifier must be specified"); ContentValues contentValues = new ContentValues(); contentValues.put(ID, campaign.getIdentifier()); contentValue... |
@Test public void tesGetCampaignsAllCampaigns() { when(sqLiteDatabase.rawQuery("SELECT * FROM " + CAMPAIGN_TABLE, null)).thenReturn(getCursor()); List<Campaign> allCampaigns = campaignRepository.getAllCampaigns(); verify(sqLiteDatabase).rawQuery("SELECT * FROM " + CAMPAIGN_TABLE, null); assertEquals(1, allCampaigns.siz... | public List<Campaign> getAllCampaigns() { Cursor cursor = null; List<Campaign> campaigns = new ArrayList<>(); try { cursor = getReadableDatabase().rawQuery("SELECT * FROM " + CAMPAIGN_TABLE, null); while (cursor.moveToNext()) { campaigns.add(readCursor(cursor)); } cursor.close(); } catch (Exception e) { Timber.e(e); } ... | CampaignRepository extends BaseRepository { public List<Campaign> getAllCampaigns() { Cursor cursor = null; List<Campaign> campaigns = new ArrayList<>(); try { cursor = getReadableDatabase().rawQuery("SELECT * FROM " + CAMPAIGN_TABLE, null); while (cursor.moveToNext()) { campaigns.add(readCursor(cursor)); } cursor.clos... | CampaignRepository extends BaseRepository { public List<Campaign> getAllCampaigns() { Cursor cursor = null; List<Campaign> campaigns = new ArrayList<>(); try { cursor = getReadableDatabase().rawQuery("SELECT * FROM " + CAMPAIGN_TABLE, null); while (cursor.moveToNext()) { campaigns.add(readCursor(cursor)); } cursor.clos... | CampaignRepository extends BaseRepository { public List<Campaign> getAllCampaigns() { Cursor cursor = null; List<Campaign> campaigns = new ArrayList<>(); try { cursor = getReadableDatabase().rawQuery("SELECT * FROM " + CAMPAIGN_TABLE, null); while (cursor.moveToNext()) { campaigns.add(readCursor(cursor)); } cursor.clos... | CampaignRepository extends BaseRepository { public List<Campaign> getAllCampaigns() { Cursor cursor = null; List<Campaign> campaigns = new ArrayList<>(); try { cursor = getReadableDatabase().rawQuery("SELECT * FROM " + CAMPAIGN_TABLE, null); while (cursor.moveToNext()) { campaigns.add(readCursor(cursor)); } cursor.clos... |
@Test public void testGetCampaignByIdentifier() { when(sqLiteDatabase.rawQuery("SELECT * FROM campaign WHERE _id =?", new String[]{"IRS_2018_S1"})).thenReturn(getCursor()); Campaign campaign = campaignRepository.getCampaignByIdentifier("IRS_2018_S1"); verify(sqLiteDatabase).rawQuery(stringArgumentCaptor.capture(), args... | public Campaign getCampaignByIdentifier(String identifier) { Cursor cursor = null; try { cursor = getReadableDatabase().rawQuery("SELECT * FROM " + CAMPAIGN_TABLE + " WHERE " + ID + " =?", new String[]{identifier}); if (cursor.moveToFirst()) { return readCursor(cursor); } } catch (Exception e) { Timber.e(e); } finally ... | CampaignRepository extends BaseRepository { public Campaign getCampaignByIdentifier(String identifier) { Cursor cursor = null; try { cursor = getReadableDatabase().rawQuery("SELECT * FROM " + CAMPAIGN_TABLE + " WHERE " + ID + " =?", new String[]{identifier}); if (cursor.moveToFirst()) { return readCursor(cursor); } } c... | CampaignRepository extends BaseRepository { public Campaign getCampaignByIdentifier(String identifier) { Cursor cursor = null; try { cursor = getReadableDatabase().rawQuery("SELECT * FROM " + CAMPAIGN_TABLE + " WHERE " + ID + " =?", new String[]{identifier}); if (cursor.moveToFirst()) { return readCursor(cursor); } } c... | CampaignRepository extends BaseRepository { public Campaign getCampaignByIdentifier(String identifier) { Cursor cursor = null; try { cursor = getReadableDatabase().rawQuery("SELECT * FROM " + CAMPAIGN_TABLE + " WHERE " + ID + " =?", new String[]{identifier}); if (cursor.moveToFirst()) { return readCursor(cursor); } } c... | CampaignRepository extends BaseRepository { public Campaign getCampaignByIdentifier(String identifier) { Cursor cursor = null; try { cursor = getReadableDatabase().rawQuery("SELECT * FROM " + CAMPAIGN_TABLE + " WHERE " + ID + " =?", new String[]{identifier}); if (cursor.moveToFirst()) { return readCursor(cursor); } } c... |
@Test public void testAddOrUpdateShouldAdd() { Note note = new Note(); note.setText("Should be completed by End of November"); Long now = System.currentTimeMillis(); note.setTime(new DateTime(now)); note.setAuthorString("jdoe"); taskNotesRepository.addOrUpdate(note, "task22132"); verify(sqLiteDatabase).replace(stringAr... | public void addOrUpdate(Note note, String taskId) { if (StringUtils.isBlank(taskId)) { throw new IllegalArgumentException("taskId must be specified"); } ContentValues contentValues = new ContentValues(); contentValues.put(TASK_ID, taskId); contentValues.put(AUTHOR, note.getAuthorString()); contentValues.put(TIME, note.... | TaskNotesRepository extends BaseRepository { public void addOrUpdate(Note note, String taskId) { if (StringUtils.isBlank(taskId)) { throw new IllegalArgumentException("taskId must be specified"); } ContentValues contentValues = new ContentValues(); contentValues.put(TASK_ID, taskId); contentValues.put(AUTHOR, note.getA... | TaskNotesRepository extends BaseRepository { public void addOrUpdate(Note note, String taskId) { if (StringUtils.isBlank(taskId)) { throw new IllegalArgumentException("taskId must be specified"); } ContentValues contentValues = new ContentValues(); contentValues.put(TASK_ID, taskId); contentValues.put(AUTHOR, note.getA... | TaskNotesRepository extends BaseRepository { public void addOrUpdate(Note note, String taskId) { if (StringUtils.isBlank(taskId)) { throw new IllegalArgumentException("taskId must be specified"); } ContentValues contentValues = new ContentValues(); contentValues.put(TASK_ID, taskId); contentValues.put(AUTHOR, note.getA... | TaskNotesRepository extends BaseRepository { public void addOrUpdate(Note note, String taskId) { if (StringUtils.isBlank(taskId)) { throw new IllegalArgumentException("taskId must be specified"); } ContentValues contentValues = new ContentValues(); contentValues.put(TASK_ID, taskId); contentValues.put(AUTHOR, note.getA... |
@Test public void tesGetTasksAllTasks() { when(sqLiteDatabase.rawQuery("SELECT * FROM task_note WHERE task_id =?", new String[]{"task22132"})).thenReturn(getCursor()); List<Note> notes = taskNotesRepository.getNotesByTask("task22132"); verify(sqLiteDatabase).rawQuery("SELECT * FROM task_note WHERE task_id =?", new Stri... | public List<Note> getNotesByTask(String taskId) { List<Note> notes = new ArrayList<>(); Cursor cursor = null; try { cursor = getReadableDatabase().rawQuery("SELECT * FROM " + TASK_NOTES_TABLE + " WHERE " + TASK_ID + " =?", new String[]{taskId}); while (cursor.moveToNext()) { notes.add(readCursor(cursor)); } } catch (Ex... | TaskNotesRepository extends BaseRepository { public List<Note> getNotesByTask(String taskId) { List<Note> notes = new ArrayList<>(); Cursor cursor = null; try { cursor = getReadableDatabase().rawQuery("SELECT * FROM " + TASK_NOTES_TABLE + " WHERE " + TASK_ID + " =?", new String[]{taskId}); while (cursor.moveToNext()) {... | TaskNotesRepository extends BaseRepository { public List<Note> getNotesByTask(String taskId) { List<Note> notes = new ArrayList<>(); Cursor cursor = null; try { cursor = getReadableDatabase().rawQuery("SELECT * FROM " + TASK_NOTES_TABLE + " WHERE " + TASK_ID + " =?", new String[]{taskId}); while (cursor.moveToNext()) {... | TaskNotesRepository extends BaseRepository { public List<Note> getNotesByTask(String taskId) { List<Note> notes = new ArrayList<>(); Cursor cursor = null; try { cursor = getReadableDatabase().rawQuery("SELECT * FROM " + TASK_NOTES_TABLE + " WHERE " + TASK_ID + " =?", new String[]{taskId}); while (cursor.moveToNext()) {... | TaskNotesRepository extends BaseRepository { public List<Note> getNotesByTask(String taskId) { List<Note> notes = new ArrayList<>(); Cursor cursor = null; try { cursor = getReadableDatabase().rawQuery("SELECT * FROM " + TASK_NOTES_TABLE + " WHERE " + TASK_ID + " =?", new String[]{taskId}); while (cursor.moveToNext()) {... |
@Test public void testAddOrUpdateShouldAdd() { Task task = gson.fromJson(taskJson, Task.class); taskRepository.addOrUpdate(task); verify(sqLiteDatabase).replace(stringArgumentCaptor.capture(), stringArgumentCaptor.capture(), contentValuesArgumentCaptor.capture()); Iterator<String> iterator = stringArgumentCaptor.getAll... | public void addOrUpdate(Task task) { addOrUpdate(task, false); } | TaskRepository extends BaseRepository { public void addOrUpdate(Task task) { addOrUpdate(task, false); } } | TaskRepository extends BaseRepository { public void addOrUpdate(Task task) { addOrUpdate(task, false); } TaskRepository(TaskNotesRepository taskNotesRepository); } | TaskRepository extends BaseRepository { public void addOrUpdate(Task task) { addOrUpdate(task, false); } TaskRepository(TaskNotesRepository taskNotesRepository); static void createTable(SQLiteDatabase database); void addOrUpdate(Task task); void addOrUpdate(Task task, boolean updateOnly); Map<String, Set<Task>> getTask... | TaskRepository extends BaseRepository { public void addOrUpdate(Task task) { addOrUpdate(task, false); } TaskRepository(TaskNotesRepository taskNotesRepository); static void createTable(SQLiteDatabase database); void addOrUpdate(Task task); void addOrUpdate(Task task, boolean updateOnly); Map<String, Set<Task>> getTask... |
@Test(expected = IllegalArgumentException.class) public void testAddOrUpdateShouldThrowException() { Task task = new Task(); taskRepository.addOrUpdate(task); } | public void addOrUpdate(Task task) { addOrUpdate(task, false); } | TaskRepository extends BaseRepository { public void addOrUpdate(Task task) { addOrUpdate(task, false); } } | TaskRepository extends BaseRepository { public void addOrUpdate(Task task) { addOrUpdate(task, false); } TaskRepository(TaskNotesRepository taskNotesRepository); } | TaskRepository extends BaseRepository { public void addOrUpdate(Task task) { addOrUpdate(task, false); } TaskRepository(TaskNotesRepository taskNotesRepository); static void createTable(SQLiteDatabase database); void addOrUpdate(Task task); void addOrUpdate(Task task, boolean updateOnly); Map<String, Set<Task>> getTask... | TaskRepository extends BaseRepository { public void addOrUpdate(Task task) { addOrUpdate(task, false); } TaskRepository(TaskNotesRepository taskNotesRepository); static void createTable(SQLiteDatabase database); void addOrUpdate(Task task); void addOrUpdate(Task task, boolean updateOnly); Map<String, Set<Task>> getTask... |
@Test public void getIndexForFormNameShouldReturnCorrectIndex() { String[] formNames = new String[] {"Birth Reg", "Immunisation Reg", "Death Form"}; Assert.assertEquals(1, formUtils.getIndexForFormName("Immunisation Reg", formNames)); } | public static int getIndexForFormName(String formName, String[] formNames) { for (int i = 0; i < formNames.length; i++) { if (formName.equalsIgnoreCase(formNames[i])) { return i; } } return -1; } | FormUtils { public static int getIndexForFormName(String formName, String[] formNames) { for (int i = 0; i < formNames.length; i++) { if (formName.equalsIgnoreCase(formNames[i])) { return i; } } return -1; } } | FormUtils { public static int getIndexForFormName(String formName, String[] formNames) { for (int i = 0; i < formNames.length; i++) { if (formName.equalsIgnoreCase(formNames[i])) { return i; } } return -1; } FormUtils(Context context); } | FormUtils { public static int getIndexForFormName(String formName, String[] formNames) { for (int i = 0; i < formNames.length; i++) { if (formName.equalsIgnoreCase(formNames[i])) { return i; } } return -1; } FormUtils(Context context); static FormUtils getInstance(Context ctx); static boolean hasChildElements(Node elem... | FormUtils { public static int getIndexForFormName(String formName, String[] formNames) { for (int i = 0; i < formNames.length; i++) { if (formName.equalsIgnoreCase(formNames[i])) { return i; } } return -1; } FormUtils(Context context); static FormUtils getInstance(Context ctx); static boolean hasChildElements(Node elem... |
@Test public void testGetTasksByPlanAndGroup() { when(sqLiteDatabase.rawQuery("SELECT * FROM task WHERE plan_id=? AND group_id =? AND status NOT IN (?,?)", new String[]{"IRS_2018_S1", "2018_IRS-3734", CANCELLED.name(), ARCHIVED.name()})).thenReturn(getCursor()); Map<String, Set<Task>> allTasks = taskRepository.getTasks... | public Map<String, Set<Task>> getTasksByPlanAndGroup(String planId, String groupId) { Cursor cursor = null; Map<String, Set<Task>> tasks = new HashMap<>(); try { String[] params = new String[]{planId, groupId}; cursor = getReadableDatabase().rawQuery(String.format("SELECT * FROM %s WHERE %s=? AND %s =? AND %s NOT IN (%... | TaskRepository extends BaseRepository { public Map<String, Set<Task>> getTasksByPlanAndGroup(String planId, String groupId) { Cursor cursor = null; Map<String, Set<Task>> tasks = new HashMap<>(); try { String[] params = new String[]{planId, groupId}; cursor = getReadableDatabase().rawQuery(String.format("SELECT * FROM ... | TaskRepository extends BaseRepository { public Map<String, Set<Task>> getTasksByPlanAndGroup(String planId, String groupId) { Cursor cursor = null; Map<String, Set<Task>> tasks = new HashMap<>(); try { String[] params = new String[]{planId, groupId}; cursor = getReadableDatabase().rawQuery(String.format("SELECT * FROM ... | TaskRepository extends BaseRepository { public Map<String, Set<Task>> getTasksByPlanAndGroup(String planId, String groupId) { Cursor cursor = null; Map<String, Set<Task>> tasks = new HashMap<>(); try { String[] params = new String[]{planId, groupId}; cursor = getReadableDatabase().rawQuery(String.format("SELECT * FROM ... | TaskRepository extends BaseRepository { public Map<String, Set<Task>> getTasksByPlanAndGroup(String planId, String groupId) { Cursor cursor = null; Map<String, Set<Task>> tasks = new HashMap<>(); try { String[] params = new String[]{planId, groupId}; cursor = getReadableDatabase().rawQuery(String.format("SELECT * FROM ... |
@Test public void testGetTasksByEntityAndCode() { when(sqLiteDatabase.rawQuery("SELECT * FROM task WHERE plan_id=? AND group_id =? AND for =? AND code =? AND status NOT IN (?,?)", new String[]{"IRS_2018_S1", "2018_IRS-3734", "location.properties.uid:41587456-b7c8-4c4e-b433-23a786f742fc", "IRS", CANCELLED.name(), ARCHIV... | public Set<Task> getTasksByEntityAndCode(String planId, String groupId, String forEntity, String code) { return getTasks(String.format("SELECT * FROM %s WHERE %s=? AND %s =? AND %s =? AND %s =? AND %s NOT IN (%s)", TASK_TABLE, PLAN_ID, GROUP_ID, FOR, CODE, STATUS, TextUtils.join(",", Collections.nCopies(INACTIVE_TASK_S... | TaskRepository extends BaseRepository { public Set<Task> getTasksByEntityAndCode(String planId, String groupId, String forEntity, String code) { return getTasks(String.format("SELECT * FROM %s WHERE %s=? AND %s =? AND %s =? AND %s =? AND %s NOT IN (%s)", TASK_TABLE, PLAN_ID, GROUP_ID, FOR, CODE, STATUS, TextUtils.join(... | TaskRepository extends BaseRepository { public Set<Task> getTasksByEntityAndCode(String planId, String groupId, String forEntity, String code) { return getTasks(String.format("SELECT * FROM %s WHERE %s=? AND %s =? AND %s =? AND %s =? AND %s NOT IN (%s)", TASK_TABLE, PLAN_ID, GROUP_ID, FOR, CODE, STATUS, TextUtils.join(... | TaskRepository extends BaseRepository { public Set<Task> getTasksByEntityAndCode(String planId, String groupId, String forEntity, String code) { return getTasks(String.format("SELECT * FROM %s WHERE %s=? AND %s =? AND %s =? AND %s =? AND %s NOT IN (%s)", TASK_TABLE, PLAN_ID, GROUP_ID, FOR, CODE, STATUS, TextUtils.join(... | TaskRepository extends BaseRepository { public Set<Task> getTasksByEntityAndCode(String planId, String groupId, String forEntity, String code) { return getTasks(String.format("SELECT * FROM %s WHERE %s=? AND %s =? AND %s =? AND %s =? AND %s NOT IN (%s)", TASK_TABLE, PLAN_ID, GROUP_ID, FOR, CODE, STATUS, TextUtils.join(... |
@Test public void testGetTaskByIdentifier() { when(sqLiteDatabase.rawQuery("SELECT * FROM task WHERE _id =?", new String[]{"tsk11231jh22"})).thenReturn(getCursor()); Task task = taskRepository.getTaskByIdentifier("tsk11231jh22"); verify(sqLiteDatabase).rawQuery(stringArgumentCaptor.capture(), argsCaptor.capture()); ass... | public Task getTaskByIdentifier(String identifier) { try (Cursor cursor = getReadableDatabase().rawQuery("SELECT * FROM " + TASK_TABLE + " WHERE " + ID + " =?", new String[]{identifier})) { if (cursor.moveToFirst()) { return readCursor(cursor); } } catch (Exception e) { Timber.e(e); } return null; } | TaskRepository extends BaseRepository { public Task getTaskByIdentifier(String identifier) { try (Cursor cursor = getReadableDatabase().rawQuery("SELECT * FROM " + TASK_TABLE + " WHERE " + ID + " =?", new String[]{identifier})) { if (cursor.moveToFirst()) { return readCursor(cursor); } } catch (Exception e) { Timber.e(... | TaskRepository extends BaseRepository { public Task getTaskByIdentifier(String identifier) { try (Cursor cursor = getReadableDatabase().rawQuery("SELECT * FROM " + TASK_TABLE + " WHERE " + ID + " =?", new String[]{identifier})) { if (cursor.moveToFirst()) { return readCursor(cursor); } } catch (Exception e) { Timber.e(... | TaskRepository extends BaseRepository { public Task getTaskByIdentifier(String identifier) { try (Cursor cursor = getReadableDatabase().rawQuery("SELECT * FROM " + TASK_TABLE + " WHERE " + ID + " =?", new String[]{identifier})) { if (cursor.moveToFirst()) { return readCursor(cursor); } } catch (Exception e) { Timber.e(... | TaskRepository extends BaseRepository { public Task getTaskByIdentifier(String identifier) { try (Cursor cursor = getReadableDatabase().rawQuery("SELECT * FROM " + TASK_TABLE + " WHERE " + ID + " =?", new String[]{identifier})) { if (cursor.moveToFirst()) { return readCursor(cursor); } } catch (Exception e) { Timber.e(... |
@Test public void testGetUnSyncedTaskStatus() { taskRepository.getUnSyncedTaskStatus(); verify(sqLiteDatabase).rawQuery(stringArgumentCaptor.capture(), argsCaptor.capture()); assertNotNull(taskRepository.getUnSyncedTaskStatus()); } | public List<TaskUpdate> getUnSyncedTaskStatus() { Cursor cursor = null; List<TaskUpdate> taskUpdates = new ArrayList<>(); try { cursor = getReadableDatabase().rawQuery(String.format("SELECT " + ID + "," + STATUS + "," + BUSINESS_STATUS + "," + SERVER_VERSION + " FROM %s WHERE %s =?", TASK_TABLE, SYNC_STATUS), new Strin... | TaskRepository extends BaseRepository { public List<TaskUpdate> getUnSyncedTaskStatus() { Cursor cursor = null; List<TaskUpdate> taskUpdates = new ArrayList<>(); try { cursor = getReadableDatabase().rawQuery(String.format("SELECT " + ID + "," + STATUS + "," + BUSINESS_STATUS + "," + SERVER_VERSION + " FROM %s WHERE %s ... | TaskRepository extends BaseRepository { public List<TaskUpdate> getUnSyncedTaskStatus() { Cursor cursor = null; List<TaskUpdate> taskUpdates = new ArrayList<>(); try { cursor = getReadableDatabase().rawQuery(String.format("SELECT " + ID + "," + STATUS + "," + BUSINESS_STATUS + "," + SERVER_VERSION + " FROM %s WHERE %s ... | TaskRepository extends BaseRepository { public List<TaskUpdate> getUnSyncedTaskStatus() { Cursor cursor = null; List<TaskUpdate> taskUpdates = new ArrayList<>(); try { cursor = getReadableDatabase().rawQuery(String.format("SELECT " + ID + "," + STATUS + "," + BUSINESS_STATUS + "," + SERVER_VERSION + " FROM %s WHERE %s ... | TaskRepository extends BaseRepository { public List<TaskUpdate> getUnSyncedTaskStatus() { Cursor cursor = null; List<TaskUpdate> taskUpdates = new ArrayList<>(); try { cursor = getReadableDatabase().rawQuery(String.format("SELECT " + ID + "," + STATUS + "," + BUSINESS_STATUS + "," + SERVER_VERSION + " FROM %s WHERE %s ... |
@Test public void testUpdateTaskStructureIdFromClient() throws Exception { List<Client> clients = new ArrayList<>(); Client client = gson.fromJson(clientJson, Client.class); clients.add(client); taskRepository.updateTaskStructureIdFromClient(clients, ""); assertNotNull(taskRepository.getUnSyncedTaskStatus()); } | public boolean updateTaskStructureIdFromClient(List<Client> clients, String attribute) { if (clients == null || clients.isEmpty()) { return false; } SQLiteStatement updateStatement = null; try { getWritableDatabase().beginTransaction(); String updateTaskSructureIdQuery = String.format("UPDATE %s SET %s = ? WHERE %s = ?... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdFromClient(List<Client> clients, String attribute) { if (clients == null || clients.isEmpty()) { return false; } SQLiteStatement updateStatement = null; try { getWritableDatabase().beginTransaction(); String updateTaskSructureIdQuery = String.f... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdFromClient(List<Client> clients, String attribute) { if (clients == null || clients.isEmpty()) { return false; } SQLiteStatement updateStatement = null; try { getWritableDatabase().beginTransaction(); String updateTaskSructureIdQuery = String.f... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdFromClient(List<Client> clients, String attribute) { if (clients == null || clients.isEmpty()) { return false; } SQLiteStatement updateStatement = null; try { getWritableDatabase().beginTransaction(); String updateTaskSructureIdQuery = String.f... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdFromClient(List<Client> clients, String attribute) { if (clients == null || clients.isEmpty()) { return false; } SQLiteStatement updateStatement = null; try { getWritableDatabase().beginTransaction(); String updateTaskSructureIdQuery = String.f... |
@Test public void updateTaskStructureIdFromStructure() throws Exception { List<Location> locations = new ArrayList<>(); Location location = gson.fromJson(structureJson, Location.class); locations.add(location); taskRepository.updateTaskStructureIdFromStructure(locations); assertTrue(taskRepository.updateTaskStructureId... | public boolean updateTaskStructureIdFromStructure(List<Location> locations) { if (locations == null || locations.isEmpty()) { return false; } SQLiteStatement updateStatement = null; try { getWritableDatabase().beginTransaction(); String updateTaskSructureIdQuery = String.format("UPDATE %s SET %s = ? WHERE %s = ? AND %s... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdFromStructure(List<Location> locations) { if (locations == null || locations.isEmpty()) { return false; } SQLiteStatement updateStatement = null; try { getWritableDatabase().beginTransaction(); String updateTaskSructureIdQuery = String.format("... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdFromStructure(List<Location> locations) { if (locations == null || locations.isEmpty()) { return false; } SQLiteStatement updateStatement = null; try { getWritableDatabase().beginTransaction(); String updateTaskSructureIdQuery = String.format("... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdFromStructure(List<Location> locations) { if (locations == null || locations.isEmpty()) { return false; } SQLiteStatement updateStatement = null; try { getWritableDatabase().beginTransaction(); String updateTaskSructureIdQuery = String.format("... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdFromStructure(List<Location> locations) { if (locations == null || locations.isEmpty()) { return false; } SQLiteStatement updateStatement = null; try { getWritableDatabase().beginTransaction(); String updateTaskSructureIdQuery = String.format("... |
@Test public void testCancelTasksForEntity() { taskRepository.cancelTasksForEntity("id1"); verify(sqLiteDatabase).update(eq(TASK_TABLE), contentValuesArgumentCaptor.capture(), eq("for = ? AND status =?"), eq(new String[]{"id1", READY.name()})); assertEquals(BaseRepository.TYPE_Unsynced, contentValuesArgumentCaptor.getV... | public void cancelTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.CANCELLED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWritableDatabase().update(TASK_TABLE, conten... | TaskRepository extends BaseRepository { public void cancelTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.CANCELLED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWrit... | TaskRepository extends BaseRepository { public void cancelTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.CANCELLED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWrit... | TaskRepository extends BaseRepository { public void cancelTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.CANCELLED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWrit... | TaskRepository extends BaseRepository { public void cancelTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.CANCELLED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWrit... |
@Test public void testCancelTasksForEntityWithNullParams() { taskRepository.cancelTasksForEntity(null); verify(sqLiteDatabase, never()).update(any(), any(), any(), any()); verifyZeroInteractions(sqLiteDatabase); } | public void cancelTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.CANCELLED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWritableDatabase().update(TASK_TABLE, conten... | TaskRepository extends BaseRepository { public void cancelTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.CANCELLED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWrit... | TaskRepository extends BaseRepository { public void cancelTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.CANCELLED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWrit... | TaskRepository extends BaseRepository { public void cancelTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.CANCELLED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWrit... | TaskRepository extends BaseRepository { public void cancelTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.CANCELLED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWrit... |
@Test public void testArchiveTasksForEntity() { taskRepository.archiveTasksForEntity("id1"); verify(sqLiteDatabase).update(eq(TASK_TABLE), contentValuesArgumentCaptor.capture(), eq("for = ? AND status NOT IN (?,?)"), eq(new String[]{"id1", READY.name(), CANCELLED.name()})); assertEquals(BaseRepository.TYPE_Unsynced, co... | public void archiveTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.ARCHIVED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWritableDatabase().update(TASK_TABLE, conten... | TaskRepository extends BaseRepository { public void archiveTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.ARCHIVED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWrit... | TaskRepository extends BaseRepository { public void archiveTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.ARCHIVED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWrit... | TaskRepository extends BaseRepository { public void archiveTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.ARCHIVED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWrit... | TaskRepository extends BaseRepository { public void archiveTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.ARCHIVED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWrit... |
@Test public void testArchiveTasksForEntityWithNullParams() { taskRepository.archiveTasksForEntity(null); verifyZeroInteractions(sqLiteDatabase); } | public void archiveTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.ARCHIVED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWritableDatabase().update(TASK_TABLE, conten... | TaskRepository extends BaseRepository { public void archiveTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.ARCHIVED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWrit... | TaskRepository extends BaseRepository { public void archiveTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.ARCHIVED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWrit... | TaskRepository extends BaseRepository { public void archiveTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.ARCHIVED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWrit... | TaskRepository extends BaseRepository { public void archiveTasksForEntity(@NonNull String entityId) { if (StringUtils.isBlank(entityId)) return; ContentValues contentValues = new ContentValues(); contentValues.put(STATUS, TaskStatus.ARCHIVED.name()); contentValues.put(SYNC_STATUS, BaseRepository.TYPE_Unsynced); getWrit... |
@Test public void assertServiceConstructorInitializationNotNull() throws Exception { PowerMockito.mockStatic(Volley.class); PowerMockito.when(Volley.newRequestQueue(Mockito.any(android.content.Context.class), Mockito.any(HurlStack.class))).thenReturn(Mockito.mock(RequestQueue.class)); OpenSRPImageLoader openSRPImageLoa... | private static RequestQueue newRequestQueue(Context context) { RequestQueue requestQueue; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { HurlStack stack = new HurlStack() { @Override public HttpResponse performRequest(Request<?> request, Map<String, String> headers) throws IOException, AuthFailureError... | OpenSRPImageLoader extends ImageLoader { private static RequestQueue newRequestQueue(Context context) { RequestQueue requestQueue; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { HurlStack stack = new HurlStack() { @Override public HttpResponse performRequest(Request<?> request, Map<String, String> head... | OpenSRPImageLoader extends ImageLoader { private static RequestQueue newRequestQueue(Context context) { RequestQueue requestQueue; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { HurlStack stack = new HurlStack() { @Override public HttpResponse performRequest(Request<?> request, Map<String, String> head... | OpenSRPImageLoader extends ImageLoader { private static RequestQueue newRequestQueue(Context context) { RequestQueue requestQueue; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { HurlStack stack = new HurlStack() { @Override public HttpResponse performRequest(Request<?> request, Map<String, String> head... | OpenSRPImageLoader extends ImageLoader { private static RequestQueue newRequestQueue(Context context) { RequestQueue requestQueue; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { HurlStack stack = new HurlStack() { @Override public HttpResponse performRequest(Request<?> request, Map<String, String> head... |
@Test public void testReadUpdateCursor() { MatrixCursor cursor = getCursor(); cursor.moveToNext(); String expectedIdentifier = cursor.getString(cursor.getColumnIndex("_id")); String expectedStatus = cursor.getString(cursor.getColumnIndex("status")); String expectedBusinessStatus = cursor.getString(cursor.getColumnIndex... | protected TaskUpdate readUpdateCursor(Cursor cursor) { TaskUpdate taskUpdate = new TaskUpdate(); taskUpdate.setIdentifier(cursor.getString(cursor.getColumnIndex(ID))); if (cursor.getString(cursor.getColumnIndex(STATUS)) != null) { taskUpdate.setStatus(cursor.getString(cursor.getColumnIndex(STATUS))); } if (cursor.getSt... | TaskRepository extends BaseRepository { protected TaskUpdate readUpdateCursor(Cursor cursor) { TaskUpdate taskUpdate = new TaskUpdate(); taskUpdate.setIdentifier(cursor.getString(cursor.getColumnIndex(ID))); if (cursor.getString(cursor.getColumnIndex(STATUS)) != null) { taskUpdate.setStatus(cursor.getString(cursor.getC... | TaskRepository extends BaseRepository { protected TaskUpdate readUpdateCursor(Cursor cursor) { TaskUpdate taskUpdate = new TaskUpdate(); taskUpdate.setIdentifier(cursor.getString(cursor.getColumnIndex(ID))); if (cursor.getString(cursor.getColumnIndex(STATUS)) != null) { taskUpdate.setStatus(cursor.getString(cursor.getC... | TaskRepository extends BaseRepository { protected TaskUpdate readUpdateCursor(Cursor cursor) { TaskUpdate taskUpdate = new TaskUpdate(); taskUpdate.setIdentifier(cursor.getString(cursor.getColumnIndex(ID))); if (cursor.getString(cursor.getColumnIndex(STATUS)) != null) { taskUpdate.setStatus(cursor.getString(cursor.getC... | TaskRepository extends BaseRepository { protected TaskUpdate readUpdateCursor(Cursor cursor) { TaskUpdate taskUpdate = new TaskUpdate(); taskUpdate.setIdentifier(cursor.getString(cursor.getColumnIndex(ID))); if (cursor.getString(cursor.getColumnIndex(STATUS)) != null) { taskUpdate.setStatus(cursor.getString(cursor.getC... |
@Test public void testMarkTaskAsSynced() { String expectedTaskIdentifier = "id1"; taskRepository.markTaskAsSynced(expectedTaskIdentifier); verify(sqLiteDatabase).update(stringArgumentCaptor.capture(), contentValuesArgumentCaptor.capture(), stringArgumentCaptor.capture(), stringArrayArgumentCaptor.capture()); Iterator<S... | public void markTaskAsSynced(String taskID) { try { ContentValues values = new ContentValues(); values.put(TaskRepository.ID, taskID); values.put(TaskRepository.SYNC_STATUS, BaseRepository.TYPE_Synced); values.put(TaskRepository.SERVER_VERSION, 0); getWritableDatabase().update(TaskRepository.TASK_TABLE, values, TaskRep... | TaskRepository extends BaseRepository { public void markTaskAsSynced(String taskID) { try { ContentValues values = new ContentValues(); values.put(TaskRepository.ID, taskID); values.put(TaskRepository.SYNC_STATUS, BaseRepository.TYPE_Synced); values.put(TaskRepository.SERVER_VERSION, 0); getWritableDatabase().update(Ta... | TaskRepository extends BaseRepository { public void markTaskAsSynced(String taskID) { try { ContentValues values = new ContentValues(); values.put(TaskRepository.ID, taskID); values.put(TaskRepository.SYNC_STATUS, BaseRepository.TYPE_Synced); values.put(TaskRepository.SERVER_VERSION, 0); getWritableDatabase().update(Ta... | TaskRepository extends BaseRepository { public void markTaskAsSynced(String taskID) { try { ContentValues values = new ContentValues(); values.put(TaskRepository.ID, taskID); values.put(TaskRepository.SYNC_STATUS, BaseRepository.TYPE_Synced); values.put(TaskRepository.SERVER_VERSION, 0); getWritableDatabase().update(Ta... | TaskRepository extends BaseRepository { public void markTaskAsSynced(String taskID) { try { ContentValues values = new ContentValues(); values.put(TaskRepository.ID, taskID); values.put(TaskRepository.SYNC_STATUS, BaseRepository.TYPE_Synced); values.put(TaskRepository.SERVER_VERSION, 0); getWritableDatabase().update(Ta... |
@Test public void testGetAllUnSyncedCreatedTasks() { when(sqLiteDatabase.rawQuery("SELECT * FROM task WHERE sync_status =? OR server_version IS NULL", new String[]{BaseRepository.TYPE_Created})).thenReturn(getCursor()); List<Task> unsyncedCreatedTasks = taskRepository.getAllUnsynchedCreatedTasks(); assertEquals(1, unsy... | public List<Task> getAllUnsynchedCreatedTasks() { return new ArrayList<>(getTasks(String.format("SELECT * FROM %s WHERE %s =? OR %s IS NULL", TASK_TABLE, SYNC_STATUS, SERVER_VERSION), new String[]{BaseRepository.TYPE_Created})); } | TaskRepository extends BaseRepository { public List<Task> getAllUnsynchedCreatedTasks() { return new ArrayList<>(getTasks(String.format("SELECT * FROM %s WHERE %s =? OR %s IS NULL", TASK_TABLE, SYNC_STATUS, SERVER_VERSION), new String[]{BaseRepository.TYPE_Created})); } } | TaskRepository extends BaseRepository { public List<Task> getAllUnsynchedCreatedTasks() { return new ArrayList<>(getTasks(String.format("SELECT * FROM %s WHERE %s =? OR %s IS NULL", TASK_TABLE, SYNC_STATUS, SERVER_VERSION), new String[]{BaseRepository.TYPE_Created})); } TaskRepository(TaskNotesRepository taskNotesRepos... | TaskRepository extends BaseRepository { public List<Task> getAllUnsynchedCreatedTasks() { return new ArrayList<>(getTasks(String.format("SELECT * FROM %s WHERE %s =? OR %s IS NULL", TASK_TABLE, SYNC_STATUS, SERVER_VERSION), new String[]{BaseRepository.TYPE_Created})); } TaskRepository(TaskNotesRepository taskNotesRepos... | TaskRepository extends BaseRepository { public List<Task> getAllUnsynchedCreatedTasks() { return new ArrayList<>(getTasks(String.format("SELECT * FROM %s WHERE %s =? OR %s IS NULL", TASK_TABLE, SYNC_STATUS, SERVER_VERSION), new String[]{BaseRepository.TYPE_Created})); } TaskRepository(TaskNotesRepository taskNotesRepos... |
@Test public void testUpdateTaskStructureIdsFromExistingStructures() { String expectedSql = "UPDATE task SET structure_id =(SELECT _id FROM structure WHERE _id = for) WHERE structure_id IS NULL"; boolean updated = taskRepository.updateTaskStructureIdsFromExistingStructures(); assertTrue(updated); verify(sqLiteDatabase)... | public boolean updateTaskStructureIdsFromExistingStructures() { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM structure WHERE %s = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, ID, ID, FOR, STRUCTURE_ID)); return true; } catch (Exception e) { Timber.e(e); return false; } } | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdsFromExistingStructures() { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM structure WHERE %s = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, ID, ID, FOR, STRUCTURE_ID)); return true; } catch (Exception ... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdsFromExistingStructures() { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM structure WHERE %s = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, ID, ID, FOR, STRUCTURE_ID)); return true; } catch (Exception ... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdsFromExistingStructures() { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM structure WHERE %s = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, ID, ID, FOR, STRUCTURE_ID)); return true; } catch (Exception ... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdsFromExistingStructures() { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM structure WHERE %s = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, ID, ID, FOR, STRUCTURE_ID)); return true; } catch (Exception ... |
@Test public void testUpdateTaskStructureIdsFromExistingStructuresFailure() { String expectedSql = "UPDATE task SET structure_id =(SELECT _id FROM structure WHERE _id = for) WHERE structure_id IS NULL"; doThrow(new SQLiteException()).when(sqLiteDatabase).execSQL(anyString()); boolean updated = taskRepository.updateTask... | public boolean updateTaskStructureIdsFromExistingStructures() { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM structure WHERE %s = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, ID, ID, FOR, STRUCTURE_ID)); return true; } catch (Exception e) { Timber.e(e); return false; } } | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdsFromExistingStructures() { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM structure WHERE %s = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, ID, ID, FOR, STRUCTURE_ID)); return true; } catch (Exception ... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdsFromExistingStructures() { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM structure WHERE %s = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, ID, ID, FOR, STRUCTURE_ID)); return true; } catch (Exception ... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdsFromExistingStructures() { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM structure WHERE %s = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, ID, ID, FOR, STRUCTURE_ID)); return true; } catch (Exception ... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdsFromExistingStructures() { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM structure WHERE %s = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, ID, ID, FOR, STRUCTURE_ID)); return true; } catch (Exception ... |
@Test public void testUpdateTaskStructureIdsfromExistingClients() { String expectedSql = "UPDATE task SET structure_id =(SELECT structure_id FROM ec_family_member WHERE base_entity_id = for) WHERE structure_id IS NULL"; String clientTable = "ec_family_member"; boolean updated = taskRepository.updateTaskStructureIdsFrom... | public boolean updateTaskStructureIdsFromExistingClients(String clientTable) { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM %s WHERE base_entity_id = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, STRUCTURE_ID, clientTable, FOR, STRUCTURE_ID)); return true; } catch (Exception e... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdsFromExistingClients(String clientTable) { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM %s WHERE base_entity_id = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, STRUCTURE_ID, clientTable, FOR, STRUCTURE... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdsFromExistingClients(String clientTable) { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM %s WHERE base_entity_id = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, STRUCTURE_ID, clientTable, FOR, STRUCTURE... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdsFromExistingClients(String clientTable) { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM %s WHERE base_entity_id = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, STRUCTURE_ID, clientTable, FOR, STRUCTURE... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdsFromExistingClients(String clientTable) { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM %s WHERE base_entity_id = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, STRUCTURE_ID, clientTable, FOR, STRUCTURE... |
@Test public void testUpdateTaskStructureIdsfromExistingClientsFailure() { String expectedSql = "UPDATE task SET structure_id =(SELECT structure_id FROM ec_family_member WHERE base_entity_id = for) WHERE structure_id IS NULL"; String clientTable = "ec_family_member"; doThrow(new SQLiteException()).when(sqLiteDatabase).... | public boolean updateTaskStructureIdsFromExistingClients(String clientTable) { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM %s WHERE base_entity_id = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, STRUCTURE_ID, clientTable, FOR, STRUCTURE_ID)); return true; } catch (Exception e... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdsFromExistingClients(String clientTable) { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM %s WHERE base_entity_id = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, STRUCTURE_ID, clientTable, FOR, STRUCTURE... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdsFromExistingClients(String clientTable) { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM %s WHERE base_entity_id = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, STRUCTURE_ID, clientTable, FOR, STRUCTURE... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdsFromExistingClients(String clientTable) { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM %s WHERE base_entity_id = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, STRUCTURE_ID, clientTable, FOR, STRUCTURE... | TaskRepository extends BaseRepository { public boolean updateTaskStructureIdsFromExistingClients(String clientTable) { try { getReadableDatabase().execSQL(String.format("UPDATE %s SET %s =(SELECT %s FROM %s WHERE base_entity_id = %s) WHERE %s IS NULL", TASK_TABLE, STRUCTURE_ID, STRUCTURE_ID, clientTable, FOR, STRUCTURE... |
@Test public void testBatchInsertTasks() throws Exception { Task expectedTask = gson.fromJson(taskJson, Task.class); JSONArray taskArray = new JSONArray().put(new JSONObject(taskJson)); taskRepository = spy(taskRepository); boolean inserted = taskRepository.batchInsertTasks(taskArray); verify(sqLiteDatabase).beginTrans... | public boolean batchInsertTasks(JSONArray array) { if (array == null || array.length() == 0) { return false; } try { getWritableDatabase().beginTransaction(); for (int i = 0; i < array.length(); i++) { JSONObject jsonObject = array.getJSONObject(i); Task task = TaskServiceHelper.taskGson.fromJson(jsonObject.toString(),... | TaskRepository extends BaseRepository { public boolean batchInsertTasks(JSONArray array) { if (array == null || array.length() == 0) { return false; } try { getWritableDatabase().beginTransaction(); for (int i = 0; i < array.length(); i++) { JSONObject jsonObject = array.getJSONObject(i); Task task = TaskServiceHelper.... | TaskRepository extends BaseRepository { public boolean batchInsertTasks(JSONArray array) { if (array == null || array.length() == 0) { return false; } try { getWritableDatabase().beginTransaction(); for (int i = 0; i < array.length(); i++) { JSONObject jsonObject = array.getJSONObject(i); Task task = TaskServiceHelper.... | TaskRepository extends BaseRepository { public boolean batchInsertTasks(JSONArray array) { if (array == null || array.length() == 0) { return false; } try { getWritableDatabase().beginTransaction(); for (int i = 0; i < array.length(); i++) { JSONObject jsonObject = array.getJSONObject(i); Task task = TaskServiceHelper.... | TaskRepository extends BaseRepository { public boolean batchInsertTasks(JSONArray array) { if (array == null || array.length() == 0) { return false; } try { getWritableDatabase().beginTransaction(); for (int i = 0; i < array.length(); i++) { JSONObject jsonObject = array.getJSONObject(i); Task task = TaskServiceHelper.... |
@Test public void testGetTasksByPlanAndEntity() { String query = "SELECT * FROM task WHERE plan_id=? AND for =? AND status NOT IN (?,?)"; when(sqLiteDatabase.rawQuery(query, new String[]{"IRS_2018_S1", "location.properties.uid:41587456-b7c8-4c4e-b433-23a786f742fc", CANCELLED.name(), ARCHIVED.name()})).thenReturn(getCur... | public Set<Task> getTasksByPlanAndEntity(String planId, String forEntity) { return getTasks(String.format("SELECT * FROM %s WHERE %s=? AND %s =? AND %s NOT IN (%s)", TASK_TABLE, PLAN_ID, FOR, STATUS, TextUtils.join(",", Collections.nCopies(INACTIVE_TASK_STATUS.length, "?"))) , ArrayUtils.addAll(new String[]{planId, for... | TaskRepository extends BaseRepository { public Set<Task> getTasksByPlanAndEntity(String planId, String forEntity) { return getTasks(String.format("SELECT * FROM %s WHERE %s=? AND %s =? AND %s NOT IN (%s)", TASK_TABLE, PLAN_ID, FOR, STATUS, TextUtils.join(",", Collections.nCopies(INACTIVE_TASK_STATUS.length, "?"))) , Ar... | TaskRepository extends BaseRepository { public Set<Task> getTasksByPlanAndEntity(String planId, String forEntity) { return getTasks(String.format("SELECT * FROM %s WHERE %s=? AND %s =? AND %s NOT IN (%s)", TASK_TABLE, PLAN_ID, FOR, STATUS, TextUtils.join(",", Collections.nCopies(INACTIVE_TASK_STATUS.length, "?"))) , Ar... | TaskRepository extends BaseRepository { public Set<Task> getTasksByPlanAndEntity(String planId, String forEntity) { return getTasks(String.format("SELECT * FROM %s WHERE %s=? AND %s =? AND %s NOT IN (%s)", TASK_TABLE, PLAN_ID, FOR, STATUS, TextUtils.join(",", Collections.nCopies(INACTIVE_TASK_STATUS.length, "?"))) , Ar... | TaskRepository extends BaseRepository { public Set<Task> getTasksByPlanAndEntity(String planId, String forEntity) { return getTasks(String.format("SELECT * FROM %s WHERE %s=? AND %s =? AND %s NOT IN (%s)", TASK_TABLE, PLAN_ID, FOR, STATUS, TextUtils.join(",", Collections.nCopies(INACTIVE_TASK_STATUS.length, "?"))) , Ar... |
@Test public void shouldSavePreviousFetchIndex() throws Exception { allSettings.savePreviousFetchIndex("1234"); Mockito.verify(settingsRepository).updateSetting("previousFetchIndex", "1234"); } | public void savePreviousFetchIndex(String value) { settingsRepository.updateSetting(PREVIOUS_FETCH_INDEX_SETTING_KEY, value); } | AllSettings { public void savePreviousFetchIndex(String value) { settingsRepository.updateSetting(PREVIOUS_FETCH_INDEX_SETTING_KEY, value); } } | AllSettings { public void savePreviousFetchIndex(String value) { settingsRepository.updateSetting(PREVIOUS_FETCH_INDEX_SETTING_KEY, value); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); } | AllSettings { public void savePreviousFetchIndex(String value) { settingsRepository.updateSetting(PREVIOUS_FETCH_INDEX_SETTING_KEY, value); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); void registerANM(String userName); void savePreviousFetchIndex(String value); String fetchPr... | AllSettings { public void savePreviousFetchIndex(String value) { settingsRepository.updateSetting(PREVIOUS_FETCH_INDEX_SETTING_KEY, value); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); void registerANM(String userName); void savePreviousFetchIndex(String value); String fetchPr... |
@Test public void formatDateReturnsinRequiredFormat() throws Exception { Date date = new Date(); String dateInFormat = dd_MM_yyyy.format(date); SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.sss'Z'"); String dateinFMT = fmt.format(dd_MM_yyyy.parse(dateInFormat)); String returnedDateinString = (JsonF... | public static Date formatDate(String dateString, boolean startOfToday) { try { if (StringUtils.isBlank(dateString)) { return null; } if (dateString.matches("\\d{2}-\\d{2}-\\d{4}")) { return dd_MM_yyyy.parse(dateString); } else if (dateString.matches("\\d{4}-\\d{2}-\\d{2}") || dateString.matches("\\d{4}-\\d{2}-\\d{2} \\... | JsonFormUtils { public static Date formatDate(String dateString, boolean startOfToday) { try { if (StringUtils.isBlank(dateString)) { return null; } if (dateString.matches("\\d{2}-\\d{2}-\\d{4}")) { return dd_MM_yyyy.parse(dateString); } else if (dateString.matches("\\d{4}-\\d{2}-\\d{2}") || dateString.matches("\\d{4}-... | JsonFormUtils { public static Date formatDate(String dateString, boolean startOfToday) { try { if (StringUtils.isBlank(dateString)) { return null; } if (dateString.matches("\\d{2}-\\d{2}-\\d{4}")) { return dd_MM_yyyy.parse(dateString); } else if (dateString.matches("\\d{4}-\\d{2}-\\d{2}") || dateString.matches("\\d{4}-... | JsonFormUtils { public static Date formatDate(String dateString, boolean startOfToday) { try { if (StringUtils.isBlank(dateString)) { return null; } if (dateString.matches("\\d{2}-\\d{2}-\\d{4}")) { return dd_MM_yyyy.parse(dateString); } else if (dateString.matches("\\d{4}-\\d{2}-\\d{2}") || dateString.matches("\\d{4}-... | JsonFormUtils { public static Date formatDate(String dateString, boolean startOfToday) { try { if (StringUtils.isBlank(dateString)) { return null; } if (dateString.matches("\\d{2}-\\d{2}-\\d{4}")) { return dd_MM_yyyy.parse(dateString); } else if (dateString.matches("\\d{4}-\\d{2}-\\d{2}") || dateString.matches("\\d{4}-... |
@Test public void shouldFetchPreviousFetchIndex() throws Exception { Mockito.when(settingsRepository.querySetting("previousFetchIndex", "0")).thenReturn("1234"); String actual = allSettings.fetchPreviousFetchIndex(); Mockito.verify(settingsRepository).querySetting("previousFetchIndex", "0"); Assert.assertEquals("1234",... | public String fetchPreviousFetchIndex() { return settingsRepository.querySetting(PREVIOUS_FETCH_INDEX_SETTING_KEY, "0"); } | AllSettings { public String fetchPreviousFetchIndex() { return settingsRepository.querySetting(PREVIOUS_FETCH_INDEX_SETTING_KEY, "0"); } } | AllSettings { public String fetchPreviousFetchIndex() { return settingsRepository.querySetting(PREVIOUS_FETCH_INDEX_SETTING_KEY, "0"); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); } | AllSettings { public String fetchPreviousFetchIndex() { return settingsRepository.querySetting(PREVIOUS_FETCH_INDEX_SETTING_KEY, "0"); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); void registerANM(String userName); void savePreviousFetchIndex(String value); String fetchPreviou... | AllSettings { public String fetchPreviousFetchIndex() { return settingsRepository.querySetting(PREVIOUS_FETCH_INDEX_SETTING_KEY, "0"); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); void registerANM(String userName); void savePreviousFetchIndex(String value); String fetchPreviou... |
@Test public void shouldSavePreviousFormSyncIndex() throws Exception { allSettings.savePreviousFormSyncIndex("1234"); Mockito.verify(settingsRepository).updateSetting("previousFormSyncIndex", "1234"); } | public void savePreviousFormSyncIndex(String value) { settingsRepository.updateSetting(PREVIOUS_FORM_SYNC_INDEX_SETTING_KEY, value); } | AllSettings { public void savePreviousFormSyncIndex(String value) { settingsRepository.updateSetting(PREVIOUS_FORM_SYNC_INDEX_SETTING_KEY, value); } } | AllSettings { public void savePreviousFormSyncIndex(String value) { settingsRepository.updateSetting(PREVIOUS_FORM_SYNC_INDEX_SETTING_KEY, value); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); } | AllSettings { public void savePreviousFormSyncIndex(String value) { settingsRepository.updateSetting(PREVIOUS_FORM_SYNC_INDEX_SETTING_KEY, value); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); void registerANM(String userName); void savePreviousFetchIndex(String value); String ... | AllSettings { public void savePreviousFormSyncIndex(String value) { settingsRepository.updateSetting(PREVIOUS_FORM_SYNC_INDEX_SETTING_KEY, value); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); void registerANM(String userName); void savePreviousFetchIndex(String value); String ... |
@Test public void shouldFetchPreviousFormSyncIndex() throws Exception { Mockito.when(settingsRepository.querySetting("previousFormSyncIndex", "0")).thenReturn("1234"); String actual = allSettings.fetchPreviousFormSyncIndex(); Mockito.verify(settingsRepository).querySetting("previousFormSyncIndex", "0"); Assert.assertEq... | public String fetchPreviousFormSyncIndex() { return settingsRepository.querySetting(PREVIOUS_FORM_SYNC_INDEX_SETTING_KEY, "0"); } | AllSettings { public String fetchPreviousFormSyncIndex() { return settingsRepository.querySetting(PREVIOUS_FORM_SYNC_INDEX_SETTING_KEY, "0"); } } | AllSettings { public String fetchPreviousFormSyncIndex() { return settingsRepository.querySetting(PREVIOUS_FORM_SYNC_INDEX_SETTING_KEY, "0"); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); } | AllSettings { public String fetchPreviousFormSyncIndex() { return settingsRepository.querySetting(PREVIOUS_FORM_SYNC_INDEX_SETTING_KEY, "0"); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); void registerANM(String userName); void savePreviousFetchIndex(String value); String fetch... | AllSettings { public String fetchPreviousFormSyncIndex() { return settingsRepository.querySetting(PREVIOUS_FORM_SYNC_INDEX_SETTING_KEY, "0"); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); void registerANM(String userName); void savePreviousFetchIndex(String value); String fetch... |
@Test public void shouldSaveAppliedVillageFilter() throws Exception { allSettings.saveAppliedVillageFilter("munjanahalli"); Mockito.verify(settingsRepository).updateSetting("appliedVillageFilter", "munjanahalli"); } | public void saveAppliedVillageFilter(String village) { settingsRepository.updateSetting(APPLIED_VILLAGE_FILTER_SETTING_KEY, village); } | AllSettings { public void saveAppliedVillageFilter(String village) { settingsRepository.updateSetting(APPLIED_VILLAGE_FILTER_SETTING_KEY, village); } } | AllSettings { public void saveAppliedVillageFilter(String village) { settingsRepository.updateSetting(APPLIED_VILLAGE_FILTER_SETTING_KEY, village); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); } | AllSettings { public void saveAppliedVillageFilter(String village) { settingsRepository.updateSetting(APPLIED_VILLAGE_FILTER_SETTING_KEY, village); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); void registerANM(String userName); void savePreviousFetchIndex(String value); String... | AllSettings { public void saveAppliedVillageFilter(String village) { settingsRepository.updateSetting(APPLIED_VILLAGE_FILTER_SETTING_KEY, village); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); void registerANM(String userName); void savePreviousFetchIndex(String value); String... |
@Test public void shouldGetAppliedVillageFilter() throws Exception { allSettings.appliedVillageFilter("All"); Mockito.verify(settingsRepository).querySetting("appliedVillageFilter", "All"); } | public String appliedVillageFilter(String defaultFilterValue) { return settingsRepository .querySetting(APPLIED_VILLAGE_FILTER_SETTING_KEY, defaultFilterValue); } | AllSettings { public String appliedVillageFilter(String defaultFilterValue) { return settingsRepository .querySetting(APPLIED_VILLAGE_FILTER_SETTING_KEY, defaultFilterValue); } } | AllSettings { public String appliedVillageFilter(String defaultFilterValue) { return settingsRepository .querySetting(APPLIED_VILLAGE_FILTER_SETTING_KEY, defaultFilterValue); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); } | AllSettings { public String appliedVillageFilter(String defaultFilterValue) { return settingsRepository .querySetting(APPLIED_VILLAGE_FILTER_SETTING_KEY, defaultFilterValue); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); void registerANM(String userName); void savePreviousFetch... | AllSettings { public String appliedVillageFilter(String defaultFilterValue) { return settingsRepository .querySetting(APPLIED_VILLAGE_FILTER_SETTING_KEY, defaultFilterValue); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); void registerANM(String userName); void savePreviousFetch... |
@Test public void assertRegisterANMCallsPreferenceAndRepositoryUpdate() throws Exception { Mockito.doNothing().when(allSharedPreferences).updateANMUserName(Mockito.anyString()); allSettings.registerANM(""); Mockito.verify(allSharedPreferences, Mockito.times(1)).updateANMUserName(Mockito.anyString()); } | public void registerANM(String userName) { preferences.updateANMUserName(userName); } | AllSettings { public void registerANM(String userName) { preferences.updateANMUserName(userName); } } | AllSettings { public void registerANM(String userName) { preferences.updateANMUserName(userName); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); } | AllSettings { public void registerANM(String userName) { preferences.updateANMUserName(userName); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); void registerANM(String userName); void savePreviousFetchIndex(String value); String fetchPreviousFetchIndex(); void saveAppliedVillag... | AllSettings { public void registerANM(String userName) { preferences.updateANMUserName(userName); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); void registerANM(String userName); void savePreviousFetchIndex(String value); String fetchPreviousFetchIndex(); void saveAppliedVillag... |
@Test public void assertSaveANMLocationCallsRepositoryUpdate() { Mockito.doNothing().doNothing().when(settingsRepository).updateSetting(Mockito.anyString(), Mockito.anyString()); allSettings.saveANMLocation(""); Mockito.verify(settingsRepository, Mockito.times(1)).updateSetting(Mockito.anyString(), Mockito.anyString())... | public void saveANMLocation(String anmLocation) { settingsRepository.updateSetting(ANM_LOCATION, anmLocation); } | AllSettings { public void saveANMLocation(String anmLocation) { settingsRepository.updateSetting(ANM_LOCATION, anmLocation); } } | AllSettings { public void saveANMLocation(String anmLocation) { settingsRepository.updateSetting(ANM_LOCATION, anmLocation); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); } | AllSettings { public void saveANMLocation(String anmLocation) { settingsRepository.updateSetting(ANM_LOCATION, anmLocation); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); void registerANM(String userName); void savePreviousFetchIndex(String value); String fetchPreviousFetchInde... | AllSettings { public void saveANMLocation(String anmLocation) { settingsRepository.updateSetting(ANM_LOCATION, anmLocation); } AllSettings(AllSharedPreferences preferences, SettingsRepository settingsRepository); void registerANM(String userName); void savePreviousFetchIndex(String value); String fetchPreviousFetchInde... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.