src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
Utils { public static boolean isEmptyMap(Map map) { return map == null || map.isEmpty(); } static String convertDateFormat(String date, boolean suppressException); static Date toDate(String date, boolean suppressException); static String convertDateFormat(String date, String defaultV, boolean suppressException); stati... | @Test public void testIsEmptyMapShouldReturnCorrectStatus() { Map<String, String> map = new HashMap<>(); map.put("key", "string"); assertFalse(Utils.isEmptyMap(map)); map.clear(); assertTrue(Utils.isEmptyMap(map)); } |
Utils { public static String getName(@NonNull String firstName, @NonNull String lastName) { return (firstName.trim() + " " + lastName.trim()).trim(); } static String convertDateFormat(String date, boolean suppressException); static Date toDate(String date, boolean suppressException); static String convertDateFormat(St... | @Test public void testGetNameShouldGetCorrectlyFormattedName() { assertEquals("John Doe", Utils.getName("John", "Doe")); assertEquals("John", Utils.getName("John", "")); assertEquals("Doe", Utils.getName("", "Doe")); } |
Utils { public static int getAgeFromDate(String dateOfBirth) { DateTime date = DateTime.parse(dateOfBirth); Years age = Years.yearsBetween(date.toLocalDate(), LocalDate.now()); return age.getYears(); } static String convertDateFormat(String date, boolean suppressException); static Date toDate(String date, boolean supp... | @Test public void testGetAgeFromDateShouldGetCorrectAge() { String date = "2000-12-12"; DateTime dateTime = DateTime.parse(date); assertEquals(Utils.getAgeFromDate(date), Years.yearsBetween(dateTime.toLocalDate(), LocalDate.now()).getYears()); } |
Utils { public static String getDob(int age) { return getDob(age, DateUtil.DATE_FORMAT_FOR_TIMELINE_EVENT); } static String convertDateFormat(String date, boolean suppressException); static Date toDate(String date, boolean suppressException); static String convertDateFormat(String date, String defaultV, boolean suppre... | @Test public void testGetDobShouldGetCorrectDob() { int age = 10; String datePattern = "YYYY-MM-dd"; Calendar cal = Calendar.getInstance(); cal.add(Calendar.YEAR, -age); assertEquals(cal.getWeekYear() + "-" + "01" + "-" + "01", Utils.getDob(age, datePattern)); assertEquals("01" + "-" + "01" + "-" + cal.getWeekYear(), U... |
Utils { public static AllSharedPreferences getAllSharedPreferences() { return CoreLibrary.getInstance().context().allSharedPreferences(); } static String convertDateFormat(String date, boolean suppressException); static Date toDate(String date, boolean suppressException); static String convertDateFormat(String date, S... | @Test public void testGetAllSharedPreferencesShouldGetPreferences() { assertNotNull(Utils.getAllSharedPreferences()); } |
Utils { @Nullable public static String getAppId(@NonNull Context context) { PackageInfo packageInfo = getPackageInfo(context); return packageInfo != null ? packageInfo.packageName : null; } static String convertDateFormat(String date, boolean suppressException); static Date toDate(String date, boolean suppressExceptio... | @Test public void testGetAppIdShouldReturnAppId() { assertEquals("org.smartregister.test", Utils.getAppId(RuntimeEnvironment.application)); } |
Utils { @Nullable public static String getAppVersion(@NonNull Context context) { PackageInfo packageInfo = getPackageInfo(context); return packageInfo != null ? packageInfo.versionName : null; } static String convertDateFormat(String date, boolean suppressException); static Date toDate(String date, boolean suppressExc... | @Test public void testGetAppVersionShouldReturnAppVersion() { assertNull(Utils.getAppVersion(RuntimeEnvironment.application)); } |
Context { public UserService userService() { if (userService == null) { userService = new UserService(allSettings(), allSharedPreferences(), httpAgent(), session(), configuration(), saveANMLocationTask(), saveUserInfoTask(), saveANMTeamTask()); } return userService; } protected Context(); static Context getInstance();... | @Test public void testUserService() { UserService userService = context.userService(); Assert.assertNotNull(userService); } |
Context { public ImageRepository imageRepository() { if (imageRepository == null) { imageRepository = new ImageRepository(); } return imageRepository; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context applicationContext(); BeneficiaryService bene... | @Test public void testImageRepository() { ImageRepository imageRepository = context.imageRepository(); Assert.assertNotNull(imageRepository); } |
DisplayUtils { public static int getDisplayWidth(Activity activity) { DisplayMetrics displayMetrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); return displayMetrics.widthPixels; } static ScreenDpi getScreenDpi(Context context); static int getDisplayWidth(Activit... | @Test public void testGetDisplayWidthReturnsCorrectWidthPixelsValue() { Mockito.doReturn(resources).when(context).getResources(); Mockito.doReturn(windowManager).when(context).getWindowManager(); DisplayManager displayManager = (DisplayManager) RuntimeEnvironment.application.getSystemService(Context.DISPLAY_SERVICE); D... |
Context { public AllAlerts allAlerts() { if (allAlerts == null) { allAlerts = new AllAlerts(alertRepository()); } return allAlerts; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context applicationContext(); BeneficiaryService beneficiaryService(); C... | @Test public void testAllAlerts() { AllAlerts allAlerts = context.allAlerts(); Assert.assertNotNull(allAlerts); } |
Context { public HTTPAgent httpAgent() { if (httpAgent == null) { httpAgent = new HTTPAgent(applicationContext, allSharedPreferences(), configuration()); } return httpAgent; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context applicationContext(); ... | @Test public void testHttpAgent() { HTTPAgent httpAgent = context.httpAgent(); Assert.assertNotNull(httpAgent); } |
Context { public ANMService anmService() { if (anmService == null) { anmService = new ANMService(allSharedPreferences(), allBeneficiaries(), allEligibleCouples()); } return anmService; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context application... | @Test public void testAnmService() { ANMService anmService = context.anmService(); Assert.assertNotNull(anmService); } |
Context { public DristhiConfiguration configuration() { if (configuration == null) { configuration = new DristhiConfiguration(); } return configuration; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context applicationContext(); BeneficiaryService be... | @Test public void testConfiguration() { DristhiConfiguration dristhiConfiguration = context.configuration(); Assert.assertNotNull(dristhiConfiguration); } |
Context { public ANMController anmController() { if (anmController == null) { anmController = new ANMController(anmService(), listCache(), homeContextCache()); } return anmController; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context applicationC... | @Test public void testAnmController() { ANMController anmController = context.anmController(); Assert.assertNotNull(anmController); } |
Context { public ANMLocationController anmLocationController() { if (anmLocationController == null) { anmLocationController = new ANMLocationController(allSettings(), listCache()); } return anmLocationController; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android... | @Test public void testAnmLocationController() { ANMLocationController anmLocationController = context.anmLocationController(); Assert.assertNotNull(anmLocationController); } |
Context { public HTTPAgent getHttpAgent() { return httpAgent(); } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context applicationContext(); BeneficiaryService beneficiaryService(); Context updateApplicationContext(android.content.Context applicationC... | @Test public void testGetHttpAgent() { HTTPAgent httpAgent = context.getHttpAgent(); Assert.assertNotNull(httpAgent); } |
Context { public EventClientRepository getEventClientRepository() { if (eventClientRepository == null) { eventClientRepository = new EventClientRepository(); } return eventClientRepository; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context applic... | @Test public void testGetEventClientRepository() { EventClientRepository eventClientRepository = context.getEventClientRepository(); Assert.assertNotNull(eventClientRepository); } |
Context { public UniqueIdRepository getUniqueIdRepository() { if (uniqueIdRepository == null) { uniqueIdRepository = new UniqueIdRepository(); } return uniqueIdRepository; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context applicationContext(); Be... | @Test public void testGetUniqueIdRepository() { UniqueIdRepository uniqueIdRepository = context.getUniqueIdRepository(); Assert.assertNotNull(uniqueIdRepository); } |
Context { public CampaignRepository getCampaignRepository() { if (campaignRepository == null) { campaignRepository = new CampaignRepository(); } return campaignRepository; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context applicationContext(); Be... | @Test public void testGetCampaignRepository() { CampaignRepository campaignRepository = context.getCampaignRepository(); Assert.assertNotNull(campaignRepository); } |
DisplayUtils { public static int getDisplayHeight(Activity activity) { DisplayMetrics displayMetrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); return displayMetrics.heightPixels; } static ScreenDpi getScreenDpi(Context context); static int getDisplayWidth(Activ... | @Test public void testGetDisplayHeightReturnsCorrectHeightPixelsValue() { Mockito.doReturn(resources).when(context).getResources(); Mockito.doReturn(windowManager).when(context).getWindowManager(); DisplayManager displayManager = (DisplayManager) RuntimeEnvironment.application.getSystemService(Context.DISPLAY_SERVICE);... |
Context { public TaskRepository getTaskRepository() { if (taskRepository == null) { taskNotesRepository = new TaskNotesRepository(); taskRepository = new TaskRepository(taskNotesRepository); } return taskRepository; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); andr... | @Test public void testgetTaskRepository() { TaskRepository taskRepository = context.getTaskRepository(); Assert.assertNotNull(taskRepository); } |
Context { public BeneficiaryService beneficiaryService() { if (beneficiaryService == null) { beneficiaryService = new BeneficiaryService(allEligibleCouples(), allBeneficiaries()); } return beneficiaryService; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.con... | @Test public void testBeneficiaryService() { BeneficiaryService beneficiaryService = context.beneficiaryService(); Assert.assertNotNull(beneficiaryService); } |
Context { protected DrishtiService drishtiService() { if (drishtiService == null) { drishtiService = new DrishtiService(httpAgent(), configuration().dristhiBaseURL()); } return drishtiService; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context app... | @Test public void testDrishtiService() { DrishtiService drishtiService = context.drishtiService(); Assert.assertNotNull(drishtiService); } |
Context { public ActionService actionService() { if (actionService == null) { actionService = new ActionService(drishtiService(), allSettings(), allSharedPreferences(), allReports()); } return actionService; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.cont... | @Test public void testActionService() { ActionService actionService = context.actionService(); Assert.assertNotNull(actionService); } |
Context { public FormSubmissionService formSubmissionService() { if (formSubmissionService == null) { if (commonFtsObject != null) { formSubmissionService = new FormSubmissionService(ziggyService(), formDataRepository(), allSettings(), allCommonsRepositoryMap()); } else { formSubmissionService = new FormSubmissionServi... | @Test public void testFormSubmissionService() { context.assignbindtypes(); FormSubmissionService formSubmissionService = context.formSubmissionService(); Assert.assertNotNull(formSubmissionService); } |
Context { public AllFormVersionSyncService allFormVersionSyncService() { if (allFormVersionSyncService == null) { allFormVersionSyncService = new AllFormVersionSyncService(httpAgent(), configuration(), formsVersionRepository()); } return allFormVersionSyncService; } protected Context(); static Context getInstance(); s... | @Test public void testAllFormVersionSyncService() { AllFormVersionSyncService allFormVersionSyncService = context.allFormVersionSyncService(); Assert.assertNotNull(allFormVersionSyncService); } |
Context { public FormSubmissionRouter formSubmissionRouter() { if (formSubmissionRouter == null) { formSubmissionRouter = new FormSubmissionRouter(formDataRepository(), ecRegistrationHandler(), fpComplicationsHandler(), fpChangeHandler(), renewFPProductHandler(), ecCloseHandler(), ancRegistrationHandler(), ancRegistrat... | @Test public void testFormSubmissionRouter() { FormSubmissionRouter formSubmissionRouter = context.formSubmissionRouter(); Assert.assertNotNull(formSubmissionRouter); } |
Context { public ZiggyService ziggyService() { if (ziggyService == null) { ziggyService = new ZiggyService(ziggyFileLoader(), formDataRepository(), formSubmissionRouter()); } return ziggyService; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context ... | @Test public void testZiggyService() { context.assignbindtypes(); ZiggyService ziggyService = context.ziggyService(); Assert.assertNotNull(ziggyService); } |
Context { public ZiggyFileLoader ziggyFileLoader() { if (ziggyFileLoader == null) { ziggyFileLoader = new ZiggyFileLoader("www/ziggy", "www/form", applicationContext().getAssets()); } return ziggyFileLoader; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.cont... | @Test public void testZiggyFileLoader() { ZiggyFileLoader ziggyFileLoader = context.ziggyFileLoader(); Assert.assertNotNull(ziggyFileLoader); } |
Context { public FormSubmissionSyncService formSubmissionSyncService() { if (formSubmissionSyncService == null) { formSubmissionSyncService = new FormSubmissionSyncService(formSubmissionService(), httpAgent(), formDataRepository(), allSettings(), allSharedPreferences(), configuration()); } return formSubmissionSyncServ... | @Test public void testFormSubmissionSyncService() { FormSubmissionSyncService formSubmissionSyncService = context.formSubmissionSyncService(); Assert.assertNotNull(formSubmissionSyncService); } |
DisplayUtils { public static double getScreenSize(Activity activity) { DisplayMetrics dm = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(dm); int width = dm.widthPixels; int height = dm.heightPixels; double wi = (double) width / (double) dm.xdpi; double hi = (double) height / (double)... | @Test public void testGetScreenSizeReturnsCorrectValues() { Mockito.doReturn(resources).when(context).getResources(); Mockito.doReturn(windowManager).when(context).getWindowManager(); DisplayManager displayManager = (DisplayManager) RuntimeEnvironment.application.getSystemService(Context.DISPLAY_SERVICE); Display displ... |
Context { public ArrayList<DrishtiRepository> sharedRepositories() { assignbindtypes(); ArrayList<DrishtiRepository> drishtireposotorylist = new ArrayList<DrishtiRepository>(); drishtireposotorylist.add(settingsRepository()); drishtireposotorylist.add(alertRepository()); drishtireposotorylist.add(eligibleCoupleReposito... | @Test public void testSharedRepositories() { ArrayList<DrishtiRepository> sharedRepositories = context.sharedRepositories(); Assert.assertEquals(sharedRepositories.size(), 12); } |
Context { public DrishtiRepository[] sharedRepositoriesArray() { ArrayList<DrishtiRepository> drishtiRepositories = sharedRepositories(); DrishtiRepository[] drishtireposotoryarray = drishtiRepositories .toArray(new DrishtiRepository[drishtiRepositories.size()]); return drishtireposotoryarray; } protected Context(); s... | @Test public void testSharedRepositoriesArray() { DrishtiRepository[] sharedRepositoriesArray = context.sharedRepositoriesArray(); Assert.assertEquals(sharedRepositoriesArray.length, 12); } |
Context { public AllTimelineEvents allTimelineEvents() { if (allTimelineEvents == null) { allTimelineEvents = new AllTimelineEvents(timelineEventRepository()); } return allTimelineEvents; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context applicat... | @Test public void testAllTimelineEvents() { AllTimelineEvents allTimelineEvents = context.allTimelineEvents(); Assert.assertNotNull(allTimelineEvents); } |
Context { public AllReports allReports() { if (allReports == null) { allReports = new AllReports(reportRepository()); } return allReports; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context applicationContext(); BeneficiaryService beneficiaryServi... | @Test public void testAllReports() { AllReports allReports = context.allReports(); Assert.assertNotNull(allReports); } |
Context { public AllServicesProvided allServicesProvided() { if (allServicesProvided == null) { allServicesProvided = new AllServicesProvided(serviceProvidedRepository()); } return allServicesProvided; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Co... | @Test public void testAllServicesProvided() { AllServicesProvided allServicesProvided = context.allServicesProvided(); Assert.assertNotNull(allServicesProvided); } |
Context { public DetailsRepository detailsRepository() { if (detailsRepository == null) { detailsRepository = new DetailsRepository(); } return detailsRepository; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context applicationContext(); Beneficiary... | @Test public void testDetailsRepository() { DetailsRepository detailsRepository = context.detailsRepository(); Assert.assertNotNull(detailsRepository); } |
Context { public FormDataRepository formDataRepository() { if (formDataRepository == null) { formDataRepository = new FormDataRepository(); } return formDataRepository; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context applicationContext(); Benef... | @Test public void testFormDataRepository() { context.assignbindtypes(); FormDataRepository formDataRepository = context.formDataRepository(); Assert.assertNotNull(formDataRepository); } |
Context { public AlertService alertService() { if (alertService == null) { if (commonFtsObject() != null) { alertService = new AlertService(alertRepository(), commonFtsObject(), allCommonsRepositoryMap()); } else { alertService = new AlertService(alertRepository()); } } return alertService; } protected Context(); stat... | @Test public void testAlertService() { AlertService alertService = context.alertService(); Assert.assertNotNull(alertService); } |
Context { public ServiceProvidedService serviceProvidedService() { if (serviceProvidedService == null) { serviceProvidedService = new ServiceProvidedService(allServicesProvided()); } return serviceProvidedService; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); androi... | @Test public void testServiceProvidedService() { ServiceProvidedService serviceProvidedService = context.serviceProvidedService(); Assert.assertNotNull(serviceProvidedService); } |
Context { public EligibleCoupleService eligibleCoupleService() { if (eligibleCoupleService == null) { eligibleCoupleService = new EligibleCoupleService(allEligibleCouples(), allTimelineEvents(), allBeneficiaries()); } return eligibleCoupleService; } protected Context(); static Context getInstance(); static Context set... | @Test public void testEligibleCoupleService() { EligibleCoupleService eligibleCoupleService = context.eligibleCoupleService(); Assert.assertNotNull(eligibleCoupleService); } |
CredentialsHelper { public static boolean shouldMigrate() { return CoreLibrary.getInstance().context().allSharedPreferences().getDBEncryptionVersion() == 0 || (CoreLibrary.getInstance().context().allSharedPreferences().getDBEncryptionVersion() > 0 && BuildConfig.DB_ENCRYPTION_VERSION > CoreLibrary.getInstance().context... | @Test public void testShouldMigrateReturnsTrueForDBEncryptionVersionZero() { boolean shouldMigrate = CredentialsHelper.shouldMigrate(); Assert.assertTrue(shouldMigrate); } |
ClientFormResponse { public ClientFormDTO getClientForm() { return clientForm; } ClientFormResponse(ClientFormDTO clientForm, ClientFormMetadataDTO clientFormMetadata); ClientFormDTO getClientForm(); void setClientForm(ClientFormDTO clientForm); ClientFormMetadataDTO getClientFormMetadata(); void setClientFormMetadata(... | @Test public void getClientForm() { ClientFormDTO clientFormDTO = new ClientFormDTO(); clientFormDTO.setId(1); clientFormDTO.setJson("[\"test json\"]"); ClientFormMetadataDTO clientFormMetadataDTO = new ClientFormMetadataDTO(); Date now = Calendar.getInstance().getTime(); clientFormMetadataDTO.setCreatedAt(now); client... |
Context { public MotherService motherService() { if (motherService == null) { motherService = new MotherService(allBeneficiaries(), allEligibleCouples(), allTimelineEvents(), serviceProvidedService()); } return motherService; } protected Context(); static Context getInstance(); static Context setInstance(Context mCont... | @Test public void testmotherService() { MotherService motherService = context.motherService(); Assert.assertNotNull(motherService); } |
Context { public ChildService childService() { if (childService == null) { childService = new ChildService(allBeneficiaries(), motherRepository(), childRepository(), allTimelineEvents(), serviceProvidedService(), allAlerts()); } return childService; } protected Context(); static Context getInstance(); static Context s... | @Test public void testChildService() { ChildService childService = context.childService(); Assert.assertNotNull(childService); } |
Context { public PendingFormSubmissionService pendingFormSubmissionService() { if (pendingFormSubmissionService == null) { pendingFormSubmissionService = new PendingFormSubmissionService(formDataRepository()); } return pendingFormSubmissionService; } protected Context(); static Context getInstance(); static Context se... | @Test public void testPendingFormSubmissionService() { context.assignbindtypes(); PendingFormSubmissionService pendingFormSubmissionService = context.pendingFormSubmissionService(); Assert.assertNotNull(pendingFormSubmissionService); } |
Context { public LocationRepository getLocationRepository() { if (locationRepository == null) { locationRepository = new LocationRepository(); } return locationRepository; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context applicationContext(); Be... | @Test public void testLocationRepository() { LocationRepository locationRepository = context.getLocationRepository(); Assert.assertNotNull(locationRepository); } |
Context { public LocationTagRepository getLocationTagRepository() { if (locationTagRepository == null) { locationTagRepository = new LocationTagRepository(); } return locationTagRepository; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context applic... | @Test public void testGetLocationTagRepository() { LocationTagRepository locationTagRepository = context.getLocationTagRepository(); Assert.assertNotNull(locationTagRepository); } |
Context { public StructureRepository getStructureRepository() { if (structureRepository == null) { structureRepository = new StructureRepository(); } return structureRepository; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context applicationContext... | @Test public void testGetStructureRepository() { StructureRepository structureRepository = context.getStructureRepository(); Assert.assertNotNull(structureRepository); } |
Context { public PlanDefinitionRepository getPlanDefinitionRepository() { if (planDefinitionRepository == null) { planDefinitionRepository = new PlanDefinitionRepository(); } return planDefinitionRepository; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.cont... | @Test public void testGetPlanDefinitionRepository() { PlanDefinitionRepository planDefinitionRepository = context.getPlanDefinitionRepository(); Assert.assertNotNull(planDefinitionRepository); } |
Context { public ManifestRepository getManifestRepository() { if (manifestRepository == null) { manifestRepository = new ManifestRepository(); } return manifestRepository; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context applicationContext(); Be... | @Test public void testGetManifestRepository() { ManifestRepository manifestRepository = context.getManifestRepository(); Assert.assertNotNull(manifestRepository); } |
Context { public ClientFormRepository getClientFormRepository() { if (clientFormRepository == null) { clientFormRepository = new ClientFormRepository(); } return clientFormRepository; } protected Context(); static Context getInstance(); static Context setInstance(Context mContext); android.content.Context applicationC... | @Test public void testGetClientFormRepository() { ClientFormRepository clientFormRepository = context.getClientFormRepository(); Assert.assertNotNull(clientFormRepository); } |
AllCommonsRepository { public long count() { return personRepository.count(); } AllCommonsRepository(CommonRepository personRepository, AlertRepository
alertRepository, TimelineEventRepository timelineEventRepository); List<CommonPersonObject> all(); CommonPersonObject findByCaseID(String caseId); CommonPer... | @Test public void ShouldShowcount() throws Exception { when(personRepository.count()).thenReturn((long) 8); assertEquals(personRepository.count(), (long) 8); }
@Test public void testCount() { allCommonsRepository.count(); verify(personRepository).count(); } |
CredentialsHelper { public byte[] getCredentials(String username, String type) { if (CREDENTIALS_TYPE.DB_AUTH.equals(type)) { return context.userService().getDecryptedPassphraseValue(username); } else if (CREDENTIALS_TYPE.LOCAL_AUTH.equals(type)) { return context.userService().getDecryptedAccountValue(username, Account... | @Test public void testGetCredentialsInvokesGetDecryptedPassphraseValueWithCorrectValuesForDBAuth() { credentialsHelper.getCredentials(TEST_USERNAME, CredentialsHelper.CREDENTIALS_TYPE.DB_AUTH); ArgumentCaptor<String> usernameArgCaptor = ArgumentCaptor.forClass(String.class); Mockito.verify(userService, Mockito.times(1)... |
AllCommonsRepository { public List<CommonPersonObject> all() { return personRepository.allcommon(); } AllCommonsRepository(CommonRepository personRepository, AlertRepository
alertRepository, TimelineEventRepository timelineEventRepository); List<CommonPersonObject> all(); CommonPersonObject findByCaseID(Str... | @Test public void testAll() { allCommonsRepository.all(); verify(personRepository).allcommon(); } |
AllCommonsRepository { public CommonPersonObject findByCaseID(String caseId) { return personRepository.findByCaseID(caseId); } AllCommonsRepository(CommonRepository personRepository, AlertRepository
alertRepository, TimelineEventRepository timelineEventRepository); List<CommonPersonObject> all(); CommonPers... | @Test public void testFindByCaseId() { allCommonsRepository.findByCaseID("case 1"); verify(personRepository).findByCaseID("case 1"); } |
AllCommonsRepository { public CommonPersonObject findHHByGOBHHID(String gobhhid) { return personRepository.findHHByGOBHHID(gobhhid); } AllCommonsRepository(CommonRepository personRepository, AlertRepository
alertRepository, TimelineEventRepository timelineEventRepository); List<CommonPersonObject> all(); Co... | @Test public void testFindHHByGOBHHID() { allCommonsRepository.findHHByGOBHHID("gobhhid 1"); verify(personRepository).findHHByGOBHHID("gobhhid 1"); } |
AllCommonsRepository { public List<CommonPersonObject> findByCaseIDs(List<String> caseIds) { return personRepository.findByCaseIDs(caseIds.toArray(new String[caseIds.size()])); } AllCommonsRepository(CommonRepository personRepository, AlertRepository
alertRepository, TimelineEventRepository timelineEventRep... | @Test public void testFindByCaseIds() { List<String> expectedCaseIds = new ArrayList<>(); expectedCaseIds.add("case 1"); expectedCaseIds.add("case 2"); allCommonsRepository.findByCaseIDs(expectedCaseIds); verify(personRepository).findByCaseIDs(new String[] {expectedCaseIds.get(0), expectedCaseIds.get(1)}); } |
AllCommonsRepository { public List<CommonPersonObject> findByRelationalIDs(List<String> RelationalID) { return personRepository .findByRelationalIDs(RelationalID.toArray(new String[RelationalID.size()])); } AllCommonsRepository(CommonRepository personRepository, AlertRepository
alertRepository, TimelineEven... | @Test public void testFindByRelationIds() { List<String> expectedRelationIds = new ArrayList<>(); expectedRelationIds.add("relation id 1"); expectedRelationIds.add("relation id 2"); allCommonsRepository.findByRelationalIDs(expectedRelationIds); verify(personRepository).findByRelationalIDs(new String[] {expectedRelation... |
AllCommonsRepository { public List<CommonPersonObject> findByRelational_IDs(List<String> RelationalID) { return personRepository .findByRelational_IDs(RelationalID.toArray(new String[RelationalID.size()])); } AllCommonsRepository(CommonRepository personRepository, AlertRepository
alertRepository, TimelineEv... | @Test public void testFindByRelationIds2() { List<String> expectedRelationIds = new ArrayList<>(); expectedRelationIds.add("relation id 1"); expectedRelationIds.add("relation id 2"); allCommonsRepository.findByRelational_IDs(expectedRelationIds); verify(personRepository).findByRelational_IDs(new String[] {expectedRelat... |
AllCommonsRepository { public void close(String entityId) { alertRepository.deleteAllAlertsForEntity(entityId); timelineEventRepository.deleteAllTimelineEventsForEntity(entityId); personRepository.close(entityId); } AllCommonsRepository(CommonRepository personRepository, AlertRepository
alertRepository, Tim... | @Test public void testClose() { String entityId = "Entity 1"; allCommonsRepository.close(entityId); verify(alertRepository).deleteAllAlertsForEntity(entityId); verify(timelineEventRepository).deleteAllTimelineEventsForEntity(entityId); verify(personRepository).close(entityId); } |
AllCommonsRepository { public void mergeDetails(String entityId, Map<String, String> details) { personRepository.mergeDetails(entityId, details); } AllCommonsRepository(CommonRepository personRepository, AlertRepository
alertRepository, TimelineEventRepository timelineEventRepository); List<CommonPersonObje... | @Test public void testMergeDetails() { String entityId = "Entity 1"; Map<String, String> details = new HashMap<>(); details.put("case id", "Case 1"); allCommonsRepository.mergeDetails(entityId, details); verify(personRepository).mergeDetails(entityId, details); } |
AllCommonsRepository { public void update(String tableName, ContentValues contentValues, String caseId) { personRepository.updateColumn(tableName, contentValues, caseId); } AllCommonsRepository(CommonRepository personRepository, AlertRepository
alertRepository, TimelineEventRepository timelineEventRepositor... | @Test public void testUpdate() { String tableName = "sprayed_structures"; String caseId = "Case 1"; ContentValues contentValues = new ContentValues(); contentValues.put("status", "Ready"); allCommonsRepository.update(tableName, contentValues, caseId); verify(personRepository).updateColumn(tableName,contentValues,caseId... |
AllCommonsRepository { public List<CommonPersonObject> customQuery(String sql, String[] selections, String tableName) { return personRepository.customQuery(sql, selections, tableName); } AllCommonsRepository(CommonRepository personRepository, AlertRepository
alertRepository, TimelineEventRepository timeline... | @Test public void testCustomQuery() { String tableName = "sprayed_structures"; String sql = "SELECT count(*) FROM sprayed_structures WHERE status = ?"; String[] selectionArgs = {"Complete"}; allCommonsRepository.customQuery(sql, selectionArgs, tableName); verify(personRepository).customQuery(sql, selectionArgs, tableNa... |
AllCommonsRepository { public List<CommonPersonObject> customQueryForCompleteRow(String sql, String[] selections, String tableName) { return personRepository.customQueryForCompleteRow(sql, selections, tableName); } AllCommonsRepository(CommonRepository personRepository, AlertRepository
alertRepository, Time... | @Test public void testCustomQueryForCompleteRow() { String tableName = "sprayed_structures"; String sql = "SELECT count(*) FROM sprayed_structures WHERE status = ?"; String[] selectionArgs = {"Complete"}; allCommonsRepository.customQueryForCompleteRow(sql, selectionArgs, tableName); verify(personRepository).customQuery... |
AllCommonsRepository { public List<String> updateSearch(List<String> caseIds) { List<String> remainingIds = new ArrayList<>(); if (caseIds == null || caseIds.isEmpty()) { return remainingIds; } Map<String, ContentValues> searchMap = new HashMap<String, ContentValues>(); for (String caseId : caseIds) { ContentValues con... | @Test public void testUpdateSearchWithListToRemove() { String caseId = "Case id 1"; String field = "status"; String value = "synced"; String[] listToremove = {"created", "deleted"}; allCommonsRepository.updateSearch(caseId,field,value,listToremove); verify(personRepository).populateSearchValues(caseId,field,value,listT... |
AllCommonsRepository { public boolean deleteSearchRecord(String caseId) { if (StringUtils.isBlank(caseId)) { return false; } return personRepository.deleteSearchRecord(caseId); } AllCommonsRepository(CommonRepository personRepository, AlertRepository
alertRepository, TimelineEventRepository timelineEventRep... | @Test public void testDeleteSearchRecord() { String caseId = "Case id 1"; allCommonsRepository.deleteSearchRecord(caseId); verify(personRepository).deleteSearchRecord(caseId); } |
CommonRepository extends DrishtiRepository { public void add(CommonPersonObject common) { SQLiteDatabase database = masterRepository.getWritableDatabase(); database.insert(TABLE_NAME, null, createValuesFor(common)); } CommonRepository(String tablename, String[] columns); CommonRepository(CommonFtsObject commonFtsObjec... | @Test public void addCallsDatabaseInsert1times() throws Exception { String tablename = ""; String[] tableColumns = new String[]{}; commonRepository = new CommonRepository(tablename, tableColumns); repository = Mockito.mock(Repository.class); sqliteDatabase = Mockito.mock(SQLiteDatabase.class); Mockito.when(repository.g... |
CredentialsHelper { public void saveCredentials(String type, String encryptedPassphrase) { if (CREDENTIALS_TYPE.DB_AUTH.equals(type)) { allSharedPreferences.savePassphrase(encryptedPassphrase, CoreLibrary.getInstance().getSyncConfiguration().getEncryptionParam().name()); allSharedPreferences.setDBEncryptionVersion(Buil... | @Test public void testSaveCredentialsUpdatesSharedPreferencesWithEncryptedPassphrase() { Mockito.doReturn(syncConfiguration).when(coreLibrary).getSyncConfiguration(); Mockito.doReturn(SyncFilter.TEAM_ID).when(syncConfiguration).getEncryptionParam(); credentialsHelper.saveCredentials(CredentialsHelper.CREDENTIALS_TYPE.D... |
CommonRepository extends DrishtiRepository { public CommonPersonObject findByCaseID(String caseId) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = null; try { cursor = database .query(TABLE_NAME, common_TABLE_COLUMNS, ID_COLUMN + " = ?", new String[]{caseId}, null, null, null, null);... | @Test public void findByCaseIDCallsDatabaseQuery1times() throws Exception { String[] columns = new String[]{"id", "relationalid", "details", "is_closed"}; MatrixCursor matrixCursor = new MatrixCursor(columns); matrixCursor.addRow(new Object[]{"caseID", "relationalID", new HashMap<String, String>(), 0}); String tablenam... |
CommonRepository extends DrishtiRepository { public CommonPersonObject findByBaseEntityId(String baseEntityId) { Cursor cursor = null; try { cursor = masterRepository.getReadableDatabase().query(TABLE_NAME, common_TABLE_COLUMNS, BASE_ENTITY_ID_COLUMN + " = ? " + "COLLATE NOCASE ", new String[]{baseEntityId}, null, null... | @Test public void findByBaseEntityIdCallsDatabaseQuery1times() throws Exception { String[] columns = new String[]{"id", "relationalid", "details", "is_closed"}; MatrixCursor matrixCursor = new MatrixCursor(columns); matrixCursor.addRow(new Object[]{"caseID", "relationalID", new HashMap<String, String>(), 0}); String ta... |
CommonRepository extends DrishtiRepository { public CommonPersonObject findHHByGOBHHID(String caseId) { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = null; try { cursor = database .query(TABLE_NAME, common_TABLE_COLUMNS, "FWGOBHHID" + " = ?", new String[]{caseId}, null, null, null, n... | @Test public void findByGOBHHIDCallsDatabaseQuery1times() throws Exception { String[] columns = new String[]{"id", "relationalid", "details", "is_closed"}; MatrixCursor matrixCursor = new MatrixCursor(columns); matrixCursor.addRow(new Object[]{"caseID", "relationalID", new HashMap<String, String>(), 0}); String tablena... |
CommonRepository extends DrishtiRepository { public List<CommonPersonObject> allcommon() { SQLiteDatabase database = masterRepository.getReadableDatabase(); Cursor cursor = null; try { cursor = database .query(TABLE_NAME, common_TABLE_COLUMNS, null, null, null, null, null, null); return readAllcommon(cursor); } finally... | @Test public void allcommonCallsDatabaseQuery1times() throws Exception { String[] columns = new String[]{"id", "relationalid", "details", "is_closed"}; MatrixCursor matrixCursor = new MatrixCursor(columns); matrixCursor.addRow(new Object[]{"caseID", "relationalID", new HashMap<String, String>(), 0}); String tablename =... |
CommonRepository extends DrishtiRepository { public CommonPersonObject readAllcommonforCursorAdapter(Cursor cursor) { int columncount = cursor.getColumnCount(); HashMap<String, String> columns = new HashMap<String, String>(); for (int i = 0; i < columncount; i++) { String columnName = cursor.getColumnName(i); String va... | @Test public void readAllcommonforCursorAdapterReturnsNotNUll() throws Exception { String[] columns = new String[]{"_id", "relationalid", "details", "is_closed"}; MatrixCursor matrixCursor = new MatrixCursor(columns); matrixCursor.addRow(new Object[]{"caseID", "relationalID", new HashMap<String, String>(), 0}); matrixC... |
CommonRepository extends DrishtiRepository { public List<CommonPersonObject> readAllcommonForField(Cursor cursor, String tableName) { List<CommonPersonObject> commons = new ArrayList<CommonPersonObject>(); try { cursor.moveToFirst(); while (!cursor.isAfterLast()) { int columncount = cursor.getColumnCount(); HashMap<Str... | @Test public void readAllcommonforFieldReturnsNotNUll() throws Exception { String[] columns = new String[]{"_id", "relationalid", "details", "is_closed"}; MatrixCursor matrixCursor = new MatrixCursor(columns); matrixCursor.addRow(new Object[]{0, 0, 0, 0}); matrixCursor.addRow(new Object[]{1, 1, 1, 1}); String tablename... |
CommonRepository extends DrishtiRepository { public void updateDetails(String caseId, Map<String, String> details) { SQLiteDatabase database = masterRepository.getWritableDatabase(); CommonPersonObject common = findByCaseID(caseId); if (common == null) { return; } ContentValues valuesToUpdate = new ContentValues(); val... | @Test public void updateDetailsCallsDatabaseUpdate1Times() throws Exception { String[] columns = new String[]{"id", "relationalid", "details", "is_closed"}; MatrixCursor matrixCursor = new MatrixCursor(columns); matrixCursor.addRow(new Object[]{"caseID", "relationalID", new HashMap<String, String>(), 0}); matrixCursor.... |
CommonRepository extends DrishtiRepository { public void mergeDetails(String caseId, Map<String, String> details) { SQLiteDatabase database = masterRepository.getWritableDatabase(); CommonPersonObject common = findByCaseID(caseId); if (common == null) { return; } Map<String, String> mergedDetails = new HashMap<String, ... | @Test public void mergeDetailsCallsDatabaseUpdate1Times() throws Exception { String[] columns = new String[]{"id", "relationalid", "details", "is_closed"}; MatrixCursor matrixCursor = new MatrixCursor(columns); matrixCursor.addRow(new Object[]{"caseID", "relationalID", new HashMap<String, String>(), 0}); matrixCursor.a... |
CommonRepository extends DrishtiRepository { @Override public void onCreate(SQLiteDatabase database) { database.execSQL(common_SQL); if (StringUtils.isNotBlank(common_ID_INDEX_SQL)) { database.execSQL(common_ID_INDEX_SQL); } if (StringUtils.isNotBlank(common_Relational_ID_INDEX_SQL)) { database.execSQL(common_Relationa... | @Test public void assertOnCreateCallsDatabaseExec() { String tablename = ""; String[] tableColumns = new String[]{CommonRepository.Relational_Underscore_ID, CommonRepository.BASE_ENTITY_ID_COLUMN, ADDITIONALCOLUMN, CUSTOMRELATIONALID}; commonFtsObject = Mockito.mock(CommonFtsObject.class); Mockito.when(commonFtsObject.... |
CommonRepository extends DrishtiRepository { public void closeCase(String baseEntityId, String tableName) { try { SQLiteDatabase db = masterRepository.getWritableDatabase(); ContentValues cv = new ContentValues(); cv.put(IS_CLOSED_COLUMN, 1); db.update(tableName, cv, BASE_ENTITY_ID_COLUMN + "=?", new String[]{baseEntit... | @Test public void assertCloseCaseCallsDatabaseExec() { String tablename = "table"; String baseEntityId = "1"; String[] tableColumns = new String[]{CommonRepository.Relational_Underscore_ID, CommonRepository.BASE_ENTITY_ID_COLUMN, ADDITIONALCOLUMN, CUSTOMRELATIONALID}; commonFtsObject = Mockito.mock(CommonFtsObject.clas... |
CommonRepository extends DrishtiRepository { public boolean deleteCase(String baseEntityId, String tableName) { try { SQLiteDatabase db = masterRepository.getWritableDatabase(); int afftectedRows = db .delete(tableName, BASE_ENTITY_ID_COLUMN + " = ? COLLATE NOCASE" + " ", new String[]{baseEntityId}); if (afftectedRows ... | @Test public void assertDeleteCaseCallsDatabaseExec() { String tablename = "table"; String baseEntityId = "1"; String[] tableColumns = new String[]{CommonRepository.Relational_Underscore_ID, CommonRepository.BASE_ENTITY_ID_COLUMN, ADDITIONALCOLUMN, CUSTOMRELATIONALID}; commonFtsObject = Mockito.mock(CommonFtsObject.cla... |
CommonRepository extends DrishtiRepository { public ArrayList<HashMap<String, String>> rawQuery(String sql, String[] selectionArgs) { ArrayList<HashMap<String, String>> maplist = new ArrayList<HashMap<String, String>>(); Cursor cursor = null; try { SQLiteDatabase database = masterRepository.getReadableDatabase(); curso... | @Test public void assertRawQueryReturnsMap() { String[] columns = new String[]{"id", "relationalid", "details", "is_closed"}; MatrixCursor cursor = new MatrixCursor(columns); cursor.addRow(new Object[]{"caseID", "relationalID", "dd1", "0"}); cursor.addRow(new Object[]{"caseID2", "relationalID2", "dd2", "0"}); String ta... |
CommonRepository extends DrishtiRepository { public boolean deleteSearchRecord(String caseId) { SQLiteDatabase database = masterRepository.getWritableDatabase(); database.beginTransaction(); String ftsSearchTable = CommonFtsObject.searchTableName(TABLE_NAME); try { int afftectedRows = database .delete(ftsSearchTable, C... | @Test public void deleteSearchRecordShouldReturnTrueAndCommitTransaction() { String tablename = "ec_client"; String[] tableColumns = new String[]{}; commonRepository = new CommonRepository(tablename, tableColumns); repository = Mockito.mock(Repository.class); sqliteDatabase = Mockito.mock(SQLiteDatabase.class); Mockito... |
CommonRepository extends DrishtiRepository { public boolean searchBatchInserts(Map<String, ContentValues> searchMap) { SQLiteDatabase database = masterRepository.getWritableDatabase(); database.beginTransaction(); String ftsSearchTable = CommonFtsObject.searchTableName(TABLE_NAME); try { for (String caseId : searchMap.... | @Test public void searchBatchInsertsShouldReturnFalse() { HashMap<String, ContentValues> searchMap = new HashMap<>(); ContentValues contentValues = new ContentValues(); searchMap.put("sample-case-id", contentValues); Mockito.doThrow(new SQLException("Some exception")).when(sqliteDatabase).insert(Mockito.eq(tablename + ... |
CommonFtsObject { public static String searchTableName(String table) { return table + "_search"; } CommonFtsObject(String[] tables); static String searchTableName(String table); void updateSearchFields(String table, String[] searchFields); void updateSortFields(String table, String[] sortFields); void updateMainConditi... | @Test public void testSearchTableNameShouldReturnCorrectSearchTableName() { assertEquals("table1_search", commonFtsObject.searchTableName("table1")); } |
CommonFtsObject { public boolean containsTable(String table) { if (tables == null || StringUtils.isBlank(table)) { return false; } List<String> tableList = Arrays.asList(tables); return tableList.contains(table); } CommonFtsObject(String[] tables); static String searchTableName(String table); void updateSearchFields(St... | @Test public void testContainsTableShouldReturnCorrectStatus() { assertTrue(commonFtsObject.containsTable("table1")); assertFalse(commonFtsObject.containsTable("table100")); } |
CommonFtsObject { public String[] getTables() { if (tables == null) { tables = ArrayUtils.EMPTY_STRING_ARRAY; } return tables; } CommonFtsObject(String[] tables); static String searchTableName(String table); void updateSearchFields(String table, String[] searchFields); void updateSortFields(String table, String[] sortF... | @Test public void testGetTablesShouldGetAllTables() { assertEquals(tables, commonFtsObject.getTables()); } |
CommonObjectFilterOption implements FilterOption { @Override public boolean filter(SmartRegisterClient client) { switch (byColumnAndByDetails) { case byColumn: return ((CommonPersonObjectClient) client).getColumnmaps().get(fieldname). contains(criteria); case byDetails: return (((CommonPersonObjectClient) client).getDe... | @Test public void testFilterByColumn() { Map<String, String> column1 = EasyMap.create("name", "Woman A").map(); CommonPersonObjectClient expectedClient = new CommonPersonObjectClient("entity id 1", emptyMap, "Woman A"); expectedClient.setColumnmaps(column1); boolean filter = commonObjectFilterOption.filter(expectedClie... |
CredentialsHelper { public PasswordHash generateLocalAuthCredentials(char[] password) throws InvalidKeySpecException, NoSuchAlgorithmException { if (password == null) return null; return SecurityHelper.getPasswordHash(password); } CredentialsHelper(Context context); static boolean shouldMigrate(); byte[] getCredentials... | @Test public void generateLocalAuthCredentials() throws Exception { Assert.assertNotNull(credentialsHelper); PowerMockito.mockStatic(SecurityHelper.class); PowerMockito.when(SecurityHelper.getPasswordHash(TEST_DUMMY_PASSWORD)).thenReturn(null); credentialsHelper.generateLocalAuthCredentials(TEST_DUMMY_PASSWORD); PowerM... |
CommonObjectFilterOption implements FilterOption { @Override public String name() { return filterOptionName; } CommonObjectFilterOption(String criteriaArg, String fieldnameArg, ByColumnAndByDetails
byColumnAndByDetailsArg, String filteroptionnameArg); @Override String name(); @Override boolean filter(SmartR... | @Test public void testFilterOptionName() { assertEquals(filterOptionName, commonObjectFilterOption.name()); } |
CommonPersonObjectController { public String get() { return cache.get(person_CLIENTS_LIST, new CacheableData<String>() { @Override public String fetch() { List<CommonPersonObject> p = allpersonobjects.all(); updateDetails(p); CommonPersonObjectClients pClients = new CommonPersonObjectClients(); if (filtermap != null) {... | @Test public void shouldSortECsByName() throws Exception { Map<String, String> personDetails1 = EasyMap.create("name", "Woman A").map(); Map<String, String> personDetails2 = EasyMap.create("name", "Woman B").map(); Map<String, String> personDetails3 = EasyMap.create("name", "Woman C").map(); CommonPersonObject cpo2 = n... |
AccountHelper { public static Account getOauthAccountByNameAndType(String accountName, String accountType) { Account[] accounts = accountManager.getAccountsByType(accountType); return accounts.length > 0 ? selectAccount(accounts, accountName) : null; } static Account getOauthAccountByNameAndType(String accountName, St... | @Test public void testGetOauthAccountByType() { Account account = AccountHelper.getOauthAccountByNameAndType(CORE_ACCOUNT_NAME, CORE_ACCOUNT_TYPE); Assert.assertNotNull(account); Assert.assertEquals(CORE_ACCOUNT_NAME, account.name); } |
AccountHelper { public static String getAccountManagerValue(String key, String accountName, String accountType) { Account account = AccountHelper.getOauthAccountByNameAndType(accountName, accountType); if (account != null) { return accountManager.getUserData(account, key); } return null; } static Account getOauthAccou... | @Test public void testGetAccountManagerValue() { Whitebox.setInternalState(AccountHelper.class, "accountManager", accountManager); Mockito.doReturn(TEST_VALUE).when(accountManager).getUserData(ArgumentMatchers.any(Account.class), ArgumentMatchers.eq(TEST_KEY)); String value = AccountHelper.getAccountManagerValue(TEST_K... |
AccountHelper { public static String getOAuthToken(String accountName, String accountType, String authTokenType) { Account account = getOauthAccountByNameAndType(accountName, accountType); try { return accountManager.blockingGetAuthToken(account, authTokenType, true); } catch (Exception ex) { Timber.e(ex, "EXCEPTION: %... | @Test public void testGetOAuthToken() throws AuthenticatorException, OperationCanceledException, IOException { Mockito.doReturn(TEST_TOKEN_VALUE).when(accountManager).blockingGetAuthToken(new Account(CORE_ACCOUNT_NAME, CORE_ACCOUNT_TYPE), AUTH_TOKEN_TYPE, true); String myToken = AccountHelper.getOAuthToken(CORE_ACCOUNT... |
AccountHelper { public static void invalidateAuthToken(String accountType, String authToken) { if (authToken != null) accountManager.invalidateAuthToken(accountType, authToken); } static Account getOauthAccountByNameAndType(String accountName, String accountType); static Account selectAccount(Account[] accounts, Strin... | @Test public void testInvalidateAuthToken() { AccountHelper.invalidateAuthToken(CORE_ACCOUNT_TYPE, TEST_TOKEN_VALUE); Mockito.verify(accountManager).invalidateAuthToken(CORE_ACCOUNT_TYPE, TEST_TOKEN_VALUE); } |
AccountHelper { public static String getCachedOAuthToken(String accountName, String accountType, String authTokenType) { Account account = getOauthAccountByNameAndType(accountName, accountType); return account != null ? accountManager.peekAuthToken(account, authTokenType) : null; } static Account getOauthAccountByName... | @Test public void testGetCachedOAuthToken() { Account account = new Account(CORE_ACCOUNT_NAME, CORE_ACCOUNT_TYPE); Mockito.doReturn(TEST_TOKEN_VALUE).when(accountManager).peekAuthToken(account, AUTH_TOKEN_TYPE); String cachedAuthToken = AccountHelper.getCachedOAuthToken(CORE_ACCOUNT_NAME, CORE_ACCOUNT_TYPE, AUTH_TOKEN_... |
CredentialsHelper { public byte[] generateDBCredentials(char[] password, LoginResponseData userInfo) { char[] encryptionParamValue = null; SyncConfiguration syncConfiguration = CoreLibrary.getInstance().getSyncConfiguration(); if (syncConfiguration.getEncryptionParam() != null) { SyncFilter syncFilter = syncConfigurati... | @Test public void testGenerateDBCredentialsReturnsCorrectBytesForSyncByProvider() { Mockito.doReturn(SyncFilter.PROVIDER).when(syncConfiguration).getEncryptionParam(); byte[] bytes = credentialsHelper.generateDBCredentials(TEST_DUMMY_PASSWORD, userInfo); Assert.assertTrue(Arrays.equals(SecurityHelper.toBytes(TEST_DUMMY... |
AccountHelper { public static AccountManagerFuture<Bundle> reAuthenticateUserAfterSessionExpired(String accountName, String accountType, String authTokenType) { Account account = getOauthAccountByNameAndType(accountName, accountType); return accountManager.updateCredentials(account, authTokenType, null, null, null, nul... | @Test public void testReAuthenticateUserAfterSessionExpired() { Account account = new Account(CORE_ACCOUNT_NAME, CORE_ACCOUNT_TYPE); Mockito.doReturn(Mockito.mock(AccountManagerFuture.class)).when(accountManager).updateCredentials(account, AUTH_TOKEN_TYPE, null, null, null, null); AccountManagerFuture<Bundle> reAuthent... |
RecyclerViewPaginatedAdapter extends RecyclerViewCursorAdapter { @NonNull @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { if (viewType == RecyclerViewCursorAdapter.Type.FOOTER.ordinal()) { return listItemProvider.createFooterHolder(parent); } else { return listItemProvider.... | @Test public void testOnCreateViewHolder() { LinearLayout vg = new LinearLayout(context); when(listItemProvider.createViewHolder(any())).thenReturn(mockViewHolder); RecyclerView.ViewHolder actualViewHolder = adapter.onCreateViewHolder(vg, RecyclerViewCursorAdapter.Type.ITEM.ordinal()); assertNotNull(actualViewHolder); ... |
RecyclerViewPaginatedAdapter extends RecyclerViewCursorAdapter { @Override public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, Cursor cursor) { if (listItemProvider.isFooterViewHolder(viewHolder)) { listItemProvider.getFooterView(viewHolder, getCurrentPageCount(), getTotalPageCount(), hasNextPage(), hasPre... | @Test public void testOnBindViewHolder() { String name = "John"; Map<String, String> details = new HashMap<>(); details.put("FWHOHFNAME", name); Map<String, String> columnmaps = new HashMap<>(); String idColumn = "baseEntityId"; columnmaps.put("id", idColumn); String caseId = "case 1"; String relationId = "identifier 1... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.