src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
AllBeneficiaries { public Mother findMotherWithOpenStatus(String caseId) { return motherRepository.findOpenCaseByCaseID(caseId); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, AlertRepository alertRepository, TimelineEventRepository ...
@Test public void assertFindMotherWithOpenStatus() { Mockito.when(motherRepository.findOpenCaseByCaseID(Mockito.anyString())).thenReturn(Mockito.mock(Mother.class)); Assert.assertNotNull(allBeneficiaries.findMotherWithOpenStatus("")); }
AllBeneficiaries { public Mother findMother(String caseId) { List<Mother> mothers = motherRepository.findByCaseIds(caseId); if (mothers.isEmpty()) { return null; } return mothers.get(0); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, AlertRepository al...
@Test public void assertFindMotherReturnsMother() { Mockito.when(motherRepository.findByCaseIds(Mockito.anyString())).thenReturn(new ArrayList<Mother>()); Assert.assertNull(allBeneficiaries.findMother("")); List<Mother> list = new ArrayList<Mother>(); list.add(Mockito.mock(Mother.class)); Mockito.when(motherRepository....
AllBeneficiaries { public Mother findMotherByECCaseId(String ecCaseId) { List<Mother> mothers = motherRepository.findAllCasesForEC(ecCaseId); if (mothers.isEmpty()) { return null; } return mothers.get(0); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, ...
@Test public void assertFindMotherByECCaseIdReturnsMother() { Mockito.when(motherRepository.findAllCasesForEC(Mockito.anyString())).thenReturn(new ArrayList<Mother>()); Assert.assertNull(allBeneficiaries.findMotherByECCaseId("")); List<Mother> list = new ArrayList<Mother>(); list.add(Mockito.mock(Mother.class)); Mockit...
AllBeneficiaries { public List<Child> findAllChildrenByCaseIDs(List<String> caseIds) { return childRepository.findChildrenByCaseIds(caseIds.toArray(new String[caseIds.size()])); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, AlertRepository alertReposi...
@Test public void assertFindAllChildrenByCaseIDs() { Mockito.when(childRepository.findChildrenByCaseIds(Mockito.any(String[].class))).thenReturn(Mockito.mock(List.class)); Assert.assertNotNull(allBeneficiaries.findAllChildrenByCaseIDs(new ArrayList<String>())); }
AllBeneficiaries { public List<Child> allChildrenWithMotherAndEC() { return childRepository.allChildrenWithMotherAndEC(); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, AlertRepository alertRepository, TimelineEventRepository ...
@Test public void assertAllChildrenWithMotherAndEC() { Mockito.when(childRepository.allChildrenWithMotherAndEC()).thenReturn(Mockito.mock(List.class)); Assert.assertNotNull(allBeneficiaries.allChildrenWithMotherAndEC()); }
AllBeneficiaries { public List<Child> findAllChildrenByECId(String ecId) { return childRepository.findAllChildrenByECId(ecId); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, AlertRepository alertRepository, TimelineEventRepository ...
@Test public void assertFindAllChildrenByECId() { Mockito.when(childRepository.findAllChildrenByECId(Mockito.anyString())).thenReturn(Mockito.mock(List.class)); Assert.assertNotNull(allBeneficiaries.findAllChildrenByECId("")); }
AllBeneficiaries { public Mother findMotherWithOpenStatusByECId(String ecId) { return motherRepository.findMotherWithOpenStatusByECId(ecId); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, AlertRepository alertRepository, TimelineEventRepository ...
@Test public void assertFindMotherWithOpenStatusByECId() { Mockito.when(motherRepository.findMotherWithOpenStatusByECId(Mockito.anyString())).thenReturn(Mockito.mock(Mother.class)); Assert.assertNotNull(allBeneficiaries.findMotherWithOpenStatusByECId("")); }
AllBeneficiaries { public boolean isPregnant(String ecId) { return motherRepository.isPregnant(ecId); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, AlertRepository alertRepository, TimelineEventRepository timelineEv...
@Test public void assertIsPregnant() { Mockito.when(motherRepository.isPregnant(Mockito.anyString())).thenReturn(false); Assert.assertEquals(allBeneficiaries.isPregnant(""), false); }
AllBeneficiaries { public void switchMotherToPNC(String entityId) { motherRepository.switchToPNC(entityId); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, AlertRepository alertRepository, TimelineEventRepository time...
@Test public void assertSwitchMotherToPNC() { Mockito.doNothing().when(motherRepository).switchToPNC(Mockito.anyString()); allBeneficiaries.switchMotherToPNC(""); Mockito.verify(motherRepository, Mockito.times(1)).switchToPNC(Mockito.anyString()); }
AllBeneficiaries { public List<Mother> findAllMothersByCaseIDs(List<String> caseIds) { return motherRepository.findByCaseIds(caseIds.toArray(new String[caseIds.size()])); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, AlertRepository alertRepository, T...
@Test public void assertFindAllMothersByCaseIDs() { Mockito.when(motherRepository.findByCaseIds(Mockito.any(String[].class))).thenReturn(Mockito.mock(List.class)); Assert.assertNotNull(allBeneficiaries.findAllMothersByCaseIDs(new ArrayList<String>())); }
AllBeneficiaries { public List<Child> findAllChildrenByMotherId(String entityId) { return childRepository.findByMotherCaseId(entityId); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, AlertRepository alertRepository, TimelineEventRepository ...
@Test public void assertFindAllChildrenByMotherId() { Mockito.when(childRepository.findByMotherCaseId(Mockito.anyString())).thenReturn(Mockito.mock(List.class)); Assert.assertNotNull(allBeneficiaries.findAllChildrenByMotherId("")); }
AllBeneficiaries { public Child findChild(String caseId) { return childRepository.find(caseId); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, AlertRepository alertRepository, TimelineEventRepository timelineEventRep...
@Test public void assertFindChild() { Mockito.when(childRepository.find(Mockito.anyString())).thenReturn(Mockito.mock(Child.class)); Assert.assertNotNull(allBeneficiaries.findChild("")); }
AllBeneficiaries { public long ancCount() { return motherRepository.ancCount(); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, AlertRepository alertRepository, TimelineEventRepository timelineEventRepository); Mother...
@Test public void assertANCcountReturnsLong() { Mockito.when(motherRepository.ancCount()).thenReturn(0l); Assert.assertEquals(allBeneficiaries.ancCount(), 0l); }
AllBeneficiaries { public long pncCount() { return motherRepository.pncCount(); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, AlertRepository alertRepository, TimelineEventRepository timelineEventRepository); Mother...
@Test public void assertPNCcountReturnsLong() { Mockito.when(motherRepository.pncCount()).thenReturn(0l); Assert.assertEquals(allBeneficiaries.pncCount(), 0l); }
AllBeneficiaries { public long childCount() { return childRepository.count(); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, AlertRepository alertRepository, TimelineEventRepository timelineEventRepository); Mother f...
@Test public void assertChildcountReturnsLong() { Mockito.when(childRepository.count()).thenReturn(0l); Assert.assertEquals(allBeneficiaries.childCount(), 0l); }
AllBeneficiaries { public List<Pair<Mother, EligibleCouple>> allANCsWithEC() { return motherRepository.allMothersOfATypeWithEC(TYPE_ANC); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, AlertRepository alertRepository, TimelineEventRepository ...
@Test public void assertAllANCsWithECReturnsList() { Mockito.when(motherRepository.allMothersOfATypeWithEC(Mockito.anyString())).thenReturn(Mockito.mock(List.class)); Assert.assertNotNull(allBeneficiaries.allANCsWithEC()); }
AllBeneficiaries { public List<Pair<Mother, EligibleCouple>> allPNCsWithEC() { return motherRepository.allMothersOfATypeWithEC(TYPE_PNC); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, AlertRepository alertRepository, TimelineEventRepository ...
@Test public void assertAllPNCsWithECReturnsList() { Mockito.when(motherRepository.allMothersOfATypeWithEC(Mockito.anyString())).thenReturn(Mockito.mock(List.class)); Assert.assertNotNull(allBeneficiaries.allPNCsWithEC()); }
AllBeneficiaries { public void closeMother(String entityId) { alertRepository.deleteAllAlertsForEntity(entityId); timelineEventRepository.deleteAllTimelineEventsForEntity(entityId); motherRepository.close(entityId); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, ...
@Test public void shouldDeleteTimelineEventsAndAlertsWhileClosingMother() throws Exception { allBeneficiaries.closeMother("entity id 1"); Mockito.verify(alertRepository).deleteAllAlertsForEntity("entity id 1"); Mockito.verify(timelineEventRepository).deleteAllTimelineEventsForEntity("entity id 1"); }
AllBeneficiaries { public void closeAllMothersForEC(String ecId) { List<Mother> mothers = motherRepository.findAllCasesForEC(ecId); if (mothers == null || mothers.isEmpty()) { return; } for (Mother mother : mothers) { closeMother(mother.caseId()); } } AllBeneficiaries(MotherRepository motherRepository, ChildRepository ...
@Test public void shouldDeleteTimelineEventsAndAlertsForAllMothersWhenECIsClosed() throws Exception { Mockito.when(motherRepository.findAllCasesForEC("ec id 1")) .thenReturn(Arrays.asList(new Mother("mother id 1", "ec id 1", "12345", "2012-12-12"), new Mother("mother id 2", "ec id 2", "123456", "2012-12-10"))); allBene...
AllBeneficiaries { public void closeChild(String entityId) { alertRepository.deleteAllAlertsForEntity(entityId); timelineEventRepository.deleteAllTimelineEventsForEntity(entityId); childRepository.close(entityId); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, ...
@Test public void shouldDeleteTimelineEventsAndAlertsWhenAChildIsClosed() throws Exception { Mockito.when(childRepository.find("child id 1")) .thenReturn(new Child("child id 1", "mother id 1", "male", new HashMap<String, String>())); allBeneficiaries.closeChild("child id 1"); Mockito.verify(alertRepository).deleteAllAl...
AllBeneficiaries { public void updateChild(Child child) { childRepository.update(child); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, AlertRepository alertRepository, TimelineEventRepository timelineEventRepository...
@Test public void shouldDelegateToChildRepositoryWhenUpdateChildIsCalled() throws Exception { allBeneficiaries.updateChild(child); Mockito.verify(childRepository).update(child); }
AllBeneficiaries { public void updateMother(Mother mother) { motherRepository.update(mother); } AllBeneficiaries(MotherRepository motherRepository, ChildRepository childRepository, AlertRepository alertRepository, TimelineEventRepository timelineEventRepos...
@Test public void shouldDelegateToMotherRepositoryWhenUpdateMotherIsCalled() throws Exception { allBeneficiaries.updateMother(mother); Mockito.verify(motherRepository).update(mother); }
AllSharedPreferences { public void updateANMUserName(String userName) { preferences.edit().putString(ANM_IDENTIFIER_PREFERENCE_KEY, userName).commit(); Set<String> anmIdentifiers = new HashSet<>(preferences.getStringSet(ANM_IDENTIFIER_SET_PREFERENCE_KEY, new HashSet<>())); anmIdentifiers.add(userName); preferences.edit...
@Test public void assertupdateANMUserNameCallsPreferenceEdit() { allSharedPreferences.updateANMUserName(""); Mockito.verify(preferences, Mockito.times(2)).edit(); }
AllSharedPreferences { public boolean fetchForceRemoteLogin(String username) { return preferences.getBoolean(new StringBuffer(AllConstants.FORCE_REMOTE_LOGIN).append('_').append(username).toString(), true); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegis...
@Test public void assertFetchForceRemoteLogin() { Mockito.when(preferences.getBoolean(AllConstants.FORCE_REMOTE_LOGIN + "_" + USERNAME, true)).thenReturn(true); Assert.assertEquals(allSharedPreferences.fetchForceRemoteLogin(USERNAME), true); }
AllSharedPreferences { public String fetchServerTimeZone() { return preferences.getString(AllConstants.SERVER_TIMEZONE, null); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fetchForceRemoteLo...
@Test public void assertFetchServerTimeZone() { Assert.assertEquals(str, allSharedPreferences.fetchServerTimeZone()); }
AllSharedPreferences { public void saveServerTimeZone(String serverTimeZone) { preferences.edit().putString(AllConstants.SERVER_TIMEZONE, serverTimeZone).commit(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String ...
@Test public void assertSaveServerTimeZone() { allSharedPreferences.saveServerTimeZone(""); Mockito.verify(preferences, Mockito.times(1)).edit(); }
AllSharedPreferences { public String fetchPioneerUser() { return preferences.getString(AllConstants.PIONEER_USER, null); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fetchForceRemoteLogin(St...
@Test public void assertFetchPioneerUser() { Assert.assertEquals(allSharedPreferences.fetchPioneerUser(), str); }
AllSharedPreferences { public Long fetchLastUpdatedAtDate(long lastSyncDate) { return preferences.getLong(LAST_UPDATED_AT_DATE, lastSyncDate); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fe...
@Test public void assertfetchLastUpdatedAtDate() { Assert.assertEquals(allSharedPreferences.fetchLastUpdatedAtDate(0l), new Long(0l)); }
AllSharedPreferences { public void saveLastUpdatedAtDate(long lastSyncDate) { preferences.edit().putLong(LAST_UPDATED_AT_DATE, lastSyncDate).commit(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); bo...
@Test public void assertsaveLastUpdatedAtDate() { allSharedPreferences.saveLastUpdatedAtDate(0l); Mockito.verify(preferences, Mockito.times(1)).edit(); }
AllSharedPreferences { public String fetchCurrentLocality() { return preferences.getString(AllConstants.CURRENT_LOCALITY, null); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fetchForceRemote...
@Test public void assertfetchCurrentLocality() { Assert.assertEquals(allSharedPreferences.fetchCurrentLocality(), str); }
AllSharedPreferences { public void saveCurrentLocality(String currentLocality) { preferences.edit().putString(AllConstants.CURRENT_LOCALITY, currentLocality).commit(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(Str...
@Test public void assertsaveCurrentLocality() { allSharedPreferences.saveCurrentLocality("LoCaLiTy"); Mockito.verify(preferences, Mockito.times(1)).edit(); }
AllSharedPreferences { public String fetchCurrentDataStrategy() { return preferences.getString(AllConstants.DATA_STRATEGY, AllConstants.DATA_CAPTURE_STRATEGY.NORMAL); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(Stri...
@Test public void assertfetchCurrentDataStrategy() { Assert.assertEquals(allSharedPreferences.fetchCurrentDataStrategy(), str); }
AllSharedPreferences { public void saveCurrentDataStrategy(String currentDataStrategy) { preferences.edit().putString(AllConstants.DATA_STRATEGY, currentDataStrategy).commit(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegister...
@Test public void assertsaveCurrentDataStrategy() { allSharedPreferences.saveCurrentDataStrategy("Mobile Clinic"); Mockito.verify(preferences, Mockito.times(1)).edit(); }
AllSharedPreferences { public void saveLanguagePreference(String languagePreference) { preferences.edit().putString(AllConstants.LANGUAGE_PREFERENCE_KEY, languagePreference).commit(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isR...
@Test public void assertsaveLanguagePreference() { allSharedPreferences.saveLanguagePreference("EN"); Mockito.verify(preferences, Mockito.times(1)).edit(); }
AllSharedPreferences { public String fetchBaseURL(String baseurl) { String url = preferences.getString(AllConstants.DRISHTI_BASE_URL, baseurl); return StringUtils.isNotBlank(url) && url.endsWith("/") ? url.substring(0, url.length() - 1) : url; } AllSharedPreferences(SharedPreferences preferences); void updateANMUserNam...
@Test public void assertfetchBaseURL() { Assert.assertEquals(allSharedPreferences.fetchBaseURL(""), "http: }
AllSharedPreferences { public void savePreference(String key, String value) { preferences.edit().putString(key, value).commit(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fetchForceRemote...
@Test public void assertsavePreference() { allSharedPreferences.savePreference("", ""); Mockito.verify(preferences, Mockito.times(1)).edit(); } @Test public void shouldSaveCampaignsOperationalArea() { allSharedPreferences.savePreference(CAMPAIGNS, "Miti Rural Health Centre"); Mockito.verify(preferences, Mockito.times(1...
AllSharedPreferences { public String getPreference(String key) { return preferences.getString(key, ""); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fetchForceRemoteLogin(String username); v...
@Test public void assertgetPreference() { Assert.assertEquals(allSharedPreferences.getPreference(""), str); } @Test public void shouldGetCampaignsOperationalArea() { Assert.assertEquals(allSharedPreferences.getPreference(CAMPAIGNS), str); }
AllSharedPreferences { public void updateANMPreferredName(String userName, String preferredName) { preferences.edit().putString(userName, preferredName).commit(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String u...
@Test public void assertupdateANMPreferredName() { allSharedPreferences.updateANMPreferredName("", ""); Mockito.verify(preferences, Mockito.times(1)).edit(); }
AllSharedPreferences { public String getANMPreferredName(String userName) { return preferences.getString(userName, ""); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fetchForceRemoteLogin(Str...
@Test public void assertgetANMPreferredName() { org.junit.Assert.assertEquals(allSharedPreferences.getANMPreferredName("uname"), str); }
AllSharedPreferences { public String fetchHost(String host) { if ((host == null || host.isEmpty()) && preferences.getString(HOST, host).equals(host)) { updateUrl(fetchBaseURL("")); } return preferences.getString(HOST, host); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName);...
@Test public void assertfetchHost() { Assert.assertEquals(allSharedPreferences.fetchHost(""), ""); Assert.assertEquals(allSharedPreferences.fetchHost(null), str); Mockito.when(preferences.getString(AllConstants.DRISHTI_BASE_URL, "")).thenReturn("Malformed Url"); Assert.assertEquals(allSharedPreferences.fetchHost(""), "...
AllSharedPreferences { public Integer fetchPort(Integer port) { return Integer.parseInt(preferences.getString(PORT, "" + port)); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fetchForceRemote...
@Test public void assertfetchPort() { Assert.assertEquals(allSharedPreferences.fetchPort(new Integer(80)), new Integer(8080)); }
AllSharedPreferences { public void savePioneerUser(String username) { preferences.edit().putString(AllConstants.PIONEER_USER, username).commit(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean...
@Test public void assertSavePioneerUser() { allSharedPreferences.savePioneerUser("uname"); Mockito.verify(preferences, Mockito.times(1)).edit(); }
AllSharedPreferences { public void saveDefaultLocalityId(String username, String localityId) { if (username != null) { preferences.edit().putString(AllConstants.DEFAULT_LOCALITY_ID_PREFIX + username, localityId) .commit(); } } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName);...
@Test public void assertSaveDefaultLocalityId() { allSharedPreferences.saveDefaultLocalityId("uname", "Id"); Mockito.verify(preferences, Mockito.times(1)).edit(); }
AllSharedPreferences { public String fetchDefaultLocalityId(String username) { if (username != null) { return preferences.getString(AllConstants.DEFAULT_LOCALITY_ID_PREFIX + username, null); } return null; } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegist...
@Test public void assertFetchDefaultLocalityId() { org.junit.Assert.assertNull(allSharedPreferences.fetchDefaultLocalityId(null)); org.junit.Assert.assertEquals(allSharedPreferences.fetchDefaultLocalityId(""), str); }
AllSharedPreferences { public void saveForceRemoteLogin(boolean forceRemoteLogin, String username) { preferences.edit().putBoolean(new StringBuffer(AllConstants.FORCE_REMOTE_LOGIN).append('_').append(username).toString(), forceRemoteLogin).commit(); } AllSharedPreferences(SharedPreferences preferences); void updateANMU...
@Test public void assertSaveForceRemoteLogin() { allSharedPreferences.saveForceRemoteLogin(true, USERNAME); Mockito.verify(preferences, Mockito.times(1)).edit(); }
AllSharedPreferences { public String fetchRegisteredANM() { return preferences.getString(ANM_IDENTIFIER_PREFERENCE_KEY, "").trim(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fetchForceRem...
@Test public void shouldFetchANMIdentifierFromPreferences() throws Exception { Mockito.when(preferences.getString("anmIdentifier", "")).thenReturn("1234"); String actual = allSharedPreferences.fetchRegisteredANM(); Mockito.verify(preferences).getString("anmIdentifier", ""); assertEquals("1234", actual); } @Test public ...
AllSharedPreferences { public String fetchLanguagePreference() { return preferences.getString(AllConstants.LANGUAGE_PREFERENCE_KEY, AllConstants.DEFAULT_LOCALE).trim(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(St...
@Test public void shouldFetchLanguagePreference() throws Exception { Mockito.when(preferences.getString(AllConstants.LANGUAGE_PREFERENCE_KEY, AllConstants.DEFAULT_LOCALE)).thenReturn(AllConstants.ENGLISH_LANGUAGE); assertEquals("English", allSharedPreferences.fetchLanguagePreference()); }
AllSharedPreferences { public Boolean fetchIsSyncInProgress() { return preferences.getBoolean(AllConstants.IS_SYNC_IN_PROGRESS_PREFERENCE_KEY, false); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); bo...
@Test public void shouldFetchIsSyncInProgress() throws Exception { Mockito.when(preferences.getBoolean(AllConstants.IS_SYNC_IN_PROGRESS_PREFERENCE_KEY, false)).thenReturn(true); assertTrue(allSharedPreferences.fetchIsSyncInProgress()); }
AllSharedPreferences { public void saveIsSyncInProgress(Boolean isSyncInProgress) { preferences.edit().putBoolean(AllConstants.IS_SYNC_IN_PROGRESS_PREFERENCE_KEY, isSyncInProgress).commit(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); bool...
@Test public void shouldSaveIsSyncInProgress() throws Exception { SharedPreferences.Editor editor = Mockito.mock(SharedPreferences.Editor.class); Mockito.when(preferences.edit()).thenReturn(editor); Mockito.when(editor.putBoolean(AllConstants.IS_SYNC_IN_PROGRESS_PREFERENCE_KEY, true)).thenReturn(editor); allSharedPrefe...
AllSharedPreferences { public Boolean fetchIsSyncInitial() { return preferences.getBoolean(AllConstants.IS_SYNC_INITIAL_KEY, false); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fetchForceRe...
@Test public void assertSaveIsSyncInitialIsFalse() { Assert.assertFalse(allSharedPreferences.fetchIsSyncInitial()); }
AllSharedPreferences { public void saveUserLocalityId(String username, String localityId) { if (username != null) { preferences.edit().putString(AllConstants.USER_LOCALITY_ID_PREFIX + username, localityId) .commit(); } } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); Strin...
@Test public void testSaveUserLocalityId() { SharedPreferences.Editor editor = Mockito.mock(SharedPreferences.Editor.class); Mockito.when(preferences.edit()).thenReturn(editor); Mockito.when(editor.putString(any(), any())).thenReturn(editor); allSharedPreferences.saveUserLocalityId("uname", "Id"); Mockito.verify(editor...
AllSharedPreferences { public String fetchUserLocalityId(String username) { if (username != null) { return preferences.getString(AllConstants.USER_LOCALITY_ID_PREFIX + username, null); } return null; } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredAN...
@Test public void testFetchUserLocalityId() { Mockito.when(preferences.getString(any(), any())).thenReturn("local-id"); assertEquals("local-id", allSharedPreferences.fetchUserLocalityId("uname")); assertNull(allSharedPreferences.fetchUserLocalityId(null)); }
AllSharedPreferences { public void saveDefaultTeam(String username, String team) { if (username != null) { preferences.edit().putString(AllConstants.DEFAULT_TEAM_PREFIX + username, team) .commit(); } } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredAN...
@Test public void testSaveDefaultTeam() { SharedPreferences.Editor editor = Mockito.mock(SharedPreferences.Editor.class); Mockito.when(preferences.edit()).thenReturn(editor); Mockito.when(editor.putString(any(), any())).thenReturn(editor); allSharedPreferences.saveDefaultTeam("uname", "team"); Mockito.verify(editor).pu...
AllSharedPreferences { public String fetchDefaultTeam(String username) { if (username != null) { return preferences.getString(AllConstants.DEFAULT_TEAM_PREFIX + username, null); } return null; } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); bo...
@Test public void testFetchDefaultTeam() { Mockito.when(preferences.getString(any(), any())).thenReturn("team"); assertEquals("team", allSharedPreferences.fetchDefaultTeam("uname")); assertNull(allSharedPreferences.fetchDefaultTeam(null)); }
AllSharedPreferences { public String fetchDefaultTeamId(String username) { if (username != null) { return preferences.getString(AllConstants.DEFAULT_TEAM_ID_PREFIX + username, null); } return null; } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(...
@Test public void testFetchDefaultTeamId() { Mockito.when(preferences.getString(any(), any())).thenReturn("team-id"); assertEquals("team-id", allSharedPreferences.fetchDefaultTeamId("uname")); assertNull(allSharedPreferences.fetchDefaultTeamId(null)); }
AllSharedPreferences { public Long fetchLastSyncDate(long lastSyncDate) { return preferences.getLong(LAST_SYNC_DATE, lastSyncDate); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fetchForceRem...
@Test public void testFetchLastSyncDate() { Mockito.when(preferences.getLong(any(), anyLong())).thenReturn(2000L); assertEquals((Long) 2000L, allSharedPreferences.fetchLastSyncDate(1000L)); }
AllSharedPreferences { public void saveLastSyncDate(long lastSyncDate) { preferences.edit().putLong(LAST_SYNC_DATE, lastSyncDate).commit(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fetch...
@Test public void testSaveLastSyncDate() { SharedPreferences.Editor editor = Mockito.mock(SharedPreferences.Editor.class); Mockito.when(preferences.edit()).thenReturn(editor); Mockito.when(editor.putLong(any(), anyLong())).thenReturn(editor); allSharedPreferences.saveLastSyncDate(2000L); Mockito.verify(editor).putLong(...
AllSharedPreferences { public void saveIsSyncInitial(boolean initialSynStatus) { preferences.edit().putBoolean(AllConstants.IS_SYNC_INITIAL_KEY, initialSynStatus).commit(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredAN...
@Test public void testSaveIsSyncInitial() { SharedPreferences.Editor editor = Mockito.mock(SharedPreferences.Editor.class); Mockito.when(preferences.edit()).thenReturn(editor); Mockito.when(editor.putBoolean(any(), anyBoolean())).thenReturn(editor); allSharedPreferences.saveIsSyncInitial(true); Mockito.verify(editor).p...
AllSharedPreferences { public long fetchLastCheckTimeStamp() { return preferences.getLong(LAST_CHECK_TIMESTAMP, 0); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fetchForceRemoteLogin(String ...
@Test public void testFetchLastCheckTimeStamp() { Mockito.when(preferences.getLong(any(), anyLong())).thenReturn(2000L); assertEquals(2000L, allSharedPreferences.fetchLastCheckTimeStamp()); }
AllSharedPreferences { public void updateLastCheckTimeStamp(long lastSyncTimeStamp) { preferences.edit().putLong(LAST_CHECK_TIMESTAMP, lastSyncTimeStamp).commit(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String ...
@Test public void testUpdateLastCheckTimeStamp() { SharedPreferences.Editor editor = Mockito.mock(SharedPreferences.Editor.class); Mockito.when(preferences.edit()).thenReturn(editor); Mockito.when(editor.putLong(any(), anyLong())).thenReturn(editor); allSharedPreferences.updateLastCheckTimeStamp(1000L); Mockito.verify(...
AllSharedPreferences { public void updateLastSettingsSyncTimeStamp(long lastSettingsSync) { preferences.edit().putLong(LAST_SETTINGS_SYNC_TIMESTAMP, lastSettingsSync).commit(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegister...
@Test public void testUpdateLastSettingsSyncTimeStamp() { SharedPreferences.Editor editor = Mockito.mock(SharedPreferences.Editor.class); Mockito.when(preferences.edit()).thenReturn(editor); Mockito.when(editor.putLong(any(), anyLong())).thenReturn(editor); allSharedPreferences.updateLastSettingsSyncTimeStamp(1000L); M...
AllSharedPreferences { public long fetchLastSettingsSyncTimeStamp() { return preferences.getLong(LAST_SETTINGS_SYNC_TIMESTAMP, 0); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fetchForceRemo...
@Test public void testFetchLastSettingsSyncTimeStamp() { Mockito.when(preferences.getLong(any(), anyLong())).thenReturn(2000L); assertEquals(2000L, allSharedPreferences.fetchLastSettingsSyncTimeStamp()); }
AllSharedPreferences { public boolean isMigratedToSqlite4() { return preferences.getBoolean(MIGRATED_TO_SQLITE_4, false); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fetchForceRemoteLogin(S...
@Test public void testIsMigratedToSqlite4() { Mockito.when(preferences.getBoolean(any(), anyBoolean())).thenReturn(true); assertTrue(allSharedPreferences.isMigratedToSqlite4()); }
AllSharedPreferences { public void setMigratedToSqlite4() { preferences.edit().putBoolean(MIGRATED_TO_SQLITE_4, true).commit(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fetchForceRemoteL...
@Test public void testSetMigratedToSqlite4() { SharedPreferences.Editor editor = Mockito.mock(SharedPreferences.Editor.class); Mockito.when(preferences.edit()).thenReturn(editor); Mockito.when(editor.putBoolean(any(), anyBoolean())).thenReturn(editor); allSharedPreferences.setMigratedToSqlite4(); Mockito.verify(editor)...
AllSharedPreferences { public int getLastPeerToPeerSyncProcessedEvent() { return preferences.getInt(PEER_TO_PEER_SYNC_LAST_PROCESSED_RECORD, -1); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean...
@Test public void testGetLastPeerToPeerSyncProcessedEvent() { Mockito.when(preferences.getInt(any(), anyInt())).thenReturn(10); assertEquals(10, allSharedPreferences.getLastPeerToPeerSyncProcessedEvent()); }
AllSharedPreferences { public void setLastPeerToPeerSyncProcessedEvent(int lastEventRowId) { preferences.edit().putInt(PEER_TO_PEER_SYNC_LAST_PROCESSED_RECORD, lastEventRowId).commit(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean i...
@Test public void testSetLastPeerToPeerSyncProcessedEvent() { SharedPreferences.Editor editor = Mockito.mock(SharedPreferences.Editor.class); Mockito.when(preferences.edit()).thenReturn(editor); Mockito.when(editor.putInt(any(), anyInt())).thenReturn(editor); allSharedPreferences.setLastPeerToPeerSyncProcessedEvent(10)...
AllSharedPreferences { public boolean isPeerToPeerUnprocessedEvents() { return getLastPeerToPeerSyncProcessedEvent() != -1; } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fetchForceRemoteLogin...
@Test public void isPeerToPeerUnprocessedEvents() { Mockito.when(preferences.getBoolean(any(), anyBoolean())).thenReturn(true); assertTrue(allSharedPreferences.isPeerToPeerUnprocessedEvents()); }
AllSharedPreferences { public void resetLastPeerToPeerSyncProcessedEvent() { setLastPeerToPeerSyncProcessedEvent(-1); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fetchForceRemoteLogin(Strin...
@Test public void resetLastPeerToPeerSyncProcessedEvent() { SharedPreferences.Editor editor = Mockito.mock(SharedPreferences.Editor.class); Mockito.when(preferences.edit()).thenReturn(editor); Mockito.when(editor.putInt(any(), anyInt())).thenReturn(editor); allSharedPreferences.resetLastPeerToPeerSyncProcessedEvent(); ...
AllSharedPreferences { public void updateLastClientProcessedTimeStamp(long lastProcessed) { preferences.edit().putLong(LAST_CLIENT_PROCESSED_TIMESTAMP, lastProcessed).commit(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegister...
@Test public void testUpdateLastClientProcessedTimeStamp() { SharedPreferences.Editor editor = Mockito.mock(SharedPreferences.Editor.class); Mockito.when(preferences.edit()).thenReturn(editor); Mockito.when(editor.putLong(any(), anyLong())).thenReturn(editor); allSharedPreferences.updateLastClientProcessedTimeStamp(100...
AllSharedPreferences { public long fetchLastClientProcessedTimeStamp() { return preferences.getLong(LAST_CLIENT_PROCESSED_TIMESTAMP, 0); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fetchFor...
@Test public void testFetchLastClientProcessedTimeStamp() { Mockito.when(preferences.getLong(any(), anyLong())).thenReturn(2000L); assertEquals(2000L, allSharedPreferences.fetchLastClientProcessedTimeStamp()); }
AllSharedPreferences { public void updateTransactionsKilledFlag(boolean transactionsKilled) { preferences.edit().putBoolean(TRANSACTIONS_KILLED_FLAG, transactionsKilled).commit(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegis...
@Test public void testUpdateTransactionsKilledFlag() { SharedPreferences.Editor editor = Mockito.mock(SharedPreferences.Editor.class); Mockito.when(preferences.edit()).thenReturn(editor); Mockito.when(editor.putBoolean(any(), anyBoolean())).thenReturn(editor); allSharedPreferences.updateTransactionsKilledFlag(true); Mo...
AllSharedPreferences { public boolean fetchTransactionsKilledFlag() { return preferences.getBoolean(TRANSACTIONS_KILLED_FLAG, false); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); boolean isRegisteredANM(String userName); boolean fetchForceR...
@Test public void testFetchTransactionsKilledFlag() { Mockito.when(preferences.getBoolean(any(), anyBoolean())).thenReturn(true); assertTrue(allSharedPreferences.fetchTransactionsKilledFlag()); }
StructureRepository extends LocationRepository { public void addOrUpdate(Location location) { if (StringUtils.isBlank(location.getId())) throw new IllegalArgumentException("id not provided"); ContentValues contentValues = new ContentValues(); if (P2PUtil.checkIfExistsById(STRUCTURE_TABLE, location.getId(), getWritableD...
@Test public void testAddOrUpdateShouldAdd() { Location location = gson.fromJson(locationJson, Location.class); structureRepository.addOrUpdate(location); verify(sqLiteDatabase).replace(stringArgumentCaptor.capture(), stringArgumentCaptor.capture(), contentValuesArgumentCaptor.capture()); assertEquals(2, stringArgument...
JsonFormUtils { public static JSONObject merge(JSONObject original, JSONObject updated) { JSONObject mergedJSON = new JSONObject(); try { mergedJSON = new JSONObject(original, getNames(original)); for (String key : getNames(updated)) { mergedJSON.put(key, updated.get(key)); } } catch (JSONException e) { Timber.e(e); } ...
@Test public void assertMergeWillMergeJsonObjects() throws Exception { String addressJsonWithCountryString = "{\"entity_id\":\"mother\",\"value\":\"Bangladesh\",\"openmrs_entity\":\"person_address\"," + "\"openmrs_entity_id\":\"country\",\"hint\":\"address of household country\"," + "\"openmrs_entity_parent\":\"usual_r...
StructureRepository extends LocationRepository { public boolean batchInsertStructures(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); Location structu...
@Test public void testBatchInsertStructures() throws Exception { Location expectedStructure = gson.fromJson(locationJson, Location.class); JSONArray structureArray = new JSONArray().put(new JSONObject(locationJson)); structureRepository = spy(structureRepository); boolean inserted = structureRepository.batchInsertStruc...
StructureRepository extends LocationRepository { public List<Location> getAllUnsynchedCreatedStructures() { Cursor cursor = null; List<Location> structures = new ArrayList<>(); try { cursor = getReadableDatabase().rawQuery(String.format("SELECT * FROM %s WHERE %s =?", STRUCTURE_TABLE, SYNC_STATUS), new String[]{BaseRep...
@Test public void testGetAllUnsynchedCreatedStructures() { String sql = "SELECT * FROM structure WHERE sync_status =?"; when(sqLiteDatabase.rawQuery(anyString(), any())).thenReturn(getCursor()); List<Location> actualStructures = structureRepository.getAllUnsynchedCreatedStructures(); verify(sqLiteDatabase).rawQuery(str...
StructureRepository extends LocationRepository { @Nullable public JsonData getStructures(long lastRowId, int limit, String parentLocationId) { JsonData jsonData = null; long maxRowId = 0; String locationFilter = parentLocationId != null ? String.format(" %s =? AND ", PARENT_ID) : ""; String query = "SELECT " + ROWID + ...
@Test public void testGetStructuresWithNullStructureId() throws Exception { Location expectedStructure = gson.fromJson(locationJson, Location.class); String sql = "SELECT rowid,* FROM structure WHERE rowid > ? ORDER BY rowid ASC LIMIT ?"; long lastRowId = 1l; int limit = 10; when(sqLiteDatabase.rawQuery(anyString(), (O...
StructureRepository extends LocationRepository { public void markStructuresAsSynced(String structureId) { try { ContentValues values = new ContentValues(); values.put(ID, structureId); values.put(SYNC_STATUS, BaseRepository.TYPE_Synced); getWritableDatabase().update(STRUCTURE_TABLE, values, ID + " = ?", new String[]{st...
@Test public void testMarkStructureAsSynced() { String expectedStructureId = "41587456-b7c8-4c4e-b433-23a786f742fc"; structureRepository.markStructuresAsSynced(expectedStructureId); verifyMarkStructureAsSyncedTests(expectedStructureId); } @Test public void testMarkStructureAsSyncedShouldThrowException() { doThrow(new S...
StructureRepository extends LocationRepository { @Override public List<Location> getAllLocations() { throw new UnsupportedOperationException("getAllLocations not supported for Structures"); } static void createTable(SQLiteDatabase database); @Override void deleteLocations(@NonNull Set<String> locationIdentifiers); @Ov...
@Test(expected = UnsupportedOperationException.class) public void testGetAllLocations() { structureRepository.getAllLocations(); }
StructureRepository extends LocationRepository { public static void createTable(SQLiteDatabase database) { database.execSQL(CREATE_LOCATION_TABLE); database.execSQL(CREATE_LOCATION_PARENT_INDEX); } static void createTable(SQLiteDatabase database); @Override void deleteLocations(@NonNull Set<String> locationIdentifiers...
@Test public void testCreateTable() { StructureRepository.createTable(sqLiteDatabase); verify(sqLiteDatabase, times(2)).execSQL(stringArgumentCaptor.capture()); assertEquals("CREATE TABLE structure (_id VARCHAR NOT NULL PRIMARY KEY,uuid VARCHAR , " + "parent_id VARCHAR , name VARCHAR , sync_status VARCHAR DEFAULT Synce...
FormsVersionRepository extends DrishtiRepository { @Override protected void onCreate(SQLiteDatabase database) { database.execSQL(FORM_VERSION_SQL); } FormDefinitionVersion fetchVersionByFormName(String formName); FormDefinitionVersion fetchVersionByFormDirName(String formDirName); String getVersion(String formDirName)...
@Test public void assertOnCreateCallsDatabaseExec() { formsVersionRepository.onCreate(sqLiteDatabase); Mockito.verify(sqLiteDatabase, Mockito.times(1)).execSQL(Mockito.anyString()); }
JsonFormUtils { public static JSONArray getMultiStepFormFields(JSONObject jsonForm) { JSONArray fields = new JSONArray(); try { int stepCount = Integer.parseInt(jsonForm.optString(AllConstants.COUNT, "1")); if (stepCount == 1) { return getSingleStepFormfields(jsonForm); } else { for (int i = 0; i < stepCount; i++) { St...
@Test public void testGetMultiStepFormFields() throws JSONException { assertNotNull(multiStepForm); JSONObject jsonForm = new JSONObject(multiStepForm); assertNotNull(jsonForm); JSONArray formFields = JsonFormUtils.getMultiStepFormFields(jsonForm); assertNotNull(formFields); } @Test public void testGetMultiStepFormFiel...
FormsVersionRepository extends DrishtiRepository { public FormDefinitionVersion fetchVersionByFormName(String formName) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.query(FORM_VERSION_TABLE_NAME, FORM_VERSION_TABLE_COLUMNS, FORM_NAME_COLUMN + " " + "" + "= ?", new String[...
@Test public void assertFetchVersionByFormName() { Assert.assertNotNull(formsVersionRepository.fetchVersionByFormName("")); }
FormsVersionRepository extends DrishtiRepository { public FormDefinitionVersion fetchVersionByFormDirName(String formDirName) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.query(FORM_VERSION_TABLE_NAME, FORM_VERSION_TABLE_COLUMNS, FORM_DIR_NAME_COLUMN + " = ?", new String[...
@Test public void assertFetchVersionByFormDirName() { Assert.assertNotNull(formsVersionRepository.fetchVersionByFormDirName("")); }
FormsVersionRepository extends DrishtiRepository { public String getVersion(String formDirName) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.query(FORM_VERSION_TABLE_NAME, FORM_VERSION_TABLE_COLUMNS, FORM_DIR_NAME_COLUMN + " = ?", new String[]{formDirName}, null, null, nu...
@Test public void assertGetVersion() { Assert.assertNotNull(formsVersionRepository.getVersion("")); }
FormsVersionRepository extends DrishtiRepository { public List<FormDefinitionVersion> getAllFormWithSyncStatus(SyncStatus status) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.query(FORM_VERSION_TABLE_NAME, FORM_VERSION_TABLE_COLUMNS, SYNC_STATUS_COLUMN + " = ?", new Strin...
@Test public void assertgetAllFormWithSyncStatus() { Assert.assertNotNull(formsVersionRepository.getAllFormWithSyncStatus(SyncStatus.PENDING)); }
FormsVersionRepository extends DrishtiRepository { public List<Map<String, String>> getAllFormWithSyncStatusAsMap(SyncStatus status) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.query(FORM_VERSION_TABLE_NAME, FORM_VERSION_TABLE_COLUMNS, SYNC_STATUS_COLUMN + " = ?", new St...
@Test public void assertgetAllFormWithSyncStatusAsMap() { Assert.assertNotNull(formsVersionRepository.getAllFormWithSyncStatusAsMap(SyncStatus.PENDING)); }
FormsVersionRepository extends DrishtiRepository { public FormDefinitionVersion getFormByFormDirName(String formDirName) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.query(FORM_VERSION_TABLE_NAME, FORM_VERSION_TABLE_COLUMNS, FORM_DIR_NAME_COLUMN + " = ?", new String[]{for...
@Test public void assertgetFormByFormDirName() { Assert.assertNotNull(formsVersionRepository.getFormByFormDirName("")); }
FormsVersionRepository extends DrishtiRepository { public void addFormVersion(Map<String, String> dataJSON) { SQLiteDatabase database = masterRepository.getWritableDatabase(); database.insert(FORM_VERSION_TABLE_NAME, null, createValuesFormVersions(dataJSON)); } FormDefinitionVersion fetchVersionByFormName(String formN...
@Test public void assertAddFormVersion() { HashMap<String, String> data = new HashMap<String, String>(); data.put(FORM_NAME_COLUMN, "form_name"); data.put(VERSION_COLUMN, "1.0"); data.put(FORM_DIR_NAME_COLUMN, "dir"); data.put(SYNC_STATUS_COLUMN, SyncStatus.PENDING.value()); formsVersionRepository.addFormVersion(data);...
FormsVersionRepository extends DrishtiRepository { public void addFormVersionFromObject(FormDefinitionVersion formDefinitionVersion) { SQLiteDatabase database = masterRepository.getWritableDatabase(); database.insert(FORM_VERSION_TABLE_NAME, null, createValuesFromObject(formDefinitionVersion)); } FormDefinitionVersion...
@Test public void assertAddFormVersionFromObject() { FormDefinitionVersion fd = new FormDefinitionVersion("", "", ""); fd.setSyncStatus(SyncStatus.PENDING); formsVersionRepository.addFormVersionFromObject(fd); Mockito.verify(sqLiteDatabase, Mockito.times(1)).insert(Mockito.anyString(), Mockito.isNull(String.class), Moc...
FormsVersionRepository extends DrishtiRepository { public boolean formExists(String formDirName) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.query(FORM_VERSION_TABLE_NAME, new String[]{FORM_DIR_NAME_COLUMN}, FORM_DIR_NAME_COLUMN + " = ?", new String[]{formDirName}, null,...
@Test public void assertformExistsReturnsTrue() { Assert.assertEquals(formsVersionRepository.formExists(""), true); }
FormsVersionRepository extends DrishtiRepository { public void deleteAll() { SQLiteDatabase database = masterRepository.getWritableDatabase(); database.delete(FORM_VERSION_TABLE_NAME, null, null); } FormDefinitionVersion fetchVersionByFormName(String formName); FormDefinitionVersion fetchVersionByFormDirName(String fo...
@Test public void assertDeleteAllCallsDatabaseDelete() { formsVersionRepository.deleteAll(); Mockito.verify(sqLiteDatabase, Mockito.times(1)).delete(Mockito.anyString(), Mockito.isNull(String.class), Mockito.isNull(String[].class)); }
GenericInteractor implements CallableInteractor { @Override public <T> void execute(Callable<T> callable, CallableInteractorCallBack<T> callBack) { execute(callable, callBack, AppExecutors.Request.DISK_THREAD); } GenericInteractor(); @VisibleForTesting GenericInteractor(AppExecutors appExecutors); @Override void execu...
@Test public void testDefaultExecuteFunction() { interactor = Mockito.spy(interactor); final String test = "Test String"; Callable<String> callable = () -> test; CallableInteractorCallBack<String> callBack = Mockito.mock(CallableInteractorCallBack.class); interactor.execute(callable, callBack); Mockito.verify(interacto...
FormsVersionRepository extends DrishtiRepository { public void updateServerVersion(String formDirName, String serverVersion) { SQLiteDatabase database = masterRepository.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(VERSION_COLUMN, serverVersion); database.update(FORM_VERSION_TABLE_NAME,...
@Test public void assertupdateServerVersion() { formsVersionRepository.updateServerVersion("", ""); Mockito.verify(sqLiteDatabase, Mockito.times(1)).update(Mockito.anyString(), Mockito.any(ContentValues.class), Mockito.anyString(), Mockito.any(String[].class)); }
FormsVersionRepository extends DrishtiRepository { public void updateFormName(String formDirName, String formName) { SQLiteDatabase database = masterRepository.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(FORM_NAME_COLUMN, formName); database.update(FORM_VERSION_TABLE_NAME, values, FORM...
@Test public void assertupdateFormName() { formsVersionRepository.updateFormName("", ""); Mockito.verify(sqLiteDatabase, Mockito.times(1)).update(Mockito.anyString(), Mockito.any(ContentValues.class), Mockito.anyString(), Mockito.any(String[].class)); }
FormsVersionRepository extends DrishtiRepository { public void updateSyncStatus(String formDirName, SyncStatus status) { SQLiteDatabase database = masterRepository.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(SYNC_STATUS_COLUMN, status.value()); database.update(FORM_VERSION_TABLE_NAME, ...
@Test public void assertupdateSyncStatus() { formsVersionRepository.updateSyncStatus("", SyncStatus.PENDING); Mockito.verify(sqLiteDatabase, Mockito.times(1)).update(Mockito.anyString(), Mockito.any(ContentValues.class), Mockito.anyString(), Mockito.any(String[].class)); }
TimelineEventRepository extends DrishtiRepository { @Override protected void onCreate(SQLiteDatabase database) { database.execSQL(TIMELINEEVENT_SQL); database.execSQL(TIMELINEVENT_CASEID_INDEX_SQL); } void add(TimelineEvent timelineEvent); List<TimelineEvent> allFor(String caseId); void deleteAllTimelineEventsForEntit...
@Test public void assertOnCreateCallsDatabaseExec() { Mockito.doNothing().when(sqLiteDatabase).execSQL(Mockito.anyString()); timelineEventRepository.onCreate(sqLiteDatabase); Mockito.verify(sqLiteDatabase, Mockito.times(2)).execSQL(Mockito.anyString()); }
TimelineEventRepository extends DrishtiRepository { public void add(TimelineEvent timelineEvent) { SQLiteDatabase database = masterRepository.getWritableDatabase(); database.insert(TIMELINEEVENT_TABLE_NAME, null, createValuesFor(timelineEvent)); } void add(TimelineEvent timelineEvent); List<TimelineEvent> allFor(Strin...
@Test public void assertAddCallsDatabaseInsert() { TimelineEvent timelineEvent = new TimelineEvent("", "", new LocalDate(), "", "", ""); timelineEventRepository.add(timelineEvent); Mockito.verify(sqLiteDatabase, Mockito.times(1)).insert(Mockito.anyString(), Mockito.isNull(String.class), Mockito.any(ContentValues.class)...
TimelineEventRepository extends DrishtiRepository { public List<TimelineEvent> allFor(String caseId) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = database.query(TIMELINEEVENT_TABLE_NAME, TIMELINEEVENT_TABLE_COLUMNS, CASEID_COLUMN + "= ?", new String[]{caseId}, null, null, null); r...
@Test public void assertAllFor() { String[] columns = {"id", "name", "date", "a", "b", "c"}; MatrixCursor cursor = new MatrixCursor(columns); cursor.addRow(new Object[]{"", "", "2017-10-10", "", "", ""}); cursor.addRow(new Object[]{"", "", "2017-10-10", "", "", ""}); Mockito.when(sqLiteDatabase.query(Mockito.anyString(...
TimelineEventRepository extends DrishtiRepository { public void deleteAllTimelineEventsForEntity(String caseId) { SQLiteDatabase database = masterRepository.getWritableDatabase(); database.delete(TIMELINEEVENT_TABLE_NAME, CASEID_COLUMN + " = ?", new String[]{caseId}); } void add(TimelineEvent timelineEvent); List<Time...
@Test public void assertDeleteAllTimelineEventsForEntity() { timelineEventRepository.deleteAllTimelineEventsForEntity(""); Mockito.verify(sqLiteDatabase, Mockito.times(1)).delete(Mockito.anyString(), Mockito.anyString(), Mockito.any(String[].class)); }