target stringlengths 20 113k | src_fm stringlengths 11 86.3k | src_fm_fc stringlengths 21 86.4k | src_fm_fc_co stringlengths 30 86.4k | src_fm_fc_ms stringlengths 42 86.8k | src_fm_fc_ms_ff stringlengths 43 86.8k |
|---|---|---|---|---|---|
@Test public void testGetParentLocationIdForNsaloGirlsSchool() throws Exception { ANMLocationController anmLocationController = Mockito.spy(CoreLibrary.getInstance().context().anmLocationController()); ReflectionHelpers.setField(CoreLibrary.getInstance().context(), "anmLocationController", anmLocationController); Mocki... | public static LocationHelper getInstance() { return instance; } | LocationHelper { public static LocationHelper getInstance() { return instance; } } | LocationHelper { public static LocationHelper getInstance() { return instance; } private LocationHelper(List<String> allowedLevels, String defaultLocationLevel); private LocationHelper(List<String> allowedLevels, String defaultLocationLevel, List<String> advancedDataCaptureStrategies); } | LocationHelper { public static LocationHelper getInstance() { return instance; } private LocationHelper(List<String> allowedLevels, String defaultLocationLevel); private LocationHelper(List<String> allowedLevels, String defaultLocationLevel, List<String> advancedDataCaptureStrategies); static void init(List<String> a... | LocationHelper { public static LocationHelper getInstance() { return instance; } private LocationHelper(List<String> allowedLevels, String defaultLocationLevel); private LocationHelper(List<String> allowedLevels, String defaultLocationLevel, List<String> advancedDataCaptureStrategies); static void init(List<String> a... |
@Test public void testGetParentLocationIdForJambulaGirlsSchool() throws Exception { ANMLocationController anmLocationController = Mockito.spy(CoreLibrary.getInstance().context().anmLocationController()); ReflectionHelpers.setField(CoreLibrary.getInstance().context(), "anmLocationController", anmLocationController); Moc... | public static LocationHelper getInstance() { return instance; } | LocationHelper { public static LocationHelper getInstance() { return instance; } } | LocationHelper { public static LocationHelper getInstance() { return instance; } private LocationHelper(List<String> allowedLevels, String defaultLocationLevel); private LocationHelper(List<String> allowedLevels, String defaultLocationLevel, List<String> advancedDataCaptureStrategies); } | LocationHelper { public static LocationHelper getInstance() { return instance; } private LocationHelper(List<String> allowedLevels, String defaultLocationLevel); private LocationHelper(List<String> allowedLevels, String defaultLocationLevel, List<String> advancedDataCaptureStrategies); static void init(List<String> a... | LocationHelper { public static LocationHelper getInstance() { return instance; } private LocationHelper(List<String> allowedLevels, String defaultLocationLevel); private LocationHelper(List<String> allowedLevels, String defaultLocationLevel, List<String> advancedDataCaptureStrategies); static void init(List<String> a... |
@Test public void testGetParentLocationIdForBukesaUrbanHealthCentre() throws Exception { ANMLocationController anmLocationController = Mockito.spy(CoreLibrary.getInstance().context().anmLocationController()); ReflectionHelpers.setField(CoreLibrary.getInstance().context(), "anmLocationController", anmLocationController)... | public static LocationHelper getInstance() { return instance; } | LocationHelper { public static LocationHelper getInstance() { return instance; } } | LocationHelper { public static LocationHelper getInstance() { return instance; } private LocationHelper(List<String> allowedLevels, String defaultLocationLevel); private LocationHelper(List<String> allowedLevels, String defaultLocationLevel, List<String> advancedDataCaptureStrategies); } | LocationHelper { public static LocationHelper getInstance() { return instance; } private LocationHelper(List<String> allowedLevels, String defaultLocationLevel); private LocationHelper(List<String> allowedLevels, String defaultLocationLevel, List<String> advancedDataCaptureStrategies); static void init(List<String> a... | LocationHelper { public static LocationHelper getInstance() { return instance; } private LocationHelper(List<String> allowedLevels, String defaultLocationLevel); private LocationHelper(List<String> allowedLevels, String defaultLocationLevel, List<String> advancedDataCaptureStrategies); static void init(List<String> a... |
@Test public void testLocationIdsFromHierarchy() { AllSettings allSettings = Mockito.spy(CoreLibrary.getInstance().context().allSettings()); ReflectionHelpers.setField(CoreLibrary.getInstance().context(), "allSettings", allSettings); SettingsRepository settingsRepository = ReflectionHelpers.getField(allSettings, "setti... | public String locationIdsFromHierarchy() { if (Utils.isEmptyCollection(locationIds)) { locationIds = locationsFromHierarchy(true, null); } if (!Utils.isEmptyCollection(locationIds)) { return StringUtils.join(locationIds, ","); } return null; } | LocationHelper { public String locationIdsFromHierarchy() { if (Utils.isEmptyCollection(locationIds)) { locationIds = locationsFromHierarchy(true, null); } if (!Utils.isEmptyCollection(locationIds)) { return StringUtils.join(locationIds, ","); } return null; } } | LocationHelper { public String locationIdsFromHierarchy() { if (Utils.isEmptyCollection(locationIds)) { locationIds = locationsFromHierarchy(true, null); } if (!Utils.isEmptyCollection(locationIds)) { return StringUtils.join(locationIds, ","); } return null; } private LocationHelper(List<String> allowedLevels, String ... | LocationHelper { public String locationIdsFromHierarchy() { if (Utils.isEmptyCollection(locationIds)) { locationIds = locationsFromHierarchy(true, null); } if (!Utils.isEmptyCollection(locationIds)) { return StringUtils.join(locationIds, ","); } return null; } private LocationHelper(List<String> allowedLevels, String ... | LocationHelper { public String locationIdsFromHierarchy() { if (Utils.isEmptyCollection(locationIds)) { locationIds = locationsFromHierarchy(true, null); } if (!Utils.isEmptyCollection(locationIds)) { return StringUtils.join(locationIds, ","); } return null; } private LocationHelper(List<String> allowedLevels, String ... |
@Test public void testGenerateDefaultLocationHierarchy() { ArrayList<String> allowedLevels = new ArrayList<>(); allowedLevels.add("District"); allowedLevels.add("Rural Health Centre"); allowedLevels.add("Village"); allowedLevels.add("Canton"); allowedLevels.add("Sub-district"); AllSharedPreferences spiedAllSharedPrefer... | public List<String> generateDefaultLocationHierarchy(List<String> allowedLevels) { if (Utils.isEmptyCollection(allowedLevels)) { return new ArrayList<>(); } try { String defaultLocationUuid = allSharedPreferences.fetchDefaultLocalityId(allSharedPreferences.fetchRegisteredANM()); LinkedHashMap<String, TreeNode<String, L... | LocationHelper { public List<String> generateDefaultLocationHierarchy(List<String> allowedLevels) { if (Utils.isEmptyCollection(allowedLevels)) { return new ArrayList<>(); } try { String defaultLocationUuid = allSharedPreferences.fetchDefaultLocalityId(allSharedPreferences.fetchRegisteredANM()); LinkedHashMap<String, T... | LocationHelper { public List<String> generateDefaultLocationHierarchy(List<String> allowedLevels) { if (Utils.isEmptyCollection(allowedLevels)) { return new ArrayList<>(); } try { String defaultLocationUuid = allSharedPreferences.fetchDefaultLocalityId(allSharedPreferences.fetchRegisteredANM()); LinkedHashMap<String, T... | LocationHelper { public List<String> generateDefaultLocationHierarchy(List<String> allowedLevels) { if (Utils.isEmptyCollection(allowedLevels)) { return new ArrayList<>(); } try { String defaultLocationUuid = allSharedPreferences.fetchDefaultLocalityId(allSharedPreferences.fetchRegisteredANM()); LinkedHashMap<String, T... | LocationHelper { public List<String> generateDefaultLocationHierarchy(List<String> allowedLevels) { if (Utils.isEmptyCollection(allowedLevels)) { return new ArrayList<>(); } try { String defaultLocationUuid = allSharedPreferences.fetchDefaultLocalityId(allSharedPreferences.fetchRegisteredANM()); LinkedHashMap<String, T... |
@Test public void testGenerateLocationHierarchyTreeShouldReturnEmptyList() { String locationData = anmLocation1; ArrayList<String> allowedLevels = new ArrayList<>(); allowedLevels.add("Canton"); LinkedHashMap<String, TreeNode<String, Location>> map = AssetHandler.jsonStringToJava(locationData, LocationTree.class).getLo... | public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } | LocationHelper { public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } } | LocationHelper { public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } private LocationHelper(List<String> allowedLevels, ... | LocationHelper { public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } private LocationHelper(List<String> allowedLevels, ... | LocationHelper { public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } private LocationHelper(List<String> allowedLevels, ... |
@Test public void testGenerateLocationHierarchyTreeWithMapShouldReturnListWithOtherFormLocationOnly() { locationHelper = Mockito.spy(locationHelper); String locationData = anmLocation1; ArrayList<String> allowedLevels = new ArrayList<>(); allowedLevels.add("Canton"); LinkedHashMap<String, TreeNode<String, Location>> ma... | public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } | LocationHelper { public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } } | LocationHelper { public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } private LocationHelper(List<String> allowedLevels, ... | LocationHelper { public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } private LocationHelper(List<String> allowedLevels, ... | LocationHelper { public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } private LocationHelper(List<String> allowedLevels, ... |
@Test public void testGenerateLocationHierarchyTreeWithMapAndOtherOptionFalseShouldReturnEmptyList() { locationHelper = Mockito.spy(locationHelper); String locationData = anmLocation1; ArrayList<String> allowedLevels = new ArrayList<>(); allowedLevels.add("Canton"); LinkedHashMap<String, TreeNode<String, Location>> map... | public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } | LocationHelper { public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } } | LocationHelper { public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } private LocationHelper(List<String> allowedLevels, ... | LocationHelper { public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } private LocationHelper(List<String> allowedLevels, ... | LocationHelper { public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } private LocationHelper(List<String> allowedLevels, ... |
@Test public void shouldReturnString10WhenStringValueIs10() { String value = IntegerUtil.tryParse("10", "0"); Assert.assertEquals(value, "10"); } | public static Integer tryParse(String value, int defaultValue) { try { return Integer.parseInt(value); } catch (NumberFormatException e) { return defaultValue; } } | IntegerUtil { public static Integer tryParse(String value, int defaultValue) { try { return Integer.parseInt(value); } catch (NumberFormatException e) { return defaultValue; } } } | IntegerUtil { public static Integer tryParse(String value, int defaultValue) { try { return Integer.parseInt(value); } catch (NumberFormatException e) { return defaultValue; } } } | IntegerUtil { public static Integer tryParse(String value, int defaultValue) { try { return Integer.parseInt(value); } catch (NumberFormatException e) { return defaultValue; } } static Integer tryParse(String value, int defaultValue); static String tryParse(String value, String defaultValue); static int compare(int lh... | IntegerUtil { public static Integer tryParse(String value, int defaultValue) { try { return Integer.parseInt(value); } catch (NumberFormatException e) { return defaultValue; } } static Integer tryParse(String value, int defaultValue); static String tryParse(String value, String defaultValue); static int compare(int lh... |
@Test public void testGenerateLocationHierarchyTreeWithMapShouldReturnListWithZambiaFormLocation() { locationHelper = Mockito.spy(locationHelper); String locationData = anmLocation1; ArrayList<String> allowedLevels = new ArrayList<>(); allowedLevels.add("Country"); allowedLevels.add("Province"); allowedLevels.add("Regi... | public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } | LocationHelper { public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } } | LocationHelper { public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } private LocationHelper(List<String> allowedLevels, ... | LocationHelper { public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } private LocationHelper(List<String> allowedLevels, ... | LocationHelper { public List<FormLocation> generateLocationHierarchyTree(boolean withOtherOption, List<String> allowedLevels) { LinkedHashMap<String, TreeNode<String, Location>> map = map(); return generateLocationHierarchyTree(withOtherOption, allowedLevels, map); } private LocationHelper(List<String> allowedLevels, ... |
@Test public void testGetOpenMrsReadableName() { assertEquals("Zambia", locationHelper.getOpenMrsReadableName("ra Zambia")); } | public String getOpenMrsReadableName(String name) { if (StringUtils.isBlank(name)) { return ""; } String readableName = name; try { Pattern prefixPattern = Pattern.compile("^[a-z]{2} (.*)$"); Matcher prefixMatcher = prefixPattern.matcher(readableName); if (prefixMatcher.find()) { readableName = prefixMatcher.group(1); ... | LocationHelper { public String getOpenMrsReadableName(String name) { if (StringUtils.isBlank(name)) { return ""; } String readableName = name; try { Pattern prefixPattern = Pattern.compile("^[a-z]{2} (.*)$"); Matcher prefixMatcher = prefixPattern.matcher(readableName); if (prefixMatcher.find()) { readableName = prefixM... | LocationHelper { public String getOpenMrsReadableName(String name) { if (StringUtils.isBlank(name)) { return ""; } String readableName = name; try { Pattern prefixPattern = Pattern.compile("^[a-z]{2} (.*)$"); Matcher prefixMatcher = prefixPattern.matcher(readableName); if (prefixMatcher.find()) { readableName = prefixM... | LocationHelper { public String getOpenMrsReadableName(String name) { if (StringUtils.isBlank(name)) { return ""; } String readableName = name; try { Pattern prefixPattern = Pattern.compile("^[a-z]{2} (.*)$"); Matcher prefixMatcher = prefixPattern.matcher(readableName); if (prefixMatcher.find()) { readableName = prefixM... | LocationHelper { public String getOpenMrsReadableName(String name) { if (StringUtils.isBlank(name)) { return ""; } String readableName = name; try { Pattern prefixPattern = Pattern.compile("^[a-z]{2} (.*)$"); Matcher prefixMatcher = prefixPattern.matcher(readableName); if (prefixMatcher.find()) { readableName = prefixM... |
@Test public void testGetOpenMrsLocationName() { ANMLocationController anmLocationController = Mockito.spy(CoreLibrary.getInstance().context().anmLocationController()); ReflectionHelpers.setField(CoreLibrary.getInstance().context(), "anmLocationController", anmLocationController); Mockito.doReturn(anmLocation2) .when(a... | public String getOpenMrsLocationName(String locationId) { if (StringUtils.isBlank(locationId)) { Timber.e("Location id is null"); return null; } String response = locationId; try { LinkedHashMap<String, TreeNode<String, Location>> map = map(); if (!Utils.isEmptyMap(map)) { for (Map.Entry<String, TreeNode<String, Locati... | LocationHelper { public String getOpenMrsLocationName(String locationId) { if (StringUtils.isBlank(locationId)) { Timber.e("Location id is null"); return null; } String response = locationId; try { LinkedHashMap<String, TreeNode<String, Location>> map = map(); if (!Utils.isEmptyMap(map)) { for (Map.Entry<String, TreeNo... | LocationHelper { public String getOpenMrsLocationName(String locationId) { if (StringUtils.isBlank(locationId)) { Timber.e("Location id is null"); return null; } String response = locationId; try { LinkedHashMap<String, TreeNode<String, Location>> map = map(); if (!Utils.isEmptyMap(map)) { for (Map.Entry<String, TreeNo... | LocationHelper { public String getOpenMrsLocationName(String locationId) { if (StringUtils.isBlank(locationId)) { Timber.e("Location id is null"); return null; } String response = locationId; try { LinkedHashMap<String, TreeNode<String, Location>> map = map(); if (!Utils.isEmptyMap(map)) { for (Map.Entry<String, TreeNo... | LocationHelper { public String getOpenMrsLocationName(String locationId) { if (StringUtils.isBlank(locationId)) { Timber.e("Location id is null"); return null; } String response = locationId; try { LinkedHashMap<String, TreeNode<String, Location>> map = map(); if (!Utils.isEmptyMap(map)) { for (Map.Entry<String, TreeNo... |
@Test public void testGetAdvancedDataCaptureStrategies() { ReflectionHelpers.setStaticField(LocationHelper.class, "instance", null); String advancedDataStrategyType = "Mobile Clinic"; ArrayList<String> allowedLevels = new ArrayList<>(); allowedLevels.add("County"); allowedLevels.add("Ward"); allowedLevels.add("Facility... | public List<String> getAdvancedDataCaptureStrategies() { return ADVANCED_DATA_CAPTURE_LEVELS; } | LocationHelper { public List<String> getAdvancedDataCaptureStrategies() { return ADVANCED_DATA_CAPTURE_LEVELS; } } | LocationHelper { public List<String> getAdvancedDataCaptureStrategies() { return ADVANCED_DATA_CAPTURE_LEVELS; } private LocationHelper(List<String> allowedLevels, String defaultLocationLevel); private LocationHelper(List<String> allowedLevels, String defaultLocationLevel, List<String> advancedDataCaptureStrategies);... | LocationHelper { public List<String> getAdvancedDataCaptureStrategies() { return ADVANCED_DATA_CAPTURE_LEVELS; } private LocationHelper(List<String> allowedLevels, String defaultLocationLevel); private LocationHelper(List<String> allowedLevels, String defaultLocationLevel, List<String> advancedDataCaptureStrategies);... | LocationHelper { public List<String> getAdvancedDataCaptureStrategies() { return ADVANCED_DATA_CAPTURE_LEVELS; } private LocationHelper(List<String> allowedLevels, String defaultLocationLevel); private LocationHelper(List<String> allowedLevels, String defaultLocationLevel, List<String> advancedDataCaptureStrategies);... |
@Test public void testGetDateFormat() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date now = new Date(); Assert.assertEquals(sdf.format(now), AbstractDao.getDobDateFormat().format(now)); } | public static SimpleDateFormat getDobDateFormat() { if (DOB_DATE_FORMAT == null) DOB_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); return DOB_DATE_FORMAT; } | AbstractDao { public static SimpleDateFormat getDobDateFormat() { if (DOB_DATE_FORMAT == null) DOB_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); return DOB_DATE_FORMAT; } } | AbstractDao { public static SimpleDateFormat getDobDateFormat() { if (DOB_DATE_FORMAT == null) DOB_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); return DOB_DATE_FORMAT; } } | AbstractDao { public static SimpleDateFormat getDobDateFormat() { if (DOB_DATE_FORMAT == null) DOB_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); return DOB_DATE_FORMAT; } static SimpleDateFormat getDobDateFormat(); static SimpleDateFormat getNativeFormsDateFormat(); static @Nullable List<Map<String... | AbstractDao { public static SimpleDateFormat getDobDateFormat() { if (DOB_DATE_FORMAT == null) DOB_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); return DOB_DATE_FORMAT; } static SimpleDateFormat getDobDateFormat(); static SimpleDateFormat getNativeFormsDateFormat(); static @Nullable List<Map<String... |
@Test public void testGetNativeFormsDateFormat() { SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); Date now = new Date(); Assert.assertEquals(sdf.format(now), AbstractDao.getNativeFormsDateFormat().format(now)); } | public static SimpleDateFormat getNativeFormsDateFormat() { if (NATIVE_FORMS_DATE_FORMAT == null) NATIVE_FORMS_DATE_FORMAT = new SimpleDateFormat("dd-MM-yyyy", Locale.ENGLISH); return NATIVE_FORMS_DATE_FORMAT; } | AbstractDao { public static SimpleDateFormat getNativeFormsDateFormat() { if (NATIVE_FORMS_DATE_FORMAT == null) NATIVE_FORMS_DATE_FORMAT = new SimpleDateFormat("dd-MM-yyyy", Locale.ENGLISH); return NATIVE_FORMS_DATE_FORMAT; } } | AbstractDao { public static SimpleDateFormat getNativeFormsDateFormat() { if (NATIVE_FORMS_DATE_FORMAT == null) NATIVE_FORMS_DATE_FORMAT = new SimpleDateFormat("dd-MM-yyyy", Locale.ENGLISH); return NATIVE_FORMS_DATE_FORMAT; } } | AbstractDao { public static SimpleDateFormat getNativeFormsDateFormat() { if (NATIVE_FORMS_DATE_FORMAT == null) NATIVE_FORMS_DATE_FORMAT = new SimpleDateFormat("dd-MM-yyyy", Locale.ENGLISH); return NATIVE_FORMS_DATE_FORMAT; } static SimpleDateFormat getDobDateFormat(); static SimpleDateFormat getNativeFormsDateFormat(... | AbstractDao { public static SimpleDateFormat getNativeFormsDateFormat() { if (NATIVE_FORMS_DATE_FORMAT == null) NATIVE_FORMS_DATE_FORMAT = new SimpleDateFormat("dd-MM-yyyy", Locale.ENGLISH); return NATIVE_FORMS_DATE_FORMAT; } static SimpleDateFormat getDobDateFormat(); static SimpleDateFormat getNativeFormsDateFormat(... |
@Test public void testObjectsConstructedEqualsCursorSize() { MatrixCursor cursor = new MatrixCursor(new String[]{"count"}); cursor.addRow(new Object[]{"1"}); Mockito.doReturn(cursor).when(sqLiteDatabase).rawQuery(Mockito.anyString(), Mockito.any(String[].class)); SampleAbstractDaoImp.setRepository(repository); int coun... | protected static void setRepository(Repository repository) { AbstractDao.repository = repository; } | AbstractDao { protected static void setRepository(Repository repository) { AbstractDao.repository = repository; } } | AbstractDao { protected static void setRepository(Repository repository) { AbstractDao.repository = repository; } } | AbstractDao { protected static void setRepository(Repository repository) { AbstractDao.repository = repository; } static SimpleDateFormat getDobDateFormat(); static SimpleDateFormat getNativeFormsDateFormat(); static @Nullable List<Map<String, Object>> readData(String query, String[] selectionArgs); } | AbstractDao { protected static void setRepository(Repository repository) { AbstractDao.repository = repository; } static SimpleDateFormat getDobDateFormat(); static SimpleDateFormat getNativeFormsDateFormat(); static @Nullable List<Map<String, Object>> readData(String query, String[] selectionArgs); } |
@Test public void testErrorInSerializationReturnsNull() { MatrixCursor cursor = new MatrixCursor(new String[]{"count"}); cursor.addRow(new Object[]{"1"}); Mockito.doReturn(cursor).when(sqLiteDatabase).rawQuery(Mockito.anyString(), Mockito.any(String[].class)); SampleAbstractDaoImp.setRepository(repository); List<Alert>... | protected static void setRepository(Repository repository) { AbstractDao.repository = repository; } | AbstractDao { protected static void setRepository(Repository repository) { AbstractDao.repository = repository; } } | AbstractDao { protected static void setRepository(Repository repository) { AbstractDao.repository = repository; } } | AbstractDao { protected static void setRepository(Repository repository) { AbstractDao.repository = repository; } static SimpleDateFormat getDobDateFormat(); static SimpleDateFormat getNativeFormsDateFormat(); static @Nullable List<Map<String, Object>> readData(String query, String[] selectionArgs); } | AbstractDao { protected static void setRepository(Repository repository) { AbstractDao.repository = repository; } static SimpleDateFormat getDobDateFormat(); static SimpleDateFormat getNativeFormsDateFormat(); static @Nullable List<Map<String, Object>> readData(String query, String[] selectionArgs); } |
@Test public void testUpdateDB() { String sql = "update table set col1 = 'value' where id = x"; AbstractDao.setRepository(repository); AbstractDao.updateDB(sql); Mockito.verify(sqLiteDatabase).rawExecSQL(sql); } | protected static void updateDB(String sql) { try { SQLiteDatabase db = getRepository().getWritableDatabase(); db.rawExecSQL(sql); } catch (Exception e) { Timber.e(e); } } | AbstractDao { protected static void updateDB(String sql) { try { SQLiteDatabase db = getRepository().getWritableDatabase(); db.rawExecSQL(sql); } catch (Exception e) { Timber.e(e); } } } | AbstractDao { protected static void updateDB(String sql) { try { SQLiteDatabase db = getRepository().getWritableDatabase(); db.rawExecSQL(sql); } catch (Exception e) { Timber.e(e); } } } | AbstractDao { protected static void updateDB(String sql) { try { SQLiteDatabase db = getRepository().getWritableDatabase(); db.rawExecSQL(sql); } catch (Exception e) { Timber.e(e); } } static SimpleDateFormat getDobDateFormat(); static SimpleDateFormat getNativeFormsDateFormat(); static @Nullable List<Map<String, Obje... | AbstractDao { protected static void updateDB(String sql) { try { SQLiteDatabase db = getRepository().getWritableDatabase(); db.rawExecSQL(sql); } catch (Exception e) { Timber.e(e); } } static SimpleDateFormat getDobDateFormat(); static SimpleDateFormat getNativeFormsDateFormat(); static @Nullable List<Map<String, Obje... |
@Test public void testGetLocationsByTags() { LocationsDao.setRepository(repository); MatrixCursor matrixCursor = new MatrixCursor(new String[]{"uuid", "location_name", "parent_id"}); matrixCursor.addRow(new Object[]{"fb7ed5db-138d-4e6f-94d8-bc443b58dadb", "Tabata Dampo", "bcf5a36d-fb53-4de9-9813-01f1d480e3fe"}); matrix... | public static List<Location> getLocationsByTags(Set<String> tags) { String sql = String.format("SELECT uuid, location.name as location_name, parent_id\n" + "FROM location\n" + " INNER JOIN location_tag on location.uuid = location_tag.location_id\n" + "WHERE location_tag.name IN ('%s');", StringUtils.join(tags, "', '"))... | LocationsDao extends AbstractDao { public static List<Location> getLocationsByTags(Set<String> tags) { String sql = String.format("SELECT uuid, location.name as location_name, parent_id\n" + "FROM location\n" + " INNER JOIN location_tag on location.uuid = location_tag.location_id\n" + "WHERE location_tag.name IN ('%s')... | LocationsDao extends AbstractDao { public static List<Location> getLocationsByTags(Set<String> tags) { String sql = String.format("SELECT uuid, location.name as location_name, parent_id\n" + "FROM location\n" + " INNER JOIN location_tag on location.uuid = location_tag.location_id\n" + "WHERE location_tag.name IN ('%s')... | LocationsDao extends AbstractDao { public static List<Location> getLocationsByTags(Set<String> tags) { String sql = String.format("SELECT uuid, location.name as location_name, parent_id\n" + "FROM location\n" + " INNER JOIN location_tag on location.uuid = location_tag.location_id\n" + "WHERE location_tag.name IN ('%s')... | LocationsDao extends AbstractDao { public static List<Location> getLocationsByTags(Set<String> tags) { String sql = String.format("SELECT uuid, location.name as location_name, parent_id\n" + "FROM location\n" + " INNER JOIN location_tag on location.uuid = location_tag.location_id\n" + "WHERE location_tag.name IN ('%s')... |
@Test public void shouldReturnStringDefaultValueWhenStringIsEmpty() { String value = IntegerUtil.tryParse("", "1"); Assert.assertEquals(value, "1"); } | public static Integer tryParse(String value, int defaultValue) { try { return Integer.parseInt(value); } catch (NumberFormatException e) { return defaultValue; } } | IntegerUtil { public static Integer tryParse(String value, int defaultValue) { try { return Integer.parseInt(value); } catch (NumberFormatException e) { return defaultValue; } } } | IntegerUtil { public static Integer tryParse(String value, int defaultValue) { try { return Integer.parseInt(value); } catch (NumberFormatException e) { return defaultValue; } } } | IntegerUtil { public static Integer tryParse(String value, int defaultValue) { try { return Integer.parseInt(value); } catch (NumberFormatException e) { return defaultValue; } } static Integer tryParse(String value, int defaultValue); static String tryParse(String value, String defaultValue); static int compare(int lh... | IntegerUtil { public static Integer tryParse(String value, int defaultValue) { try { return Integer.parseInt(value); } catch (NumberFormatException e) { return defaultValue; } } static Integer tryParse(String value, int defaultValue); static String tryParse(String value, String defaultValue); static int compare(int lh... |
@Test public void testGetScreenDpiReturnsCorrectValuesForMediumDensity() { Mockito.doReturn(resources).when(context).getResources(); DisplayMetrics displayMetrics = new DisplayMetrics(); displayMetrics.density = 0.76f; Mockito.doReturn(displayMetrics).when(resources).getDisplayMetrics(); DisplayUtils.ScreenDpi screenDp... | public static ScreenDpi getScreenDpi(Context context) { float density = context.getResources().getDisplayMetrics().density; ScreenDpi dpi = ScreenDpi.XXXHDPI; if (density <= 0.75) { dpi = ScreenDpi.LDPI; } else if (density > 0.75 && density <= 1.0) { dpi = ScreenDpi.MDPI; } else if (density > 1.0 && density <= 1.5) { d... | DisplayUtils { public static ScreenDpi getScreenDpi(Context context) { float density = context.getResources().getDisplayMetrics().density; ScreenDpi dpi = ScreenDpi.XXXHDPI; if (density <= 0.75) { dpi = ScreenDpi.LDPI; } else if (density > 0.75 && density <= 1.0) { dpi = ScreenDpi.MDPI; } else if (density > 1.0 && dens... | DisplayUtils { public static ScreenDpi getScreenDpi(Context context) { float density = context.getResources().getDisplayMetrics().density; ScreenDpi dpi = ScreenDpi.XXXHDPI; if (density <= 0.75) { dpi = ScreenDpi.LDPI; } else if (density > 0.75 && density <= 1.0) { dpi = ScreenDpi.MDPI; } else if (density > 1.0 && dens... | DisplayUtils { public static ScreenDpi getScreenDpi(Context context) { float density = context.getResources().getDisplayMetrics().density; ScreenDpi dpi = ScreenDpi.XXXHDPI; if (density <= 0.75) { dpi = ScreenDpi.LDPI; } else if (density > 0.75 && density <= 1.0) { dpi = ScreenDpi.MDPI; } else if (density > 1.0 && dens... | DisplayUtils { public static ScreenDpi getScreenDpi(Context context) { float density = context.getResources().getDisplayMetrics().density; ScreenDpi dpi = ScreenDpi.XXXHDPI; if (density <= 0.75) { dpi = ScreenDpi.LDPI; } else if (density > 0.75 && density <= 1.0) { dpi = ScreenDpi.MDPI; } else if (density > 1.0 && dens... |
@Test public void testConvertDrawableToBitmap() { BottomNavigationHelper spyBottomNavigationHelper = Mockito.spy(bottomNavigationHelper); Resources resources = Mockito.mock(Resources.class); Assert.assertNotNull(resources); Mockito.doReturn(drawable).when(resources).getDrawable(INITIALS_RESOURCE_ID); Assert.assertNotNu... | protected Bitmap convertDrawableResToBitmap(@DrawableRes int drawableId, Resources resources) { Drawable drawable = resources.getDrawable(drawableId); if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } else if (drawable instanceof GradientDrawable) { GradientDrawable gradientDra... | BottomNavigationHelper { protected Bitmap convertDrawableResToBitmap(@DrawableRes int drawableId, Resources resources) { Drawable drawable = resources.getDrawable(drawableId); if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } else if (drawable instanceof GradientDrawable) { Gra... | BottomNavigationHelper { protected Bitmap convertDrawableResToBitmap(@DrawableRes int drawableId, Resources resources) { Drawable drawable = resources.getDrawable(drawableId); if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } else if (drawable instanceof GradientDrawable) { Gra... | BottomNavigationHelper { protected Bitmap convertDrawableResToBitmap(@DrawableRes int drawableId, Resources resources) { Drawable drawable = resources.getDrawable(drawableId); if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } else if (drawable instanceof GradientDrawable) { Gra... | BottomNavigationHelper { protected Bitmap convertDrawableResToBitmap(@DrawableRes int drawableId, Resources resources) { Drawable drawable = resources.getDrawable(drawableId); if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } else if (drawable instanceof GradientDrawable) { Gra... |
@Test public void testConvertGradientDrawableToBitmap() { Assert.assertNotNull(bottomNavigationHelper.convertDrawableResToBitmap(R.drawable.bottom_bar_initials_background, RuntimeEnvironment.application.getResources())); } | protected Bitmap convertDrawableResToBitmap(@DrawableRes int drawableId, Resources resources) { Drawable drawable = resources.getDrawable(drawableId); if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } else if (drawable instanceof GradientDrawable) { GradientDrawable gradientDra... | BottomNavigationHelper { protected Bitmap convertDrawableResToBitmap(@DrawableRes int drawableId, Resources resources) { Drawable drawable = resources.getDrawable(drawableId); if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } else if (drawable instanceof GradientDrawable) { Gra... | BottomNavigationHelper { protected Bitmap convertDrawableResToBitmap(@DrawableRes int drawableId, Resources resources) { Drawable drawable = resources.getDrawable(drawableId); if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } else if (drawable instanceof GradientDrawable) { Gra... | BottomNavigationHelper { protected Bitmap convertDrawableResToBitmap(@DrawableRes int drawableId, Resources resources) { Drawable drawable = resources.getDrawable(drawableId); if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } else if (drawable instanceof GradientDrawable) { Gra... | BottomNavigationHelper { protected Bitmap convertDrawableResToBitmap(@DrawableRes int drawableId, Resources resources) { Drawable drawable = resources.getDrawable(drawableId); if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } else if (drawable instanceof GradientDrawable) { Gra... |
@Test public void testConvertBitmapDrawableToBitmap() { Assert.assertNotNull(bottomNavigationHelper.convertDrawableResToBitmap(R.drawable.child_boy_infant, RuntimeEnvironment.application.getResources())); } | protected Bitmap convertDrawableResToBitmap(@DrawableRes int drawableId, Resources resources) { Drawable drawable = resources.getDrawable(drawableId); if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } else if (drawable instanceof GradientDrawable) { GradientDrawable gradientDra... | BottomNavigationHelper { protected Bitmap convertDrawableResToBitmap(@DrawableRes int drawableId, Resources resources) { Drawable drawable = resources.getDrawable(drawableId); if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } else if (drawable instanceof GradientDrawable) { Gra... | BottomNavigationHelper { protected Bitmap convertDrawableResToBitmap(@DrawableRes int drawableId, Resources resources) { Drawable drawable = resources.getDrawable(drawableId); if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } else if (drawable instanceof GradientDrawable) { Gra... | BottomNavigationHelper { protected Bitmap convertDrawableResToBitmap(@DrawableRes int drawableId, Resources resources) { Drawable drawable = resources.getDrawable(drawableId); if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } else if (drawable instanceof GradientDrawable) { Gra... | BottomNavigationHelper { protected Bitmap convertDrawableResToBitmap(@DrawableRes int drawableId, Resources resources) { Drawable drawable = resources.getDrawable(drawableId); if (drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); } else if (drawable instanceof GradientDrawable) { Gra... |
@Test public void assertshouldReturn3PageCountFor50Clients() { SmartRegisterPaginatedAdapter adapter = getAdapterWithFakeClients(FIFTY); Assert.assertEquals(adapter.pageCount(), THREE); } | public int pageCount() { return pageCount; } | SmartRegisterPaginatedAdapter extends BaseAdapter { public int pageCount() { return pageCount; } } | SmartRegisterPaginatedAdapter extends BaseAdapter { public int pageCount() { return pageCount; } SmartRegisterPaginatedAdapter(SmartRegisterClientsProvider listItemProvider); SmartRegisterPaginatedAdapter(int clientsPerPage, SmartRegisterClientsProvider
listItemProvider); } | SmartRegisterPaginatedAdapter extends BaseAdapter { public int pageCount() { return pageCount; } SmartRegisterPaginatedAdapter(SmartRegisterClientsProvider listItemProvider); SmartRegisterPaginatedAdapter(int clientsPerPage, SmartRegisterClientsProvider
listItemProvider); void refreshClients(SmartRegisterC... | SmartRegisterPaginatedAdapter extends BaseAdapter { public int pageCount() { return pageCount; } SmartRegisterPaginatedAdapter(SmartRegisterClientsProvider listItemProvider); SmartRegisterPaginatedAdapter(int clientsPerPage, SmartRegisterClientsProvider
listItemProvider); void refreshClients(SmartRegisterC... |
@Test public void assertgetItemShouldReturnRespectiveItem() { SmartRegisterPaginatedAdapter adapter = getAdapterWithFakeClients(FIFTY); Assert.assertEquals(((ECClient) adapter.getItem(ZERO)).name(), NameZERO); Assert.assertEquals(((ECClient) adapter.getItem(FOURTYNINE)).name(), NameFOURTYNINE); } | @Override public Object getItem(int i) { return filteredClients.get(i); } | SmartRegisterPaginatedAdapter extends BaseAdapter { @Override public Object getItem(int i) { return filteredClients.get(i); } } | SmartRegisterPaginatedAdapter extends BaseAdapter { @Override public Object getItem(int i) { return filteredClients.get(i); } SmartRegisterPaginatedAdapter(SmartRegisterClientsProvider listItemProvider); SmartRegisterPaginatedAdapter(int clientsPerPage, SmartRegisterClientsProvider
listItemProvider); } | SmartRegisterPaginatedAdapter extends BaseAdapter { @Override public Object getItem(int i) { return filteredClients.get(i); } SmartRegisterPaginatedAdapter(SmartRegisterClientsProvider listItemProvider); SmartRegisterPaginatedAdapter(int clientsPerPage, SmartRegisterClientsProvider
listItemProvider); void ... | SmartRegisterPaginatedAdapter extends BaseAdapter { @Override public Object getItem(int i) { return filteredClients.get(i); } SmartRegisterPaginatedAdapter(SmartRegisterClientsProvider listItemProvider); SmartRegisterPaginatedAdapter(int clientsPerPage, SmartRegisterClientsProvider
listItemProvider); void ... |
@Test public void assertgetViewShouldDelegateCallToProviderGetViewWithProperClient() { FakeClientsProvider fakeClientsProvider = new FakeClientsProvider(getSmartRegisterClients(FIFTY)); SmartRegisterPaginatedAdapter adapter = getAdapter(fakeClientsProvider); adapter.getView(ZERO, null, null); Assert.assertEquals(NameZE... | @Override public View getView(int i, View parentView, ViewGroup viewGroup) { return listItemProvider .getView((SmartRegisterClient) getItem(actualPosition(i)), parentView, viewGroup); } | SmartRegisterPaginatedAdapter extends BaseAdapter { @Override public View getView(int i, View parentView, ViewGroup viewGroup) { return listItemProvider .getView((SmartRegisterClient) getItem(actualPosition(i)), parentView, viewGroup); } } | SmartRegisterPaginatedAdapter extends BaseAdapter { @Override public View getView(int i, View parentView, ViewGroup viewGroup) { return listItemProvider .getView((SmartRegisterClient) getItem(actualPosition(i)), parentView, viewGroup); } SmartRegisterPaginatedAdapter(SmartRegisterClientsProvider listItemProvider); Sma... | SmartRegisterPaginatedAdapter extends BaseAdapter { @Override public View getView(int i, View parentView, ViewGroup viewGroup) { return listItemProvider .getView((SmartRegisterClient) getItem(actualPosition(i)), parentView, viewGroup); } SmartRegisterPaginatedAdapter(SmartRegisterClientsProvider listItemProvider); Sma... | SmartRegisterPaginatedAdapter extends BaseAdapter { @Override public View getView(int i, View parentView, ViewGroup viewGroup) { return listItemProvider .getView((SmartRegisterClient) getItem(actualPosition(i)), parentView, viewGroup); } SmartRegisterPaginatedAdapter(SmartRegisterClientsProvider listItemProvider); Sma... |
@Test public void testGetCount() { ServiceLocationsAdapter adapter = getAdapterWithFakeClients(); Assert.assertEquals(adapter.getCount(), 3); } | @Override public int getCount() { return locationNames.size(); } | ServiceLocationsAdapter extends BaseAdapter { @Override public int getCount() { return locationNames.size(); } } | ServiceLocationsAdapter extends BaseAdapter { @Override public int getCount() { return locationNames.size(); } ServiceLocationsAdapter(Context context, List<String> locationNames); } | ServiceLocationsAdapter extends BaseAdapter { @Override public int getCount() { return locationNames.size(); } ServiceLocationsAdapter(Context context, List<String> locationNames); @Override int getCount(); @Override Object getItem(int position); @Override long getItemId(int position); @Override View getView(int positi... | ServiceLocationsAdapter extends BaseAdapter { @Override public int getCount() { return locationNames.size(); } ServiceLocationsAdapter(Context context, List<String> locationNames); @Override int getCount(); @Override Object getItem(int position); @Override long getItemId(int position); @Override View getView(int positi... |
@Test public void testGetItemId() { ServiceLocationsAdapter adapter = getAdapterWithFakeClients(); Assert.assertEquals(adapter.getItemId(0), 2321); } | @Override public long getItemId(int position) { return position + 2321; } | ServiceLocationsAdapter extends BaseAdapter { @Override public long getItemId(int position) { return position + 2321; } } | ServiceLocationsAdapter extends BaseAdapter { @Override public long getItemId(int position) { return position + 2321; } ServiceLocationsAdapter(Context context, List<String> locationNames); } | ServiceLocationsAdapter extends BaseAdapter { @Override public long getItemId(int position) { return position + 2321; } ServiceLocationsAdapter(Context context, List<String> locationNames); @Override int getCount(); @Override Object getItem(int position); @Override long getItemId(int position); @Override View getView(i... | ServiceLocationsAdapter extends BaseAdapter { @Override public long getItemId(int position) { return position + 2321; } ServiceLocationsAdapter(Context context, List<String> locationNames); @Override int getCount(); @Override Object getItem(int position); @Override long getItemId(int position); @Override View getView(i... |
@Test public void testGetLocationAt() { ServiceLocationsAdapter adapter = getAdapterWithFakeClients(); Assert.assertEquals(adapter.getLocationAt(0), "test1"); } | public String getLocationAt(int position) { return locationNames.get(position); } | ServiceLocationsAdapter extends BaseAdapter { public String getLocationAt(int position) { return locationNames.get(position); } } | ServiceLocationsAdapter extends BaseAdapter { public String getLocationAt(int position) { return locationNames.get(position); } ServiceLocationsAdapter(Context context, List<String> locationNames); } | ServiceLocationsAdapter extends BaseAdapter { public String getLocationAt(int position) { return locationNames.get(position); } ServiceLocationsAdapter(Context context, List<String> locationNames); @Override int getCount(); @Override Object getItem(int position); @Override long getItemId(int position); @Override View g... | ServiceLocationsAdapter extends BaseAdapter { public String getLocationAt(int position) { return locationNames.get(position); } ServiceLocationsAdapter(Context context, List<String> locationNames); @Override int getCount(); @Override Object getItem(int position); @Override long getItemId(int position); @Override View g... |
@Test public void testGetLocationNames() { ServiceLocationsAdapter adapter = getAdapterWithFakeClients(); List<String> names = adapter.getLocationNames(); Assert.assertEquals(names.get(0), "test1"); } | public List<String> getLocationNames() { return locationNames; } | ServiceLocationsAdapter extends BaseAdapter { public List<String> getLocationNames() { return locationNames; } } | ServiceLocationsAdapter extends BaseAdapter { public List<String> getLocationNames() { return locationNames; } ServiceLocationsAdapter(Context context, List<String> locationNames); } | ServiceLocationsAdapter extends BaseAdapter { public List<String> getLocationNames() { return locationNames; } ServiceLocationsAdapter(Context context, List<String> locationNames); @Override int getCount(); @Override Object getItem(int position); @Override long getItemId(int position); @Override View getView(int positi... | ServiceLocationsAdapter extends BaseAdapter { public List<String> getLocationNames() { return locationNames; } ServiceLocationsAdapter(Context context, List<String> locationNames); @Override int getCount(); @Override Object getItem(int position); @Override long getItemId(int position); @Override View getView(int positi... |
@Test public void assertIntegerCompareReturnsInt() { Assert.assertEquals(IntegerUtil.compare(1, 2), -1); Assert.assertEquals(IntegerUtil.compare(2, 2), 0); Assert.assertEquals(IntegerUtil.compare(3, 2), 1); } | public static int compare(int lhs, int rhs) { return lhs < rhs ? -1 : (lhs == rhs ? 0 : 1); } | IntegerUtil { public static int compare(int lhs, int rhs) { return lhs < rhs ? -1 : (lhs == rhs ? 0 : 1); } } | IntegerUtil { public static int compare(int lhs, int rhs) { return lhs < rhs ? -1 : (lhs == rhs ? 0 : 1); } } | IntegerUtil { public static int compare(int lhs, int rhs) { return lhs < rhs ? -1 : (lhs == rhs ? 0 : 1); } static Integer tryParse(String value, int defaultValue); static String tryParse(String value, String defaultValue); static int compare(int lhs, int rhs); } | IntegerUtil { public static int compare(int lhs, int rhs) { return lhs < rhs ? -1 : (lhs == rhs ? 0 : 1); } static Integer tryParse(String value, int defaultValue); static String tryParse(String value, String defaultValue); static int compare(int lhs, int rhs); } |
@Test public void testGetView() { ServiceLocationsAdapter adapter = getAdapterWithFakeClients(); itemsListView.setAdapter(adapter); when(applicationContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).thenReturn(layoutInflater); Mockito.doReturn(linearLayout).when(layoutInflater).inflate(R.layout.location_picker_... | @Override public View getView(int position, View convertView, ViewGroup parent) { if (!views.containsKey(locationNames.get(position))) { LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.location_picker_dropdown_item, null); view... | ServiceLocationsAdapter extends BaseAdapter { @Override public View getView(int position, View convertView, ViewGroup parent) { if (!views.containsKey(locationNames.get(position))) { LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.lay... | ServiceLocationsAdapter extends BaseAdapter { @Override public View getView(int position, View convertView, ViewGroup parent) { if (!views.containsKey(locationNames.get(position))) { LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.lay... | ServiceLocationsAdapter extends BaseAdapter { @Override public View getView(int position, View convertView, ViewGroup parent) { if (!views.containsKey(locationNames.get(position))) { LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.lay... | ServiceLocationsAdapter extends BaseAdapter { @Override public View getView(int position, View convertView, ViewGroup parent) { if (!views.containsKey(locationNames.get(position))) { LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.lay... |
@Test public void testOnRunJobStartsCorrectService() { SyncTaskServiceJob syncTaskServiceJob = new SyncTaskServiceJob(SyncTaskIntentService.class); SyncTaskServiceJob syncTaskServiceJobSpy = Mockito.spy(syncTaskServiceJob); ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class); Mockito.doReturn(context)... | @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), serviceClass); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESCHEDULE, false) ? Result.RESCHEDULE : Result.SUCCES... | SyncTaskServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), serviceClass); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESCHEDULE, false... | SyncTaskServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), serviceClass); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESCHEDULE, false... | SyncTaskServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), serviceClass); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESCHEDULE, false... | SyncTaskServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), serviceClass); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESCHEDULE, false... |
@Test public void testOnRunJobStartsCorrectService() { ValidateSyncDataServiceJob validateSyncDataServiceJob = new ValidateSyncDataServiceJob(); ValidateSyncDataServiceJob validateSyncDataServiceJobSpy = Mockito.spy(validateSyncDataServiceJob); ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class); Mock... | @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), ValidateIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESCHEDULE, false) ? Result.RESCHEDULE ... | ValidateSyncDataServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), ValidateIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_K... | ValidateSyncDataServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), ValidateIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_K... | ValidateSyncDataServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), ValidateIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_K... | ValidateSyncDataServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), ValidateIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_K... |
@Test public void testOnRunJobStartsCorrectService() { CampaignServiceJob campaignServiceJob = new CampaignServiceJob(); CampaignServiceJob campaignServiceJobJobSpy = Mockito.spy(campaignServiceJob); ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class); Mockito.doReturn(context).when(campaignServiceJob... | @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), CampaignIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESCHEDULE, false) ? Result.RESCHEDULE ... | CampaignServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), CampaignIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RE... | CampaignServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), CampaignIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RE... | CampaignServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), CampaignIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RE... | CampaignServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), CampaignIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RE... |
@Test public void testOnRunJobStartsCorrectService() { PullUniqueIdsServiceJob pullUniqueIdsServiceJob = new PullUniqueIdsServiceJob(); PullUniqueIdsServiceJob pullUniqueIdsServiceJobSpy = Mockito.spy(pullUniqueIdsServiceJob); ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class); Mockito.doReturn(conte... | @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), PullUniqueIdsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESCHEDULE, false) ? Result.RESCHE... | PullUniqueIdsServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), PullUniqueIdsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT... | PullUniqueIdsServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), PullUniqueIdsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT... | PullUniqueIdsServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), PullUniqueIdsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT... | PullUniqueIdsServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), PullUniqueIdsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT... |
@Test public void testOnRunJobStartsCorrectService() { ExtendedSyncServiceJob extendedSyncServiceJob = new ExtendedSyncServiceJob(); ExtendedSyncServiceJob syncServiceJobSpy = Mockito.spy(extendedSyncServiceJob); ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class); Mockito.doReturn(context).when(syncS... | @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), ExtendedSyncIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESCHEDULE, false) ? Result.RESCHED... | ExtendedSyncServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), ExtendedSyncIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_K... | ExtendedSyncServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), ExtendedSyncIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_K... | ExtendedSyncServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), ExtendedSyncIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_K... | ExtendedSyncServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), ExtendedSyncIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_K... |
@Test public void testOnRunJobStartsCorrectService() { SyncLocationsByLevelAndTagsServiceJob syncLocationsByLevelAndTagsServiceJob = new SyncLocationsByLevelAndTagsServiceJob(); SyncLocationsByLevelAndTagsServiceJob syncLocationsByLevelAndTagsServiceJobSpy = Mockito.spy(syncLocationsByLevelAndTagsServiceJob); ArgumentC... | @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), SyncLocationsByLevelAndTagsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESCHEDULE, false) ?... | SyncLocationsByLevelAndTagsServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), SyncLocationsByLevelAndTagsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().ge... | SyncLocationsByLevelAndTagsServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), SyncLocationsByLevelAndTagsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().ge... | SyncLocationsByLevelAndTagsServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), SyncLocationsByLevelAndTagsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().ge... | SyncLocationsByLevelAndTagsServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), SyncLocationsByLevelAndTagsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().ge... |
@Test public void testOnRunJobStartsCorrectService() { DocumentConfigurationServiceJob documentConfigurationServiceJob = new DocumentConfigurationServiceJob(DocumentConfigurationIntentService.class); DocumentConfigurationServiceJob documentConfigurationServiceJobSpy = Mockito.spy(documentConfigurationServiceJob); Argum... | @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), serviceClass); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESCHEDULE, false) ? Result.RESCHEDULE : Result.SUCCES... | DocumentConfigurationServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), serviceClass); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESC... | DocumentConfigurationServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), serviceClass); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESC... | DocumentConfigurationServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), serviceClass); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESC... | DocumentConfigurationServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), serviceClass); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESC... |
@Test public void testOnRunJobStartsCorrectService() { SyncServiceJob syncServiceJob = new SyncServiceJob(SyncIntentService.class); SyncServiceJob syncServiceJobSpy = Mockito.spy(syncServiceJob); ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class); Mockito.doReturn(context).when(syncServiceJobSpy).get... | @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), serviceClass); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESCHEDULE, false) ? Result.RESCHEDULE : Result.SUCCES... | SyncServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), serviceClass); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESCHEDULE, false) ? ... | SyncServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), serviceClass); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESCHEDULE, false) ? ... | SyncServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), serviceClass); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESCHEDULE, false) ? ... | SyncServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), serviceClass); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESCHEDULE, false) ? ... |
@Test public void testOnRunJobStartsCorrectService() { SyncLocationsByTeamIdsJob syncLocationsByTeamIdsJob = new SyncLocationsByTeamIdsJob(); SyncLocationsByTeamIdsJob syncLocationsByTeamIdsJobSpy = Mockito.spy(syncLocationsByTeamIdsJob); ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class); Mockito.do... | @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), SyncLocationsByTeamIdsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESCHEDULE, false) ? Resu... | SyncLocationsByTeamIdsJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), SyncLocationsByTeamIdsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConst... | SyncLocationsByTeamIdsJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), SyncLocationsByTeamIdsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConst... | SyncLocationsByTeamIdsJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), SyncLocationsByTeamIdsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConst... | SyncLocationsByTeamIdsJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), SyncLocationsByTeamIdsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConst... |
@Test public void assertGetDurationTest() { Locale locale = RuntimeEnvironment.application.getApplicationContext().getResources().getConfiguration().locale; Assert.assertEquals("1d", DateUtil.getDuration(100000000l, locale)); Assert.assertEquals("5w 1d", DateUtil.getDuration(3110400000l, locale)); Assert.assertEquals("... | public static String getDuration(DateTime dateTime) { return getDuration(CoreLibrary.getInstance().context().applicationContext(), dateTime); } | DateUtil { public static String getDuration(DateTime dateTime) { return getDuration(CoreLibrary.getInstance().context().applicationContext(), dateTime); } } | DateUtil { public static String getDuration(DateTime dateTime) { return getDuration(CoreLibrary.getInstance().context().applicationContext(), dateTime); } } | DateUtil { public static String getDuration(DateTime dateTime) { return getDuration(CoreLibrary.getInstance().context().applicationContext(), dateTime); } static void fakeIt(LocalDate fakeDayAsToday); static void setDefaultDateFormat(String defaultDateFormat); static LocalDate today(); static String formatDateForTimel... | DateUtil { public static String getDuration(DateTime dateTime) { return getDuration(CoreLibrary.getInstance().context().applicationContext(), dateTime); } static void fakeIt(LocalDate fakeDayAsToday); static void setDefaultDateFormat(String defaultDateFormat); static LocalDate today(); static String formatDateForTimel... |
@Test public void testOnRunJobStartsCorrectService() { SyncAllLocationsServiceJob syncAllLocationsServiceJob = new SyncAllLocationsServiceJob(); SyncAllLocationsServiceJob spy = Mockito.spy(syncAllLocationsServiceJob); ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class); Mockito.doReturn(context).when... | @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), SyncAllLocationsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.INTENT_KEY.TO_RESCHEDULE, false) ? Result.RES... | SyncAllLocationsServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), SyncAllLocationsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.... | SyncAllLocationsServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), SyncAllLocationsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.... | SyncAllLocationsServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), SyncAllLocationsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.... | SyncAllLocationsServiceJob extends BaseJob { @NonNull @Override protected Result onRunJob(@NonNull Params params) { Intent intent = new Intent(getApplicationContext(), SyncAllLocationsIntentService.class); getApplicationContext().startService(intent); return params != null && params.getExtras().getBoolean(AllConstants.... |
@Test public void testSerialize() { Campaign campaign = gson.fromJson(campaignJson, Campaign.class); assertEquals(campaignJson, gson.toJson(campaign)); assertEquals(campaign.getTitle(),"2019 IRS Season 1"); } | public String getTitle() { return title; } | Campaign { public String getTitle() { return title; } } | Campaign { public String getTitle() { return title; } } | Campaign { public String getTitle() { return title; } String getIdentifier(); void setIdentifier(String identifier); String getTitle(); void setTitle(String title); String getDescription(); void setDescription(String description); TaskStatus getStatus(); void setStatus(TaskStatus status); ExecutionPeriod getExecutionP... | Campaign { public String getTitle() { return title; } String getIdentifier(); void setIdentifier(String identifier); String getTitle(); void setTitle(String title); String getDescription(); void setDescription(String description); TaskStatus getStatus(); void setStatus(TaskStatus status); ExecutionPeriod getExecutionP... |
@Test public void testCloseCaseShouldReturnFalseIfCloseCaseIsEmpty() { ClientProcessorForJava clientProcessor = new ClientProcessorForJava(context); assertFalse(clientProcessor.closeCase(new Client("1233-2"), new ArrayList<>())); } | public Boolean closeCase(Client client, List<String> closesCase) { try { if (closesCase == null || closesCase.isEmpty()) { return false; } String baseEntityId = client.getBaseEntityId(); for (String tableName : closesCase) { closeCase(tableName, baseEntityId); updateFTSsearch(tableName, baseEntityId, null); } return tr... | ClientProcessorForJava { public Boolean closeCase(Client client, List<String> closesCase) { try { if (closesCase == null || closesCase.isEmpty()) { return false; } String baseEntityId = client.getBaseEntityId(); for (String tableName : closesCase) { closeCase(tableName, baseEntityId); updateFTSsearch(tableName, baseEnt... | ClientProcessorForJava { public Boolean closeCase(Client client, List<String> closesCase) { try { if (closesCase == null || closesCase.isEmpty()) { return false; } String baseEntityId = client.getBaseEntityId(); for (String tableName : closesCase) { closeCase(tableName, baseEntityId); updateFTSsearch(tableName, baseEnt... | ClientProcessorForJava { public Boolean closeCase(Client client, List<String> closesCase) { try { if (closesCase == null || closesCase.isEmpty()) { return false; } String baseEntityId = client.getBaseEntityId(); for (String tableName : closesCase) { closeCase(tableName, baseEntityId); updateFTSsearch(tableName, baseEnt... | ClientProcessorForJava { public Boolean closeCase(Client client, List<String> closesCase) { try { if (closesCase == null || closesCase.isEmpty()) { return false; } String baseEntityId = client.getBaseEntityId(); for (String tableName : closesCase) { closeCase(tableName, baseEntityId); updateFTSsearch(tableName, baseEnt... |
@Test public void testCloseCaseShouldPassCorrectValuesToCloseCase() { ClientProcessorForJava clientProcessor = new ClientProcessorForJava(context); CommonRepository commonRepository = Mockito.mock(CommonRepository.class); ReflectionHelpers.setStaticField(CoreLibrary.class, "instance", coreLibrary); PowerMockito.when(co... | public Boolean closeCase(Client client, List<String> closesCase) { try { if (closesCase == null || closesCase.isEmpty()) { return false; } String baseEntityId = client.getBaseEntityId(); for (String tableName : closesCase) { closeCase(tableName, baseEntityId); updateFTSsearch(tableName, baseEntityId, null); } return tr... | ClientProcessorForJava { public Boolean closeCase(Client client, List<String> closesCase) { try { if (closesCase == null || closesCase.isEmpty()) { return false; } String baseEntityId = client.getBaseEntityId(); for (String tableName : closesCase) { closeCase(tableName, baseEntityId); updateFTSsearch(tableName, baseEnt... | ClientProcessorForJava { public Boolean closeCase(Client client, List<String> closesCase) { try { if (closesCase == null || closesCase.isEmpty()) { return false; } String baseEntityId = client.getBaseEntityId(); for (String tableName : closesCase) { closeCase(tableName, baseEntityId); updateFTSsearch(tableName, baseEnt... | ClientProcessorForJava { public Boolean closeCase(Client client, List<String> closesCase) { try { if (closesCase == null || closesCase.isEmpty()) { return false; } String baseEntityId = client.getBaseEntityId(); for (String tableName : closesCase) { closeCase(tableName, baseEntityId); updateFTSsearch(tableName, baseEnt... | ClientProcessorForJava { public Boolean closeCase(Client client, List<String> closesCase) { try { if (closesCase == null || closesCase.isEmpty()) { return false; } String baseEntityId = client.getBaseEntityId(); for (String tableName : closesCase) { closeCase(tableName, baseEntityId); updateFTSsearch(tableName, baseEnt... |
@Test public void testGetColumnMappingsShouldReturnTheCorrectTable() throws IOException { ReflectionHelpers.setStaticField(CoreLibrary.class, "instance", coreLibrary); Mockito.when(coreLibrary.getEcClientFieldsFile()).thenReturn("ec_client_fields.json"); AssetManager assetManager = Mockito.mock(AssetManager.class); Moc... | public Table getColumnMappings(String registerName) { try { ClientField clientField = assetJsonToJava(CoreLibrary.getInstance().getEcClientFieldsFile(), ClientField.class); if (clientField == null) { return null; } List<Table> bindObjects = clientField.bindobjects; for (Table bindObject : bindObjects) { if (bindObject.... | ClientProcessorForJava { public Table getColumnMappings(String registerName) { try { ClientField clientField = assetJsonToJava(CoreLibrary.getInstance().getEcClientFieldsFile(), ClientField.class); if (clientField == null) { return null; } List<Table> bindObjects = clientField.bindobjects; for (Table bindObject : bindO... | ClientProcessorForJava { public Table getColumnMappings(String registerName) { try { ClientField clientField = assetJsonToJava(CoreLibrary.getInstance().getEcClientFieldsFile(), ClientField.class); if (clientField == null) { return null; } List<Table> bindObjects = clientField.bindobjects; for (Table bindObject : bindO... | ClientProcessorForJava { public Table getColumnMappings(String registerName) { try { ClientField clientField = assetJsonToJava(CoreLibrary.getInstance().getEcClientFieldsFile(), ClientField.class); if (clientField == null) { return null; } List<Table> bindObjects = clientField.bindobjects; for (Table bindObject : bindO... | ClientProcessorForJava { public Table getColumnMappings(String registerName) { try { ClientField clientField = assetJsonToJava(CoreLibrary.getInstance().getEcClientFieldsFile(), ClientField.class); if (clientField == null) { return null; } List<Table> bindObjects = clientField.bindobjects; for (Table bindObject : bindO... |
@Test public void testGetColumnMappingsShouldReturnNullIfFileIsNotRead() throws IOException { ReflectionHelpers.setStaticField(CoreLibrary.class, "instance", coreLibrary); Mockito.when(coreLibrary.getEcClientFieldsFile()).thenReturn("ec_client_fields.json"); AssetManager assetManager = Mockito.mock(AssetManager.class);... | public Table getColumnMappings(String registerName) { try { ClientField clientField = assetJsonToJava(CoreLibrary.getInstance().getEcClientFieldsFile(), ClientField.class); if (clientField == null) { return null; } List<Table> bindObjects = clientField.bindobjects; for (Table bindObject : bindObjects) { if (bindObject.... | ClientProcessorForJava { public Table getColumnMappings(String registerName) { try { ClientField clientField = assetJsonToJava(CoreLibrary.getInstance().getEcClientFieldsFile(), ClientField.class); if (clientField == null) { return null; } List<Table> bindObjects = clientField.bindobjects; for (Table bindObject : bindO... | ClientProcessorForJava { public Table getColumnMappings(String registerName) { try { ClientField clientField = assetJsonToJava(CoreLibrary.getInstance().getEcClientFieldsFile(), ClientField.class); if (clientField == null) { return null; } List<Table> bindObjects = clientField.bindobjects; for (Table bindObject : bindO... | ClientProcessorForJava { public Table getColumnMappings(String registerName) { try { ClientField clientField = assetJsonToJava(CoreLibrary.getInstance().getEcClientFieldsFile(), ClientField.class); if (clientField == null) { return null; } List<Table> bindObjects = clientField.bindobjects; for (Table bindObject : bindO... | ClientProcessorForJava { public Table getColumnMappings(String registerName) { try { ClientField clientField = assetJsonToJava(CoreLibrary.getInstance().getEcClientFieldsFile(), ClientField.class); if (clientField == null) { return null; } List<Table> bindObjects = clientField.bindobjects; for (Table bindObject : bindO... |
@Test public void testUpdateClientDetailsTableShouldNotSaveClientDetailsIdConfigIsFalse() { ReflectionHelpers.setStaticField(CoreLibrary.class, "instance", coreLibrary); DetailsRepository detailsRepository = Mockito.mock(DetailsRepository.class); SyncConfiguration syncConfiguration = Mockito.mock(SyncConfiguration.clas... | public void updateClientDetailsTable(Event event, Client client) { try { Timber.d("Started updateClientDetailsTable"); if (CoreLibrary.getInstance().getSyncConfiguration().updateClientDetailsTable()) { String baseEntityId = client.getBaseEntityId(); Long timestamp = getEventDate(event.getEventDate()); Map<String, Strin... | ClientProcessorForJava { public void updateClientDetailsTable(Event event, Client client) { try { Timber.d("Started updateClientDetailsTable"); if (CoreLibrary.getInstance().getSyncConfiguration().updateClientDetailsTable()) { String baseEntityId = client.getBaseEntityId(); Long timestamp = getEventDate(event.getEventD... | ClientProcessorForJava { public void updateClientDetailsTable(Event event, Client client) { try { Timber.d("Started updateClientDetailsTable"); if (CoreLibrary.getInstance().getSyncConfiguration().updateClientDetailsTable()) { String baseEntityId = client.getBaseEntityId(); Long timestamp = getEventDate(event.getEventD... | ClientProcessorForJava { public void updateClientDetailsTable(Event event, Client client) { try { Timber.d("Started updateClientDetailsTable"); if (CoreLibrary.getInstance().getSyncConfiguration().updateClientDetailsTable()) { String baseEntityId = client.getBaseEntityId(); Long timestamp = getEventDate(event.getEventD... | ClientProcessorForJava { public void updateClientDetailsTable(Event event, Client client) { try { Timber.d("Started updateClientDetailsTable"); if (CoreLibrary.getInstance().getSyncConfiguration().updateClientDetailsTable()) { String baseEntityId = client.getBaseEntityId(); Long timestamp = getEventDate(event.getEventD... |
@Test public void testUpdateClientDetailsTableShouldSaveClientDetailsIdConfigIsTrue() { ReflectionHelpers.setStaticField(CoreLibrary.class, "instance", coreLibrary); DetailsRepository detailsRepository = Mockito.mock(DetailsRepository.class); SyncConfiguration syncConfiguration = Mockito.mock(SyncConfiguration.class); ... | public void updateClientDetailsTable(Event event, Client client) { try { Timber.d("Started updateClientDetailsTable"); if (CoreLibrary.getInstance().getSyncConfiguration().updateClientDetailsTable()) { String baseEntityId = client.getBaseEntityId(); Long timestamp = getEventDate(event.getEventDate()); Map<String, Strin... | ClientProcessorForJava { public void updateClientDetailsTable(Event event, Client client) { try { Timber.d("Started updateClientDetailsTable"); if (CoreLibrary.getInstance().getSyncConfiguration().updateClientDetailsTable()) { String baseEntityId = client.getBaseEntityId(); Long timestamp = getEventDate(event.getEventD... | ClientProcessorForJava { public void updateClientDetailsTable(Event event, Client client) { try { Timber.d("Started updateClientDetailsTable"); if (CoreLibrary.getInstance().getSyncConfiguration().updateClientDetailsTable()) { String baseEntityId = client.getBaseEntityId(); Long timestamp = getEventDate(event.getEventD... | ClientProcessorForJava { public void updateClientDetailsTable(Event event, Client client) { try { Timber.d("Started updateClientDetailsTable"); if (CoreLibrary.getInstance().getSyncConfiguration().updateClientDetailsTable()) { String baseEntityId = client.getBaseEntityId(); Long timestamp = getEventDate(event.getEventD... | ClientProcessorForJava { public void updateClientDetailsTable(Event event, Client client) { try { Timber.d("Started updateClientDetailsTable"); if (CoreLibrary.getInstance().getSyncConfiguration().updateClientDetailsTable()) { String baseEntityId = client.getBaseEntityId(); Long timestamp = getEventDate(event.getEventD... |
@Test public void processFieldShouldReturnFalse() { assertFalse(clientProcessor.processField(null, null, null)); } | public Boolean processField(org.smartregister.domain.jsonmapping.Field field, Event event, Client client) { try { if (field == null) { return false; } String dataSegment = null; String fieldName = field.field; String fieldValue = field.field_value; String responseKey = null; if (fieldName != null && fieldName.contains(... | ClientProcessorForJava { public Boolean processField(org.smartregister.domain.jsonmapping.Field field, Event event, Client client) { try { if (field == null) { return false; } String dataSegment = null; String fieldName = field.field; String fieldValue = field.field_value; String responseKey = null; if (fieldName != nu... | ClientProcessorForJava { public Boolean processField(org.smartregister.domain.jsonmapping.Field field, Event event, Client client) { try { if (field == null) { return false; } String dataSegment = null; String fieldName = field.field; String fieldValue = field.field_value; String responseKey = null; if (fieldName != nu... | ClientProcessorForJava { public Boolean processField(org.smartregister.domain.jsonmapping.Field field, Event event, Client client) { try { if (field == null) { return false; } String dataSegment = null; String fieldName = field.field; String fieldValue = field.field_value; String responseKey = null; if (fieldName != nu... | ClientProcessorForJava { public Boolean processField(org.smartregister.domain.jsonmapping.Field field, Event event, Client client) { try { if (field == null) { return false; } String dataSegment = null; String fieldName = field.field; String fieldValue = field.field_value; String responseKey = null; if (fieldName != nu... |
@Test public void processCaseModelShouldReturnFalseWhenCreatesCaseParamIsNull() { assertFalse(clientProcessor.processCaseModel(null, null, null)); } | public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String baseEntityId = client != nul... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... |
@Test public void assertCheckIfDateThreeMonthsOlderReturnsBoolean() { Assert.assertEquals(DateUtil.checkIfDateThreeMonthsOlder(new Date()), false); } | public static boolean checkIfDateThreeMonthsOlder(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(cal.getTime()); cal.add(Calendar.DATE, -90); Date dateBefore90Days = cal.getTime(); return date.before(dateBefore90Days); } | DateUtil { public static boolean checkIfDateThreeMonthsOlder(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(cal.getTime()); cal.add(Calendar.DATE, -90); Date dateBefore90Days = cal.getTime(); return date.before(dateBefore90Days); } } | DateUtil { public static boolean checkIfDateThreeMonthsOlder(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(cal.getTime()); cal.add(Calendar.DATE, -90); Date dateBefore90Days = cal.getTime(); return date.before(dateBefore90Days); } } | DateUtil { public static boolean checkIfDateThreeMonthsOlder(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(cal.getTime()); cal.add(Calendar.DATE, -90); Date dateBefore90Days = cal.getTime(); return date.before(dateBefore90Days); } static void fakeIt(LocalDate fakeDayAsToday); static void setDefaultDa... | DateUtil { public static boolean checkIfDateThreeMonthsOlder(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(cal.getTime()); cal.add(Calendar.DATE, -90); Date dateBefore90Days = cal.getTime(); return date.before(dateBefore90Days); } static void fakeIt(LocalDate fakeDayAsToday); static void setDefaultDa... |
@Test public void processClientClassShouldFalseWhenClassificationRuleIsNull() { Event event = new Event(); Client client = new Client("bei"); Assert.assertFalse(clientProcessor.processClientClass(null, event, client)); } | public Boolean processClientClass(ClassificationRule clientClass, Event event, Client client) { try { if (clientClass == null) { return false; } if (event == null) { return false; } if (client == null) { return false; } Rule rule = clientClass.rule; List<org.smartregister.domain.jsonmapping.Field> fields = rule.fields;... | ClientProcessorForJava { public Boolean processClientClass(ClassificationRule clientClass, Event event, Client client) { try { if (clientClass == null) { return false; } if (event == null) { return false; } if (client == null) { return false; } Rule rule = clientClass.rule; List<org.smartregister.domain.jsonmapping.Fie... | ClientProcessorForJava { public Boolean processClientClass(ClassificationRule clientClass, Event event, Client client) { try { if (clientClass == null) { return false; } if (event == null) { return false; } if (client == null) { return false; } Rule rule = clientClass.rule; List<org.smartregister.domain.jsonmapping.Fie... | ClientProcessorForJava { public Boolean processClientClass(ClassificationRule clientClass, Event event, Client client) { try { if (clientClass == null) { return false; } if (event == null) { return false; } if (client == null) { return false; } Rule rule = clientClass.rule; List<org.smartregister.domain.jsonmapping.Fie... | ClientProcessorForJava { public Boolean processClientClass(ClassificationRule clientClass, Event event, Client client) { try { if (clientClass == null) { return false; } if (event == null) { return false; } if (client == null) { return false; } Rule rule = clientClass.rule; List<org.smartregister.domain.jsonmapping.Fie... |
@Test public void processClientClassShouldFalseWhenEventIsNull() { Client client = new Client("bei"); ClassificationRule classificationRule = gson.fromJson("{\"comment\":\"Child: This rule checks whether a given case belongs to Child register\",\"rule\":{\"type\":\"event\",\"fields\":[{\"field\":\"eventType\",\"field_v... | public Boolean processClientClass(ClassificationRule clientClass, Event event, Client client) { try { if (clientClass == null) { return false; } if (event == null) { return false; } if (client == null) { return false; } Rule rule = clientClass.rule; List<org.smartregister.domain.jsonmapping.Field> fields = rule.fields;... | ClientProcessorForJava { public Boolean processClientClass(ClassificationRule clientClass, Event event, Client client) { try { if (clientClass == null) { return false; } if (event == null) { return false; } if (client == null) { return false; } Rule rule = clientClass.rule; List<org.smartregister.domain.jsonmapping.Fie... | ClientProcessorForJava { public Boolean processClientClass(ClassificationRule clientClass, Event event, Client client) { try { if (clientClass == null) { return false; } if (event == null) { return false; } if (client == null) { return false; } Rule rule = clientClass.rule; List<org.smartregister.domain.jsonmapping.Fie... | ClientProcessorForJava { public Boolean processClientClass(ClassificationRule clientClass, Event event, Client client) { try { if (clientClass == null) { return false; } if (event == null) { return false; } if (client == null) { return false; } Rule rule = clientClass.rule; List<org.smartregister.domain.jsonmapping.Fie... | ClientProcessorForJava { public Boolean processClientClass(ClassificationRule clientClass, Event event, Client client) { try { if (clientClass == null) { return false; } if (event == null) { return false; } if (client == null) { return false; } Rule rule = clientClass.rule; List<org.smartregister.domain.jsonmapping.Fie... |
@Test public void processClientClassShouldFalseWhenClientIsNull() { Event event = new Event(); ClassificationRule classificationRule = gson.fromJson("{\"comment\":\"Child: This rule checks whether a given case belongs to Child register\",\"rule\":{\"type\":\"event\",\"fields\":[{\"field\":\"eventType\",\"field_value\":... | public Boolean processClientClass(ClassificationRule clientClass, Event event, Client client) { try { if (clientClass == null) { return false; } if (event == null) { return false; } if (client == null) { return false; } Rule rule = clientClass.rule; List<org.smartregister.domain.jsonmapping.Field> fields = rule.fields;... | ClientProcessorForJava { public Boolean processClientClass(ClassificationRule clientClass, Event event, Client client) { try { if (clientClass == null) { return false; } if (event == null) { return false; } if (client == null) { return false; } Rule rule = clientClass.rule; List<org.smartregister.domain.jsonmapping.Fie... | ClientProcessorForJava { public Boolean processClientClass(ClassificationRule clientClass, Event event, Client client) { try { if (clientClass == null) { return false; } if (event == null) { return false; } if (client == null) { return false; } Rule rule = clientClass.rule; List<org.smartregister.domain.jsonmapping.Fie... | ClientProcessorForJava { public Boolean processClientClass(ClassificationRule clientClass, Event event, Client client) { try { if (clientClass == null) { return false; } if (event == null) { return false; } if (client == null) { return false; } Rule rule = clientClass.rule; List<org.smartregister.domain.jsonmapping.Fie... | ClientProcessorForJava { public Boolean processClientClass(ClassificationRule clientClass, Event event, Client client) { try { if (clientClass == null) { return false; } if (event == null) { return false; } if (client == null) { return false; } Rule rule = clientClass.rule; List<org.smartregister.domain.jsonmapping.Fie... |
@Test public void processCaseModelWhenGivenColumnConfigurationFromEventObsShouldPopulateContentValuesAsPerColumnConfiguration() { String eventJson = "{\"baseEntityId\":\"021a1da2-cebf-44fa-9ef3-3ffc18fa6356\",\"entityType\":\"vaccination\",\"eventDate\":\"2018-10-15T20:00:00.000-04:00\",\"eventType\":\"Vaccination\",\"... | public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String baseEntityId = client != nul... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... |
@Test public void processCaseModelWhenGivenColumnConfigurationFromEventFieldShouldPopulateContentValues() { String eventJson = "{\"baseEntityId\":\"021a1da2-cebf-44fa-9ef3-3ffc18fa6356\",\"entityType\":\"vaccination\",\"eventDate\":\"2018-10-15T20:00:00.000-04:00\",\"eventType\":\"Vaccination\",\"formSubmissionId\":\"e... | public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String baseEntityId = client != nul... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... |
@Test public void processCaseModelWhenGivenColumnConfigurationFromClientIdentifiersFieldShouldPopulateContentValues() { String eventJson = "{\"baseEntityId\":\"3a221190-c004-4297-88bd-4b925e19098f\",\"entityType\":\"ec_family_member\",\"eventDate\":\"2019-09-23T20:00:00.000-04:00\",\"eventType\":\"Family Member Registr... | public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String baseEntityId = client != nul... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... |
@Test public void processCaseModelWhenGivenColumnConfigurationFromClientRelationshipsFieldShouldPopulateContentValues() { String eventJson = "{\"baseEntityId\":\"3a221190-c004-4297-88bd-4b925e19098f\",\"entityType\":\"ec_family_member\",\"eventDate\":\"2019-09-23T20:00:00.000-04:00\",\"eventType\":\"Family Member Regis... | public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String baseEntityId = client != nul... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... |
@Test public void processCaseModelWhenGivenColumnConfigurationFromClientAddressesFieldShouldPopulateContentValues() { String eventJson = "{\"baseEntityId\":\"5b85d576-51cd-4ccc-bfd7-2b67d4af89e3\",\"entityType\":\"ec_family\",\"eventDate\":\"2019-09-24T08:12:12.000-04:00\",\"eventType\":\"Update Family Relations\",\"fo... | public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String baseEntityId = client != nul... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... | ClientProcessorForJava { public Boolean processCaseModel(Event event, Client client, List<String> createsCase) { try { if (createsCase == null || createsCase.isEmpty()) { return false; } for (String clientType : createsCase) { Table table = getColumnMappings(clientType); List<Column> columns = table.columns; String bas... |
@Test public void processClientTest() throws Exception { JSONArray eventArray = new JSONArray(ClientData.eventJsonArray); final ArrayList<JSONObject> eventList = new ArrayList<JSONObject>(); for (int i = 0; i < eventArray.length(); i++) { eventList.add(eventArray.getJSONObject(i)); } JSONArray clientArray = new JSONArr... | public synchronized void processClient() throws Exception { AllSharedPreferences allSharedPreferences = new AllSharedPreferences(preferences); long lastSyncTimeStamp = allSharedPreferences.fetchLastSyncDate(0); Date lastSyncDate = new Date(lastSyncTimeStamp); String clientClassificationStr = getFileContents("ec_client_... | ClientProcessor { public synchronized void processClient() throws Exception { AllSharedPreferences allSharedPreferences = new AllSharedPreferences(preferences); long lastSyncTimeStamp = allSharedPreferences.fetchLastSyncDate(0); Date lastSyncDate = new Date(lastSyncTimeStamp); String clientClassificationStr = getFileCo... | ClientProcessor { public synchronized void processClient() throws Exception { AllSharedPreferences allSharedPreferences = new AllSharedPreferences(preferences); long lastSyncTimeStamp = allSharedPreferences.fetchLastSyncDate(0); Date lastSyncDate = new Date(lastSyncTimeStamp); String clientClassificationStr = getFileCo... | ClientProcessor { public synchronized void processClient() throws Exception { AllSharedPreferences allSharedPreferences = new AllSharedPreferences(preferences); long lastSyncTimeStamp = allSharedPreferences.fetchLastSyncDate(0); Date lastSyncDate = new Date(lastSyncTimeStamp); String clientClassificationStr = getFileCo... | ClientProcessor { public synchronized void processClient() throws Exception { AllSharedPreferences allSharedPreferences = new AllSharedPreferences(preferences); long lastSyncTimeStamp = allSharedPreferences.fetchLastSyncDate(0); Date lastSyncDate = new Date(lastSyncTimeStamp); String clientClassificationStr = getFileCo... |
@Test public void assertProcessFieldReturnsTrue() throws Exception { final JSONObject fieldObject = new JSONObject(ClientData.ec_client_fields_json); final ArrayList<JSONObject> eventList = new ArrayList<JSONObject>(); JSONArray eventArray = new JSONArray(ClientData.eventJsonArray); for (int i = 0; i < eventArray.lengt... | public Boolean processField(JSONObject fieldJson, JSONObject event, JSONObject client) { try { if (fieldJson == null || fieldJson.length() == 0) { return false; } String dataSegment = null; String fieldName = fieldJson.has("field") ? fieldJson.getString("field") : null; String fieldValue = fieldJson.has("field_value") ... | ClientProcessor { public Boolean processField(JSONObject fieldJson, JSONObject event, JSONObject client) { try { if (fieldJson == null || fieldJson.length() == 0) { return false; } String dataSegment = null; String fieldName = fieldJson.has("field") ? fieldJson.getString("field") : null; String fieldValue = fieldJson.h... | ClientProcessor { public Boolean processField(JSONObject fieldJson, JSONObject event, JSONObject client) { try { if (fieldJson == null || fieldJson.length() == 0) { return false; } String dataSegment = null; String fieldName = fieldJson.has("field") ? fieldJson.getString("field") : null; String fieldValue = fieldJson.h... | ClientProcessor { public Boolean processField(JSONObject fieldJson, JSONObject event, JSONObject client) { try { if (fieldJson == null || fieldJson.length() == 0) { return false; } String dataSegment = null; String fieldName = fieldJson.has("field") ? fieldJson.getString("field") : null; String fieldValue = fieldJson.h... | ClientProcessor { public Boolean processField(JSONObject fieldJson, JSONObject event, JSONObject client) { try { if (fieldJson == null || fieldJson.length() == 0) { return false; } String dataSegment = null; String fieldName = fieldJson.has("field") ? fieldJson.getString("field") : null; String fieldValue = fieldJson.h... |
@Test public void assertIsVaidDateReturnsBoolean() { Assert.assertEquals(DateUtil.isValidDate(null), false); Assert.assertEquals(DateUtil.isValidDate("invaliddate"), false); Assert.assertEquals(DateUtil.isValidDate("2017-10-20"), true); } | public static boolean isValidDate(String dateString) { if (dateString == null || dateString.length() != "yyyy-MM-dd".length()) { return false; } return dateString.matches("\\d{4}-\\d{2}-\\d{2}"); } | DateUtil { public static boolean isValidDate(String dateString) { if (dateString == null || dateString.length() != "yyyy-MM-dd".length()) { return false; } return dateString.matches("\\d{4}-\\d{2}-\\d{2}"); } } | DateUtil { public static boolean isValidDate(String dateString) { if (dateString == null || dateString.length() != "yyyy-MM-dd".length()) { return false; } return dateString.matches("\\d{4}-\\d{2}-\\d{2}"); } } | DateUtil { public static boolean isValidDate(String dateString) { if (dateString == null || dateString.length() != "yyyy-MM-dd".length()) { return false; } return dateString.matches("\\d{4}-\\d{2}-\\d{2}"); } static void fakeIt(LocalDate fakeDayAsToday); static void setDefaultDateFormat(String defaultDateFormat); stat... | DateUtil { public static boolean isValidDate(String dateString) { if (dateString == null || dateString.length() != "yyyy-MM-dd".length()) { return false; } return dateString.matches("\\d{4}-\\d{2}-\\d{2}"); } static void fakeIt(LocalDate fakeDayAsToday); static void setDefaultDateFormat(String defaultDateFormat); stat... |
@Test public void instantiatesSuccessfullyOnConstructorCall() throws Exception { Assert.assertNotNull(new ClientProcessor(context.applicationContext())); Assert.assertNotNull(ClientProcessor.getInstance(context.applicationContext())); } | public static ClientProcessor getInstance(Context context) { if (instance == null) { instance = new ClientProcessor(context); } return instance; } | ClientProcessor { public static ClientProcessor getInstance(Context context) { if (instance == null) { instance = new ClientProcessor(context); } return instance; } } | ClientProcessor { public static ClientProcessor getInstance(Context context) { if (instance == null) { instance = new ClientProcessor(context); } return instance; } ClientProcessor(Context context); } | ClientProcessor { public static ClientProcessor getInstance(Context context) { if (instance == null) { instance = new ClientProcessor(context); } return instance; } ClientProcessor(Context context); static ClientProcessor getInstance(Context context); synchronized void processClient(); synchronized void processClient(L... | ClientProcessor { public static ClientProcessor getInstance(Context context) { if (instance == null) { instance = new ClientProcessor(context); } return instance; } ClientProcessor(Context context); static ClientProcessor getInstance(Context context); synchronized void processClient(); synchronized void processClient(L... |
@Test public void ProcessEventReturnsNotNull() throws Exception { JSONArray eventArray = new JSONArray(ClientData.eventJsonArray); final ArrayList<JSONObject> eventList = new ArrayList<JSONObject>(); for (int i = 0; i < eventArray.length(); i++) { eventList.add(eventArray.getJSONObject(i)); } JSONArray clientArray = ne... | public Boolean processEvent(JSONObject event, JSONObject clientClassificationJson) throws Exception { try { String baseEntityId = event.getString(baseEntityIdJSONKey); if (event.has("creator")) { Timber.i("EVENT from openmrs"); } JSONObject client = getClient(baseEntityId); if (isNullOrEmptyJSONObject(client)) { return... | ClientProcessor { public Boolean processEvent(JSONObject event, JSONObject clientClassificationJson) throws Exception { try { String baseEntityId = event.getString(baseEntityIdJSONKey); if (event.has("creator")) { Timber.i("EVENT from openmrs"); } JSONObject client = getClient(baseEntityId); if (isNullOrEmptyJSONObject... | ClientProcessor { public Boolean processEvent(JSONObject event, JSONObject clientClassificationJson) throws Exception { try { String baseEntityId = event.getString(baseEntityIdJSONKey); if (event.has("creator")) { Timber.i("EVENT from openmrs"); } JSONObject client = getClient(baseEntityId); if (isNullOrEmptyJSONObject... | ClientProcessor { public Boolean processEvent(JSONObject event, JSONObject clientClassificationJson) throws Exception { try { String baseEntityId = event.getString(baseEntityIdJSONKey); if (event.has("creator")) { Timber.i("EVENT from openmrs"); } JSONObject client = getClient(baseEntityId); if (isNullOrEmptyJSONObject... | ClientProcessor { public Boolean processEvent(JSONObject event, JSONObject clientClassificationJson) throws Exception { try { String baseEntityId = event.getString(baseEntityIdJSONKey); if (event.has("creator")) { Timber.i("EVENT from openmrs"); } JSONObject client = getClient(baseEntityId); if (isNullOrEmptyJSONObject... |
@Test public void getClientAddressAsMapReturnsNotNull() throws Exception { JSONArray eventArray = new JSONArray(ClientData.eventJsonArray); final ArrayList<JSONObject> eventList = new ArrayList<JSONObject>(); for (int i = 0; i < eventArray.length(); i++) { eventList.add(eventArray.getJSONObject(i)); } JSONArray clientA... | public Map<String, String> getClientAddressAsMap(JSONObject client) { Map<String, String> addressMap = new HashMap<String, String>(); try { String addressFieldsKey = "addressFields"; String addressesKey = "addresses"; if (client.has(addressesKey)) { JSONArray addressJsonArray = client.getJSONArray(addressesKey); if (ad... | ClientProcessor { public Map<String, String> getClientAddressAsMap(JSONObject client) { Map<String, String> addressMap = new HashMap<String, String>(); try { String addressFieldsKey = "addressFields"; String addressesKey = "addresses"; if (client.has(addressesKey)) { JSONArray addressJsonArray = client.getJSONArray(add... | ClientProcessor { public Map<String, String> getClientAddressAsMap(JSONObject client) { Map<String, String> addressMap = new HashMap<String, String>(); try { String addressFieldsKey = "addressFields"; String addressesKey = "addresses"; if (client.has(addressesKey)) { JSONArray addressJsonArray = client.getJSONArray(add... | ClientProcessor { public Map<String, String> getClientAddressAsMap(JSONObject client) { Map<String, String> addressMap = new HashMap<String, String>(); try { String addressFieldsKey = "addressFields"; String addressesKey = "addresses"; if (client.has(addressesKey)) { JSONArray addressJsonArray = client.getJSONArray(add... | ClientProcessor { public Map<String, String> getClientAddressAsMap(JSONObject client) { Map<String, String> addressMap = new HashMap<String, String>(); try { String addressFieldsKey = "addressFields"; String addressesKey = "addresses"; if (client.has(addressesKey)) { JSONArray addressJsonArray = client.getJSONArray(add... |
@Test public void processCaseModelReturnsNotNUll() throws Exception { JSONArray eventArray = new JSONArray(ClientData.eventJsonArray); final ArrayList<JSONObject> eventList = new ArrayList<JSONObject>(); for (int i = 0; i < eventArray.length(); i++) { eventList.add(eventArray.getJSONObject(i)); } JSONArray clientArray ... | public Boolean processCaseModel(JSONObject event, JSONObject client, JSONArray createsCase) { try { if (createsCase == null || createsCase.length() == 0) { return false; } for (int openCase = 0; openCase < createsCase.length(); openCase++) { String clientType = createsCase.getString(openCase); JSONObject columnMappings... | ClientProcessor { public Boolean processCaseModel(JSONObject event, JSONObject client, JSONArray createsCase) { try { if (createsCase == null || createsCase.length() == 0) { return false; } for (int openCase = 0; openCase < createsCase.length(); openCase++) { String clientType = createsCase.getString(openCase); JSONObj... | ClientProcessor { public Boolean processCaseModel(JSONObject event, JSONObject client, JSONArray createsCase) { try { if (createsCase == null || createsCase.length() == 0) { return false; } for (int openCase = 0; openCase < createsCase.length(); openCase++) { String clientType = createsCase.getString(openCase); JSONObj... | ClientProcessor { public Boolean processCaseModel(JSONObject event, JSONObject client, JSONArray createsCase) { try { if (createsCase == null || createsCase.length() == 0) { return false; } for (int openCase = 0; openCase < createsCase.length(); openCase++) { String clientType = createsCase.getString(openCase); JSONObj... | ClientProcessor { public Boolean processCaseModel(JSONObject event, JSONObject client, JSONArray createsCase) { try { if (createsCase == null || createsCase.length() == 0) { return false; } for (int openCase = 0; openCase < createsCase.length(); openCase++) { String clientType = createsCase.getString(openCase); JSONObj... |
@Test public void onHandleIntentShouldProcessEventsIfPeerToPeerUnprocessedEventsReturnsTrue() throws Exception { p2pProcessRecordsService.onHandleIntent(null); Mockito.verify(eventClientRepository, Mockito.never()).getMaxRowId(Mockito.any(EventClientRepository.Table.class)); Mockito.verify(clientProcessorForJava, Mocki... | @Override protected void onHandleIntent(@Nullable Intent intent) { super.onHandleIntent(intent); AllSharedPreferences allSharedPreferences = CoreLibrary.getInstance().context().allSharedPreferences(); if (allSharedPreferences.isPeerToPeerUnprocessedEvents()) { CoreLibrary.getInstance().setPeerToPeerProcessing(true); lo... | P2pProcessRecordsService extends BaseSyncIntentService { @Override protected void onHandleIntent(@Nullable Intent intent) { super.onHandleIntent(intent); AllSharedPreferences allSharedPreferences = CoreLibrary.getInstance().context().allSharedPreferences(); if (allSharedPreferences.isPeerToPeerUnprocessedEvents()) { Co... | P2pProcessRecordsService extends BaseSyncIntentService { @Override protected void onHandleIntent(@Nullable Intent intent) { super.onHandleIntent(intent); AllSharedPreferences allSharedPreferences = CoreLibrary.getInstance().context().allSharedPreferences(); if (allSharedPreferences.isPeerToPeerUnprocessedEvents()) { Co... | P2pProcessRecordsService extends BaseSyncIntentService { @Override protected void onHandleIntent(@Nullable Intent intent) { super.onHandleIntent(intent); AllSharedPreferences allSharedPreferences = CoreLibrary.getInstance().context().allSharedPreferences(); if (allSharedPreferences.isPeerToPeerUnprocessedEvents()) { Co... | P2pProcessRecordsService extends BaseSyncIntentService { @Override protected void onHandleIntent(@Nullable Intent intent) { super.onHandleIntent(intent); AllSharedPreferences allSharedPreferences = CoreLibrary.getInstance().context().allSharedPreferences(); if (allSharedPreferences.isPeerToPeerUnprocessedEvents()) { Co... |
@Test public void onDestroyShouldSetPeerProcessingToFalse() { CoreLibrary.getInstance().setPeerToPeerProcessing(true); Assert.assertTrue(CoreLibrary.getInstance().isPeerToPeerProcessing()); p2pProcessRecordsService.onDestroy(); Assert.assertFalse(CoreLibrary.getInstance().isPeerToPeerProcessing()); } | @Override public void onDestroy() { if (CoreLibrary.getInstance().isPeerToPeerProcessing()) { CoreLibrary.getInstance().setPeerToPeerProcessing(false); } super.onDestroy(); } | P2pProcessRecordsService extends BaseSyncIntentService { @Override public void onDestroy() { if (CoreLibrary.getInstance().isPeerToPeerProcessing()) { CoreLibrary.getInstance().setPeerToPeerProcessing(false); } super.onDestroy(); } } | P2pProcessRecordsService extends BaseSyncIntentService { @Override public void onDestroy() { if (CoreLibrary.getInstance().isPeerToPeerProcessing()) { CoreLibrary.getInstance().setPeerToPeerProcessing(false); } super.onDestroy(); } P2pProcessRecordsService(String name); P2pProcessRecordsService(); } | P2pProcessRecordsService extends BaseSyncIntentService { @Override public void onDestroy() { if (CoreLibrary.getInstance().isPeerToPeerProcessing()) { CoreLibrary.getInstance().setPeerToPeerProcessing(false); } super.onDestroy(); } P2pProcessRecordsService(String name); P2pProcessRecordsService(); @Override void onDes... | P2pProcessRecordsService extends BaseSyncIntentService { @Override public void onDestroy() { if (CoreLibrary.getInstance().isPeerToPeerProcessing()) { CoreLibrary.getInstance().setPeerToPeerProcessing(false); } super.onDestroy(); } P2pProcessRecordsService(String name); P2pProcessRecordsService(); @Override void onDes... |
@Test public void testInit() { assertNotNull(Whitebox.getInternalState(syncIntentService, "httpAgent")); assertNotNull(Whitebox.getInternalState(syncIntentService, "syncUtils")); assertNotNull(Whitebox.getInternalState(syncIntentService, "context")); } | protected void init(@NonNull Context context) { this.context = context; httpAgent = CoreLibrary.getInstance().context().getHttpAgent(); syncUtils = new SyncUtils(getBaseContext()); validateAssignmentHelper = new ValidateAssignmentHelper(syncUtils); } | SyncIntentService extends BaseSyncIntentService { protected void init(@NonNull Context context) { this.context = context; httpAgent = CoreLibrary.getInstance().context().getHttpAgent(); syncUtils = new SyncUtils(getBaseContext()); validateAssignmentHelper = new ValidateAssignmentHelper(syncUtils); } } | SyncIntentService extends BaseSyncIntentService { protected void init(@NonNull Context context) { this.context = context; httpAgent = CoreLibrary.getInstance().context().getHttpAgent(); syncUtils = new SyncUtils(getBaseContext()); validateAssignmentHelper = new ValidateAssignmentHelper(syncUtils); } SyncIntentService()... | SyncIntentService extends BaseSyncIntentService { protected void init(@NonNull Context context) { this.context = context; httpAgent = CoreLibrary.getInstance().context().getHttpAgent(); syncUtils = new SyncUtils(getBaseContext()); validateAssignmentHelper = new ValidateAssignmentHelper(syncUtils); } SyncIntentService()... | SyncIntentService extends BaseSyncIntentService { protected void init(@NonNull Context context) { this.context = context; httpAgent = CoreLibrary.getInstance().context().getHttpAgent(); syncUtils = new SyncUtils(getBaseContext()); validateAssignmentHelper = new ValidateAssignmentHelper(syncUtils); } SyncIntentService()... |
@Test public void testHandleSyncSendFetchStartedBroadCast() throws PackageManager.NameNotFoundException { syncIntentService = spy(syncIntentService); Whitebox.setInternalState(syncIntentService, "syncUtils", syncUtils); when(syncUtils.verifyAuthorization()).thenReturn(true); when(syncUtils.isAppVersionAllowed()).thenRe... | protected void handleSync() { sendSyncStatusBroadcastMessage(FetchStatus.fetchStarted); doSync(); } | SyncIntentService extends BaseSyncIntentService { protected void handleSync() { sendSyncStatusBroadcastMessage(FetchStatus.fetchStarted); doSync(); } } | SyncIntentService extends BaseSyncIntentService { protected void handleSync() { sendSyncStatusBroadcastMessage(FetchStatus.fetchStarted); doSync(); } SyncIntentService(); SyncIntentService(String name); } | SyncIntentService extends BaseSyncIntentService { protected void handleSync() { sendSyncStatusBroadcastMessage(FetchStatus.fetchStarted); doSync(); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLi... | SyncIntentService extends BaseSyncIntentService { protected void handleSync() { sendSyncStatusBroadcastMessage(FetchStatus.fetchStarted); doSync(); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLi... |
@Test public void testHandleSyncCallsLogoutUserIfHasValidAuthorizationIsFalse() throws AuthenticatorException, OperationCanceledException, IOException { Whitebox.setInternalState(syncIntentService, "syncUtils", syncUtils); when(syncUtils.verifyAuthorization()).thenReturn(false); when(syncConfiguration.disableSyncToServ... | protected void handleSync() { sendSyncStatusBroadcastMessage(FetchStatus.fetchStarted); doSync(); } | SyncIntentService extends BaseSyncIntentService { protected void handleSync() { sendSyncStatusBroadcastMessage(FetchStatus.fetchStarted); doSync(); } } | SyncIntentService extends BaseSyncIntentService { protected void handleSync() { sendSyncStatusBroadcastMessage(FetchStatus.fetchStarted); doSync(); } SyncIntentService(); SyncIntentService(String name); } | SyncIntentService extends BaseSyncIntentService { protected void handleSync() { sendSyncStatusBroadcastMessage(FetchStatus.fetchStarted); doSync(); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLi... | SyncIntentService extends BaseSyncIntentService { protected void handleSync() { sendSyncStatusBroadcastMessage(FetchStatus.fetchStarted); doSync(); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLi... |
@Test public void testHandleSyncCallsLogOutUserIfAppVersionIsNotAllowedAnd() throws AuthenticatorException, OperationCanceledException, IOException { syncIntentService = spy(syncIntentService); Whitebox.setInternalState(syncIntentService, "syncUtils", syncUtils); when(syncUtils.verifyAuthorization()).thenReturn(true); ... | protected void handleSync() { sendSyncStatusBroadcastMessage(FetchStatus.fetchStarted); doSync(); } | SyncIntentService extends BaseSyncIntentService { protected void handleSync() { sendSyncStatusBroadcastMessage(FetchStatus.fetchStarted); doSync(); } } | SyncIntentService extends BaseSyncIntentService { protected void handleSync() { sendSyncStatusBroadcastMessage(FetchStatus.fetchStarted); doSync(); } SyncIntentService(); SyncIntentService(String name); } | SyncIntentService extends BaseSyncIntentService { protected void handleSync() { sendSyncStatusBroadcastMessage(FetchStatus.fetchStarted); doSync(); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLi... | SyncIntentService extends BaseSyncIntentService { protected void handleSync() { sendSyncStatusBroadcastMessage(FetchStatus.fetchStarted); doSync(); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLi... |
@Test public void assertWeekDifferenceReturnsInt() { LocalDate start = new LocalDate(1447487308000l); LocalDate end = new LocalDate(1510645708000l); Assert.assertEquals(DateUtil.weekDifference(start, end), 104); } | public static int weekDifference(LocalDate startDate, LocalDate endDate) { try { return Math.abs(Weeks.weeksBetween(startDate, endDate).getWeeks()); } catch (Exception e) { return 0; } } | DateUtil { public static int weekDifference(LocalDate startDate, LocalDate endDate) { try { return Math.abs(Weeks.weeksBetween(startDate, endDate).getWeeks()); } catch (Exception e) { return 0; } } } | DateUtil { public static int weekDifference(LocalDate startDate, LocalDate endDate) { try { return Math.abs(Weeks.weeksBetween(startDate, endDate).getWeeks()); } catch (Exception e) { return 0; } } } | DateUtil { public static int weekDifference(LocalDate startDate, LocalDate endDate) { try { return Math.abs(Weeks.weeksBetween(startDate, endDate).getWeeks()); } catch (Exception e) { return 0; } } static void fakeIt(LocalDate fakeDayAsToday); static void setDefaultDateFormat(String defaultDateFormat); static LocalDat... | DateUtil { public static int weekDifference(LocalDate startDate, LocalDate endDate) { try { return Math.abs(Weeks.weeksBetween(startDate, endDate).getWeeks()); } catch (Exception e) { return 0; } } static void fakeIt(LocalDate fakeDayAsToday); static void setDefaultDateFormat(String defaultDateFormat); static LocalDat... |
@Test public void testPullEcFromServerWhenSyncFilterParamIsNull() throws PackageManager.NameNotFoundException { syncIntentService = spy(syncIntentService); syncIntentService.pullECFromServer(); verify(syncIntentService).sendBroadcast(intentArgumentCaptor.capture()); assertEquals(SyncStatusBroadcastReceiver.ACTION_SYNC_... | protected void pullECFromServer() { fetchRetry(0, true); } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLimit(); HTTPAgent getHttpAgent(); Context ... | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLimit(); HTTPAgent getHttpAgent(); Context ... |
@Test public void testPullEcFromServerWhenSyncFilterValueIsNull() throws PackageManager.NameNotFoundException { syncIntentService = spy(syncIntentService); when(syncConfiguration.getSyncFilterParam()).thenReturn(SyncFilter.LOCATION); syncIntentService.pullECFromServer(); verify(syncIntentService).sendBroadcast(intentAr... | protected void pullECFromServer() { fetchRetry(0, true); } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLimit(); HTTPAgent getHttpAgent(); Context ... | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLimit(); HTTPAgent getHttpAgent(); Context ... |
@Test public void testPullEcFromServerWhenHttpAgentIsNull() throws PackageManager.NameNotFoundException { syncIntentService = spy(syncIntentService); Whitebox.setInternalState(syncIntentService, "httpAgent", (Object[]) null); assertNull(Whitebox.getInternalState(syncIntentService, "httpAgent")); when(syncConfiguration.... | protected void pullECFromServer() { fetchRetry(0, true); } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLimit(); HTTPAgent getHttpAgent(); Context ... | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLimit(); HTTPAgent getHttpAgent(); Context ... |
@Test public void testPullEcFromServerUsingPOSTUsesCorrectURLAndParams() throws PackageManager.NameNotFoundException { syncIntentService = spy(syncIntentService); initMocksForPullECFromServerUsingPOST(); ResponseStatus responseStatus = ResponseStatus.failure; responseStatus.setDisplayValue(ResponseErrorStatus.malformed... | protected void pullECFromServer() { fetchRetry(0, true); } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLimit(); HTTPAgent getHttpAgent(); Context ... | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLimit(); HTTPAgent getHttpAgent(); Context ... |
@Test public void testPullEcFromServerWithURLError() throws PackageManager.NameNotFoundException { syncIntentService = spy(syncIntentService); initMocksForPullECFromServerUsingPOST(); ResponseStatus responseStatus = ResponseStatus.failure; responseStatus.setDisplayValue(ResponseErrorStatus.malformed_url.name()); Mockit... | protected void pullECFromServer() { fetchRetry(0, true); } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLimit(); HTTPAgent getHttpAgent(); Context ... | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLimit(); HTTPAgent getHttpAgent(); Context ... |
@Test public void testPullEcFromServerWithTimeoutError() throws PackageManager.NameNotFoundException { syncIntentService = spy(syncIntentService); initMocksForPullECFromServerUsingPOST(); ResponseStatus responseStatus = ResponseStatus.failure; responseStatus.setDisplayValue(ResponseErrorStatus.timeout.name()); Mockito.... | protected void pullECFromServer() { fetchRetry(0, true); } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLimit(); HTTPAgent getHttpAgent(); Context ... | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLimit(); HTTPAgent getHttpAgent(); Context ... |
@Test public void testFetchFailedWithCountLessThanMaxSyncRetryCallsFetchRetry() { when(syncConfiguration.getSyncMaxRetries()).thenReturn(1); initMocksForPullECFromServerUsingPOST(); syncIntentService = spy(syncIntentService); ResponseStatus responseStatus = ResponseStatus.failure; Mockito.doReturn(new Response<>(respon... | public void fetchFailed(int count) { if (count < CoreLibrary.getInstance().getSyncConfiguration().getSyncMaxRetries()) { int newCount = count + 1; fetchRetry(newCount, false); } else { complete(FetchStatus.fetchedFailed); } } | SyncIntentService extends BaseSyncIntentService { public void fetchFailed(int count) { if (count < CoreLibrary.getInstance().getSyncConfiguration().getSyncMaxRetries()) { int newCount = count + 1; fetchRetry(newCount, false); } else { complete(FetchStatus.fetchedFailed); } } } | SyncIntentService extends BaseSyncIntentService { public void fetchFailed(int count) { if (count < CoreLibrary.getInstance().getSyncConfiguration().getSyncMaxRetries()) { int newCount = count + 1; fetchRetry(newCount, false); } else { complete(FetchStatus.fetchedFailed); } } SyncIntentService(); SyncIntentService(Stri... | SyncIntentService extends BaseSyncIntentService { public void fetchFailed(int count) { if (count < CoreLibrary.getInstance().getSyncConfiguration().getSyncMaxRetries()) { int newCount = count + 1; fetchRetry(newCount, false); } else { complete(FetchStatus.fetchedFailed); } } SyncIntentService(); SyncIntentService(Stri... | SyncIntentService extends BaseSyncIntentService { public void fetchFailed(int count) { if (count < CoreLibrary.getInstance().getSyncConfiguration().getSyncMaxRetries()) { int newCount = count + 1; fetchRetry(newCount, false); } else { complete(FetchStatus.fetchedFailed); } } SyncIntentService(); SyncIntentService(Stri... |
@Test public void testSuccessfulPullEcFromServerWithNullPayloadSendsNothingFetchedBroadcast() { initMocksForPullECFromServerUsingPOST(); syncIntentService = spy(syncIntentService); ResponseStatus responseStatus = ResponseStatus.success; Mockito.doReturn(new Response<>(responseStatus, null).withTotalRecords(0l)) .when(h... | protected void pullECFromServer() { fetchRetry(0, true); } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); } | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLimit(); HTTPAgent getHttpAgent(); Context ... | SyncIntentService extends BaseSyncIntentService { protected void pullECFromServer() { fetchRetry(0, true); } SyncIntentService(); SyncIntentService(String name); @Override int onStartCommand(Intent intent, int flags, int startId); void fetchFailed(int count); int getEventPullLimit(); HTTPAgent getHttpAgent(); Context ... |
@Test public void testPushECToServer() throws Exception { syncIntentService = spy(syncIntentService); Map<String, Object> pendingEvents = new HashMap<>(); List<JSONObject> clients = new ArrayList<>(); JSONObject client = new JSONObject(clientJson); clients.add(client); List<JSONObject> events = new ArrayList<>(); JSONO... | private boolean pushECToServer(EventClientRepository db) { boolean isSuccessfulPushSync = true; int totalEventCount = db.getUnSyncedEventsCount(); int eventsUploadedCount = 0; while (true) { Map<String, Object> pendingEvents = db.getUnSyncedEvents(EVENT_PUSH_LIMIT); if (pendingEvents.isEmpty()) { break; } String baseUr... | SyncIntentService extends BaseSyncIntentService { private boolean pushECToServer(EventClientRepository db) { boolean isSuccessfulPushSync = true; int totalEventCount = db.getUnSyncedEventsCount(); int eventsUploadedCount = 0; while (true) { Map<String, Object> pendingEvents = db.getUnSyncedEvents(EVENT_PUSH_LIMIT); if ... | SyncIntentService extends BaseSyncIntentService { private boolean pushECToServer(EventClientRepository db) { boolean isSuccessfulPushSync = true; int totalEventCount = db.getUnSyncedEventsCount(); int eventsUploadedCount = 0; while (true) { Map<String, Object> pendingEvents = db.getUnSyncedEvents(EVENT_PUSH_LIMIT); if ... | SyncIntentService extends BaseSyncIntentService { private boolean pushECToServer(EventClientRepository db) { boolean isSuccessfulPushSync = true; int totalEventCount = db.getUnSyncedEventsCount(); int eventsUploadedCount = 0; while (true) { Map<String, Object> pendingEvents = db.getUnSyncedEvents(EVENT_PUSH_LIMIT); if ... | SyncIntentService extends BaseSyncIntentService { private boolean pushECToServer(EventClientRepository db) { boolean isSuccessfulPushSync = true; int totalEventCount = db.getUnSyncedEventsCount(); int eventsUploadedCount = 0; while (true) { Map<String, Object> pendingEvents = db.getUnSyncedEvents(EVENT_PUSH_LIMIT); if ... |
@Test public void onStartCommandShouldInstantiateVariables() { Assert.assertNull(ReflectionHelpers.getField(documentConfigurationIntentService, "httpAgent")); Assert.assertNull(ReflectionHelpers.getField(documentConfigurationIntentService, "manifestRepository")); Assert.assertNull(ReflectionHelpers.getField(documentCon... | @Override public int onStartCommand(Intent intent, int flags, int startId) { httpAgent = CoreLibrary.getInstance().context().getHttpAgent(); manifestRepository = CoreLibrary.getInstance().context().getManifestRepository(); clientFormRepository = CoreLibrary.getInstance().context().getClientFormRepository(); configurati... | DocumentConfigurationIntentService extends BaseSyncIntentService { @Override public int onStartCommand(Intent intent, int flags, int startId) { httpAgent = CoreLibrary.getInstance().context().getHttpAgent(); manifestRepository = CoreLibrary.getInstance().context().getManifestRepository(); clientFormRepository = CoreLib... | DocumentConfigurationIntentService extends BaseSyncIntentService { @Override public int onStartCommand(Intent intent, int flags, int startId) { httpAgent = CoreLibrary.getInstance().context().getHttpAgent(); manifestRepository = CoreLibrary.getInstance().context().getManifestRepository(); clientFormRepository = CoreLib... | DocumentConfigurationIntentService extends BaseSyncIntentService { @Override public int onStartCommand(Intent intent, int flags, int startId) { httpAgent = CoreLibrary.getInstance().context().getHttpAgent(); manifestRepository = CoreLibrary.getInstance().context().getManifestRepository(); clientFormRepository = CoreLib... | DocumentConfigurationIntentService extends BaseSyncIntentService { @Override public int onStartCommand(Intent intent, int flags, int startId) { httpAgent = CoreLibrary.getInstance().context().getHttpAgent(); manifestRepository = CoreLibrary.getInstance().context().getManifestRepository(); clientFormRepository = CoreLib... |
@Test public void formatDateTest() { Assert.assertEquals("03-10-2019", DateUtil.formatDate(new LocalDate("2019-10-03"), "dd-MM-YYY")); Assert.assertEquals("", DateUtil.formatDate(new LocalDate("2019-10-03"), "KK-TT")); } | public static String formatDate(String unformattedDate) { return formatDate(unformattedDate, DEFAULT_DATE_FORMAT); } | DateUtil { public static String formatDate(String unformattedDate) { return formatDate(unformattedDate, DEFAULT_DATE_FORMAT); } } | DateUtil { public static String formatDate(String unformattedDate) { return formatDate(unformattedDate, DEFAULT_DATE_FORMAT); } } | DateUtil { public static String formatDate(String unformattedDate) { return formatDate(unformattedDate, DEFAULT_DATE_FORMAT); } static void fakeIt(LocalDate fakeDayAsToday); static void setDefaultDateFormat(String defaultDateFormat); static LocalDate today(); static String formatDateForTimelineEvent(String unformatted... | DateUtil { public static String formatDate(String unformattedDate) { return formatDate(unformattedDate, DEFAULT_DATE_FORMAT); } static void fakeIt(LocalDate fakeDayAsToday); static void setDefaultDateFormat(String defaultDateFormat); static LocalDate today(); static String formatDateForTimelineEvent(String unformatted... |
@Test public void processSettingsShouldReturnTrueWhenIntentIsNull() throws JSONException { settingsSyncIntentService.syncSettingsServiceHelper = Mockito.spy(settingsSyncIntentService.syncSettingsServiceHelper); Assert.assertTrue(settingsSyncIntentService.processSettings(null)); Mockito.verify(settingsSyncIntentService.... | protected boolean processSettings(Intent intent) { Timber.d("In Settings Sync Intent Service..."); boolean isSuccessfulSync = true; if (intent != null) { try { super.onHandleIntent(intent); int count = syncSettingsServiceHelper.processIntent(); if (count > 0) { intent.putExtra(AllConstants.INTENT_KEY.SYNC_TOTAL_RECORDS... | SettingsSyncIntentService extends BaseSyncIntentService { protected boolean processSettings(Intent intent) { Timber.d("In Settings Sync Intent Service..."); boolean isSuccessfulSync = true; if (intent != null) { try { super.onHandleIntent(intent); int count = syncSettingsServiceHelper.processIntent(); if (count > 0) { ... | SettingsSyncIntentService extends BaseSyncIntentService { protected boolean processSettings(Intent intent) { Timber.d("In Settings Sync Intent Service..."); boolean isSuccessfulSync = true; if (intent != null) { try { super.onHandleIntent(intent); int count = syncSettingsServiceHelper.processIntent(); if (count > 0) { ... | SettingsSyncIntentService extends BaseSyncIntentService { protected boolean processSettings(Intent intent) { Timber.d("In Settings Sync Intent Service..."); boolean isSuccessfulSync = true; if (intent != null) { try { super.onHandleIntent(intent); int count = syncSettingsServiceHelper.processIntent(); if (count > 0) { ... | SettingsSyncIntentService extends BaseSyncIntentService { protected boolean processSettings(Intent intent) { Timber.d("In Settings Sync Intent Service..."); boolean isSuccessfulSync = true; if (intent != null) { try { super.onHandleIntent(intent); int count = syncSettingsServiceHelper.processIntent(); if (count > 0) { ... |
@Test public void processSettingsShouldReturnTrueAndCallProcessIntentWhenIntentIsNotNull() throws JSONException { settingsSyncIntentService.syncSettingsServiceHelper = Mockito.spy(settingsSyncIntentService.syncSettingsServiceHelper); Mockito.doReturn(30).when(settingsSyncIntentService.syncSettingsServiceHelper).process... | protected boolean processSettings(Intent intent) { Timber.d("In Settings Sync Intent Service..."); boolean isSuccessfulSync = true; if (intent != null) { try { super.onHandleIntent(intent); int count = syncSettingsServiceHelper.processIntent(); if (count > 0) { intent.putExtra(AllConstants.INTENT_KEY.SYNC_TOTAL_RECORDS... | SettingsSyncIntentService extends BaseSyncIntentService { protected boolean processSettings(Intent intent) { Timber.d("In Settings Sync Intent Service..."); boolean isSuccessfulSync = true; if (intent != null) { try { super.onHandleIntent(intent); int count = syncSettingsServiceHelper.processIntent(); if (count > 0) { ... | SettingsSyncIntentService extends BaseSyncIntentService { protected boolean processSettings(Intent intent) { Timber.d("In Settings Sync Intent Service..."); boolean isSuccessfulSync = true; if (intent != null) { try { super.onHandleIntent(intent); int count = syncSettingsServiceHelper.processIntent(); if (count > 0) { ... | SettingsSyncIntentService extends BaseSyncIntentService { protected boolean processSettings(Intent intent) { Timber.d("In Settings Sync Intent Service..."); boolean isSuccessfulSync = true; if (intent != null) { try { super.onHandleIntent(intent); int count = syncSettingsServiceHelper.processIntent(); if (count > 0) { ... | SettingsSyncIntentService extends BaseSyncIntentService { protected boolean processSettings(Intent intent) { Timber.d("In Settings Sync Intent Service..."); boolean isSuccessfulSync = true; if (intent != null) { try { super.onHandleIntent(intent); int count = syncSettingsServiceHelper.processIntent(); if (count > 0) { ... |
@Test public void onCreateShouldCreateSyncSettingsServiceHelper() { settingsSyncIntentService = Robolectric.buildIntentService(SettingsSyncIntentService.class) .get(); Assert.assertNull(settingsSyncIntentService.syncSettingsServiceHelper); settingsSyncIntentService.onCreate(); Assert.assertNotNull(settingsSyncIntentSer... | @Override public void onCreate() { super.onCreate(); Context context = CoreLibrary.getInstance().context(); syncSettingsServiceHelper = new SyncSettingsServiceHelper(context.configuration().dristhiBaseURL(), context.getHttpAgent()); } | SettingsSyncIntentService extends BaseSyncIntentService { @Override public void onCreate() { super.onCreate(); Context context = CoreLibrary.getInstance().context(); syncSettingsServiceHelper = new SyncSettingsServiceHelper(context.configuration().dristhiBaseURL(), context.getHttpAgent()); } } | SettingsSyncIntentService extends BaseSyncIntentService { @Override public void onCreate() { super.onCreate(); Context context = CoreLibrary.getInstance().context(); syncSettingsServiceHelper = new SyncSettingsServiceHelper(context.configuration().dristhiBaseURL(), context.getHttpAgent()); } SettingsSyncIntentService()... | SettingsSyncIntentService extends BaseSyncIntentService { @Override public void onCreate() { super.onCreate(); Context context = CoreLibrary.getInstance().context(); syncSettingsServiceHelper = new SyncSettingsServiceHelper(context.configuration().dristhiBaseURL(), context.getHttpAgent()); } SettingsSyncIntentService()... | SettingsSyncIntentService extends BaseSyncIntentService { @Override public void onCreate() { super.onCreate(); Context context = CoreLibrary.getInstance().context(); syncSettingsServiceHelper = new SyncSettingsServiceHelper(context.configuration().dristhiBaseURL(), context.getHttpAgent()); } SettingsSyncIntentService()... |
@Test public void testSyncTasks() { taskServiceHelper.syncTasks(); verify(taskServiceHelper).syncCreatedTaskToServer(); verify(taskServiceHelper).syncTaskStatusToServer(); } | public List<Task> syncTasks() { syncCreatedTaskToServer(); syncTaskStatusToServer(); return fetchTasksFromServer(); } | TaskServiceHelper extends BaseHelper { public List<Task> syncTasks() { syncCreatedTaskToServer(); syncTaskStatusToServer(); return fetchTasksFromServer(); } } | TaskServiceHelper extends BaseHelper { public List<Task> syncTasks() { syncCreatedTaskToServer(); syncTaskStatusToServer(); return fetchTasksFromServer(); } @VisibleForTesting TaskServiceHelper(TaskRepository taskRepository); } | TaskServiceHelper extends BaseHelper { public List<Task> syncTasks() { syncCreatedTaskToServer(); syncTaskStatusToServer(); return fetchTasksFromServer(); } @VisibleForTesting TaskServiceHelper(TaskRepository taskRepository); void setSyncByGroupIdentifier(boolean syncByGroupIdentifier); boolean isSyncByGroupIdentifier... | TaskServiceHelper extends BaseHelper { public List<Task> syncTasks() { syncCreatedTaskToServer(); syncTaskStatusToServer(); return fetchTasksFromServer(); } @VisibleForTesting TaskServiceHelper(TaskRepository taskRepository); void setSyncByGroupIdentifier(boolean syncByGroupIdentifier); boolean isSyncByGroupIdentifier... |
@Test public void testSyncTaskStatusToServer() { TaskUpdate taskUpdate = new TaskUpdate(); taskUpdate.setIdentifier(planId); taskUpdate.setBusinessStatus("Not Visited"); taskUpdate.setStatus("Cancelled"); when(taskRepository.getUnSyncedTaskStatus()).thenReturn(Collections.singletonList(taskUpdate)); Mockito.doReturn(ne... | public void syncTaskStatusToServer() { HTTPAgent httpAgent = getHttpAgent(); List<TaskUpdate> updates = taskRepository.getUnSyncedTaskStatus(); if (!updates.isEmpty()) { String jsonPayload = new Gson().toJson(updates); String baseUrl = CoreLibrary.getInstance().context().configuration().dristhiBaseURL(); Response<Strin... | TaskServiceHelper extends BaseHelper { public void syncTaskStatusToServer() { HTTPAgent httpAgent = getHttpAgent(); List<TaskUpdate> updates = taskRepository.getUnSyncedTaskStatus(); if (!updates.isEmpty()) { String jsonPayload = new Gson().toJson(updates); String baseUrl = CoreLibrary.getInstance().context().configura... | TaskServiceHelper extends BaseHelper { public void syncTaskStatusToServer() { HTTPAgent httpAgent = getHttpAgent(); List<TaskUpdate> updates = taskRepository.getUnSyncedTaskStatus(); if (!updates.isEmpty()) { String jsonPayload = new Gson().toJson(updates); String baseUrl = CoreLibrary.getInstance().context().configura... | TaskServiceHelper extends BaseHelper { public void syncTaskStatusToServer() { HTTPAgent httpAgent = getHttpAgent(); List<TaskUpdate> updates = taskRepository.getUnSyncedTaskStatus(); if (!updates.isEmpty()) { String jsonPayload = new Gson().toJson(updates); String baseUrl = CoreLibrary.getInstance().context().configura... | TaskServiceHelper extends BaseHelper { public void syncTaskStatusToServer() { HTTPAgent httpAgent = getHttpAgent(); List<TaskUpdate> updates = taskRepository.getUnSyncedTaskStatus(); if (!updates.isEmpty()) { String jsonPayload = new Gson().toJson(updates); String baseUrl = CoreLibrary.getInstance().context().configura... |
@Test public void testSynCreatedTaskToServerSuccessfully() { Task expectedTask = TaskServiceHelper.taskGson.fromJson(taskJSon, new TypeToken<Task>() { }.getType()); expectedTask.setSyncStatus(BaseRepository.TYPE_Created); ArrayList tasks = new ArrayList(); tasks.add(expectedTask); String expectedJsonPayload = TaskServi... | public void syncCreatedTaskToServer() { HTTPAgent httpAgent = getHttpAgent(); List<Task> tasks = taskRepository.getAllUnsynchedCreatedTasks(); if (!tasks.isEmpty()) { String jsonPayload = taskGson.toJson(tasks); String baseUrl = CoreLibrary.getInstance().context().configuration().dristhiBaseURL(); Response<String> resp... | TaskServiceHelper extends BaseHelper { public void syncCreatedTaskToServer() { HTTPAgent httpAgent = getHttpAgent(); List<Task> tasks = taskRepository.getAllUnsynchedCreatedTasks(); if (!tasks.isEmpty()) { String jsonPayload = taskGson.toJson(tasks); String baseUrl = CoreLibrary.getInstance().context().configuration().... | TaskServiceHelper extends BaseHelper { public void syncCreatedTaskToServer() { HTTPAgent httpAgent = getHttpAgent(); List<Task> tasks = taskRepository.getAllUnsynchedCreatedTasks(); if (!tasks.isEmpty()) { String jsonPayload = taskGson.toJson(tasks); String baseUrl = CoreLibrary.getInstance().context().configuration().... | TaskServiceHelper extends BaseHelper { public void syncCreatedTaskToServer() { HTTPAgent httpAgent = getHttpAgent(); List<Task> tasks = taskRepository.getAllUnsynchedCreatedTasks(); if (!tasks.isEmpty()) { String jsonPayload = taskGson.toJson(tasks); String baseUrl = CoreLibrary.getInstance().context().configuration().... | TaskServiceHelper extends BaseHelper { public void syncCreatedTaskToServer() { HTTPAgent httpAgent = getHttpAgent(); List<Task> tasks = taskRepository.getAllUnsynchedCreatedTasks(); if (!tasks.isEmpty()) { String jsonPayload = taskGson.toJson(tasks); String baseUrl = CoreLibrary.getInstance().context().configuration().... |
@Test public void testSynCreatedTaskToServerWithFailure() { Task expectedTask = TaskServiceHelper.taskGson.fromJson(taskJSon, new TypeToken<Task>() { }.getType()); expectedTask.setSyncStatus(BaseRepository.TYPE_Created); ArrayList tasks = new ArrayList(); tasks.add(expectedTask); String expectedJsonPayload = TaskServic... | public void syncCreatedTaskToServer() { HTTPAgent httpAgent = getHttpAgent(); List<Task> tasks = taskRepository.getAllUnsynchedCreatedTasks(); if (!tasks.isEmpty()) { String jsonPayload = taskGson.toJson(tasks); String baseUrl = CoreLibrary.getInstance().context().configuration().dristhiBaseURL(); Response<String> resp... | TaskServiceHelper extends BaseHelper { public void syncCreatedTaskToServer() { HTTPAgent httpAgent = getHttpAgent(); List<Task> tasks = taskRepository.getAllUnsynchedCreatedTasks(); if (!tasks.isEmpty()) { String jsonPayload = taskGson.toJson(tasks); String baseUrl = CoreLibrary.getInstance().context().configuration().... | TaskServiceHelper extends BaseHelper { public void syncCreatedTaskToServer() { HTTPAgent httpAgent = getHttpAgent(); List<Task> tasks = taskRepository.getAllUnsynchedCreatedTasks(); if (!tasks.isEmpty()) { String jsonPayload = taskGson.toJson(tasks); String baseUrl = CoreLibrary.getInstance().context().configuration().... | TaskServiceHelper extends BaseHelper { public void syncCreatedTaskToServer() { HTTPAgent httpAgent = getHttpAgent(); List<Task> tasks = taskRepository.getAllUnsynchedCreatedTasks(); if (!tasks.isEmpty()) { String jsonPayload = taskGson.toJson(tasks); String baseUrl = CoreLibrary.getInstance().context().configuration().... | TaskServiceHelper extends BaseHelper { public void syncCreatedTaskToServer() { HTTPAgent httpAgent = getHttpAgent(); List<Task> tasks = taskRepository.getAllUnsynchedCreatedTasks(); if (!tasks.isEmpty()) { String jsonPayload = taskGson.toJson(tasks); String baseUrl = CoreLibrary.getInstance().context().configuration().... |
@Test public void testSynCreatedTaskToServerWithTasksNotProcessedResponse() { Task expectedTask = TaskServiceHelper.taskGson.fromJson(taskJSon, new TypeToken<Task>() { }.getType()); expectedTask.setSyncStatus(BaseRepository.TYPE_Created); ArrayList tasks = new ArrayList(); tasks.add(expectedTask); String expectedJsonPa... | public void syncCreatedTaskToServer() { HTTPAgent httpAgent = getHttpAgent(); List<Task> tasks = taskRepository.getAllUnsynchedCreatedTasks(); if (!tasks.isEmpty()) { String jsonPayload = taskGson.toJson(tasks); String baseUrl = CoreLibrary.getInstance().context().configuration().dristhiBaseURL(); Response<String> resp... | TaskServiceHelper extends BaseHelper { public void syncCreatedTaskToServer() { HTTPAgent httpAgent = getHttpAgent(); List<Task> tasks = taskRepository.getAllUnsynchedCreatedTasks(); if (!tasks.isEmpty()) { String jsonPayload = taskGson.toJson(tasks); String baseUrl = CoreLibrary.getInstance().context().configuration().... | TaskServiceHelper extends BaseHelper { public void syncCreatedTaskToServer() { HTTPAgent httpAgent = getHttpAgent(); List<Task> tasks = taskRepository.getAllUnsynchedCreatedTasks(); if (!tasks.isEmpty()) { String jsonPayload = taskGson.toJson(tasks); String baseUrl = CoreLibrary.getInstance().context().configuration().... | TaskServiceHelper extends BaseHelper { public void syncCreatedTaskToServer() { HTTPAgent httpAgent = getHttpAgent(); List<Task> tasks = taskRepository.getAllUnsynchedCreatedTasks(); if (!tasks.isEmpty()) { String jsonPayload = taskGson.toJson(tasks); String baseUrl = CoreLibrary.getInstance().context().configuration().... | TaskServiceHelper extends BaseHelper { public void syncCreatedTaskToServer() { HTTPAgent httpAgent = getHttpAgent(); List<Task> tasks = taskRepository.getAllUnsynchedCreatedTasks(); if (!tasks.isEmpty()) { String jsonPayload = taskGson.toJson(tasks); String baseUrl = CoreLibrary.getInstance().context().configuration().... |
@Test public void testSyncPlansCallsSendSyncProgressDialog() { Whitebox.setInternalState(planIntentServiceHelper, "totalRecords", 10l); planIntentServiceHelper.syncPlans(); verify(planIntentServiceHelper).sendSyncProgressBroadcast(syncProgressArgumentCaptor.capture(),any()); assertEquals(SyncEntity.PLANS, syncProgressA... | public void syncPlans() { syncProgress = new SyncProgress(); syncProgress.setSyncEntity(SyncEntity.PLANS); syncProgress.setTotalRecords(totalRecords); int batchFetchCount = batchFetchPlansFromServer(true); syncProgress.setPercentageSynced(Utils.calculatePercentage(totalRecords, batchFetchCount)); sendSyncProgressBroadc... | PlanIntentServiceHelper extends BaseHelper { public void syncPlans() { syncProgress = new SyncProgress(); syncProgress.setSyncEntity(SyncEntity.PLANS); syncProgress.setTotalRecords(totalRecords); int batchFetchCount = batchFetchPlansFromServer(true); syncProgress.setPercentageSynced(Utils.calculatePercentage(totalRecor... | PlanIntentServiceHelper extends BaseHelper { public void syncPlans() { syncProgress = new SyncProgress(); syncProgress.setSyncEntity(SyncEntity.PLANS); syncProgress.setTotalRecords(totalRecords); int batchFetchCount = batchFetchPlansFromServer(true); syncProgress.setPercentageSynced(Utils.calculatePercentage(totalRecor... | PlanIntentServiceHelper extends BaseHelper { public void syncPlans() { syncProgress = new SyncProgress(); syncProgress.setSyncEntity(SyncEntity.PLANS); syncProgress.setTotalRecords(totalRecords); int batchFetchCount = batchFetchPlansFromServer(true); syncProgress.setPercentageSynced(Utils.calculatePercentage(totalRecor... | PlanIntentServiceHelper extends BaseHelper { public void syncPlans() { syncProgress = new SyncProgress(); syncProgress.setSyncEntity(SyncEntity.PLANS); syncProgress.setTotalRecords(totalRecords); int batchFetchCount = batchFetchPlansFromServer(true); syncProgress.setPercentageSynced(Utils.calculatePercentage(totalRecor... |
@Test public void testBatchFetchPlansFromServer() { PlanDefinition expectedPlan = PlanIntentServiceHelper.gson.fromJson(planJson, new TypeToken<PlanDefinition>() { }.getType()); ArrayList plans = new ArrayList(); plans.add(expectedPlan); Mockito.doReturn(new Response<>(ResponseStatus.success, PlanIntentServiceHelper.gs... | private int batchFetchPlansFromServer(boolean returnCount) { int batchFetchCount = 0; try { long serverVersion = 0; try { serverVersion = Long.parseLong(allSharedPreferences.getPreference(PLAN_LAST_SYNC_DATE)); } catch (NumberFormatException e) { Timber.e(e, "EXCEPTION %s", e.toString()); } if (serverVersion > 0) { ser... | PlanIntentServiceHelper extends BaseHelper { private int batchFetchPlansFromServer(boolean returnCount) { int batchFetchCount = 0; try { long serverVersion = 0; try { serverVersion = Long.parseLong(allSharedPreferences.getPreference(PLAN_LAST_SYNC_DATE)); } catch (NumberFormatException e) { Timber.e(e, "EXCEPTION %s", ... | PlanIntentServiceHelper extends BaseHelper { private int batchFetchPlansFromServer(boolean returnCount) { int batchFetchCount = 0; try { long serverVersion = 0; try { serverVersion = Long.parseLong(allSharedPreferences.getPreference(PLAN_LAST_SYNC_DATE)); } catch (NumberFormatException e) { Timber.e(e, "EXCEPTION %s", ... | PlanIntentServiceHelper extends BaseHelper { private int batchFetchPlansFromServer(boolean returnCount) { int batchFetchCount = 0; try { long serverVersion = 0; try { serverVersion = Long.parseLong(allSharedPreferences.getPreference(PLAN_LAST_SYNC_DATE)); } catch (NumberFormatException e) { Timber.e(e, "EXCEPTION %s", ... | PlanIntentServiceHelper extends BaseHelper { private int batchFetchPlansFromServer(boolean returnCount) { int batchFetchCount = 0; try { long serverVersion = 0; try { serverVersion = Long.parseLong(allSharedPreferences.getPreference(PLAN_LAST_SYNC_DATE)); } catch (NumberFormatException e) { Timber.e(e, "EXCEPTION %s", ... |
@Test public void getLocalDateTest() { Assert.assertEquals(new LocalDate("2019-10-03"), DateUtil.getLocalDate("03/10/2019")); Assert.assertEquals(null, DateUtil.getLocalDate("03-15-2019")); } | public static LocalDate getLocalDate(String date) { try { SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT, Utils.getDefaultLocale()); Date formattedDate = format.parse(date); return new LocalDate(formattedDate); } catch (Exception e) { return null; } } | DateUtil { public static LocalDate getLocalDate(String date) { try { SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT, Utils.getDefaultLocale()); Date formattedDate = format.parse(date); return new LocalDate(formattedDate); } catch (Exception e) { return null; } } } | DateUtil { public static LocalDate getLocalDate(String date) { try { SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT, Utils.getDefaultLocale()); Date formattedDate = format.parse(date); return new LocalDate(formattedDate); } catch (Exception e) { return null; } } } | DateUtil { public static LocalDate getLocalDate(String date) { try { SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT, Utils.getDefaultLocale()); Date formattedDate = format.parse(date); return new LocalDate(formattedDate); } catch (Exception e) { return null; } } static void fakeIt(LocalDate fakeDay... | DateUtil { public static LocalDate getLocalDate(String date) { try { SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT, Utils.getDefaultLocale()); Date formattedDate = format.parse(date); return new LocalDate(formattedDate); } catch (Exception e) { return null; } } static void fakeIt(LocalDate fakeDay... |
@Test public void testProcessIntent() throws JSONException { AllSettings allSettings = Mockito.spy(CoreLibrary.getInstance().context().allSettings()); ReflectionHelpers.setField(CoreLibrary.getInstance().context(), "allSettings", allSettings); SettingsRepository settingsRepository = ReflectionHelpers.getField(allSettin... | public int processIntent() throws JSONException { try { JSONObject response = pushSettingsToServer(); if (response != null && response.has(AllConstants.INTENT_KEY.VALIDATED_RECORDS)) { JSONArray records = response.getJSONArray(AllConstants.INTENT_KEY.VALIDATED_RECORDS); Setting setting; for (int i = 0; i < records.leng... | SyncSettingsServiceHelper { public int processIntent() throws JSONException { try { JSONObject response = pushSettingsToServer(); if (response != null && response.has(AllConstants.INTENT_KEY.VALIDATED_RECORDS)) { JSONArray records = response.getJSONArray(AllConstants.INTENT_KEY.VALIDATED_RECORDS); Setting setting; for ... | SyncSettingsServiceHelper { public int processIntent() throws JSONException { try { JSONObject response = pushSettingsToServer(); if (response != null && response.has(AllConstants.INTENT_KEY.VALIDATED_RECORDS)) { JSONArray records = response.getJSONArray(AllConstants.INTENT_KEY.VALIDATED_RECORDS); Setting setting; for ... | SyncSettingsServiceHelper { public int processIntent() throws JSONException { try { JSONObject response = pushSettingsToServer(); if (response != null && response.has(AllConstants.INTENT_KEY.VALIDATED_RECORDS)) { JSONArray records = response.getJSONArray(AllConstants.INTENT_KEY.VALIDATED_RECORDS); Setting setting; for ... | SyncSettingsServiceHelper { public int processIntent() throws JSONException { try { JSONObject response = pushSettingsToServer(); if (response != null && response.has(AllConstants.INTENT_KEY.VALIDATED_RECORDS)) { JSONArray records = response.getJSONArray(AllConstants.INTENT_KEY.VALIDATED_RECORDS); Setting setting; for ... |
@Test public void testRemoveLocationsFromHierarchyShouldRemoveLocations() throws Exception { Set<String> locations = new HashSet<>(Arrays.asList("853934ee-d1a6-4b69-9191-59047edbc9a8", "4ed8f536-5c08-4203-8a90-a7e13becb01d")); validateAssignmentHelper.removeLocationsFromHierarchy(locationTree, locations); verify(settin... | @VisibleForTesting protected void removeLocationsFromHierarchy(LocationTree locationTree, Set<String> removedAssignments) throws AuthenticatorException, OperationCanceledException, IOException { for (String removedAssignment : removedAssignments) { locationTree.deleteLocation(removedAssignment); } settingsRepository.sa... | ValidateAssignmentHelper extends BaseHelper { @VisibleForTesting protected void removeLocationsFromHierarchy(LocationTree locationTree, Set<String> removedAssignments) throws AuthenticatorException, OperationCanceledException, IOException { for (String removedAssignment : removedAssignments) { locationTree.deleteLocati... | ValidateAssignmentHelper extends BaseHelper { @VisibleForTesting protected void removeLocationsFromHierarchy(LocationTree locationTree, Set<String> removedAssignments) throws AuthenticatorException, OperationCanceledException, IOException { for (String removedAssignment : removedAssignments) { locationTree.deleteLocati... | ValidateAssignmentHelper extends BaseHelper { @VisibleForTesting protected void removeLocationsFromHierarchy(LocationTree locationTree, Set<String> removedAssignments) throws AuthenticatorException, OperationCanceledException, IOException { for (String removedAssignment : removedAssignments) { locationTree.deleteLocati... | ValidateAssignmentHelper extends BaseHelper { @VisibleForTesting protected void removeLocationsFromHierarchy(LocationTree locationTree, Set<String> removedAssignments) throws AuthenticatorException, OperationCanceledException, IOException { for (String removedAssignment : removedAssignments) { locationTree.deleteLocati... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.