Skip to content

Commit

Permalink
Fix failing LocationHelperTest
Browse files Browse the repository at this point in the history
  • Loading branch information
ekigamba committed Mar 9, 2023
1 parent 1793807 commit cd2bb0f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion opensrp-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ android {
targetSdkVersion androidTargetSdkVersion
versionCode Integer.parseInt(project.VERSION_CODE)
versionName project.VERSION_NAME
testInstrumentationRunner "android.test.InstrumentationTestRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
buildConfigField "long", "BUILD_TIMESTAMP", System.currentTimeMillis() + "L"
buildConfigField "int", "DB_ENCRYPTION_VERSION", '1'
buildConfigField("int", "VERSION_CODE", "${defaultConfig.versionCode}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ public void testGenerateDefaultLocationHierarchyWithRegisteredANMNotSetReturnsNu
LocationHelper spyLocationHelper = Mockito.spy(locationHelper);
AllSharedPreferences spiedAllSharedPreferences = Mockito.spy((AllSharedPreferences) ReflectionHelpers.getField(spyLocationHelper, "allSharedPreferences"));
ReflectionHelpers.setField(spyLocationHelper, "allSharedPreferences", spiedAllSharedPreferences);
Mockito.doReturn("demo").when(spiedAllSharedPreferences).fetchRegisteredANM();

ANMLocationController anmLocationController = Mockito.spy(CoreLibrary.getInstance().context().anmLocationController());
ReflectionHelpers.setField(CoreLibrary.getInstance().context(), "anmLocationController", anmLocationController);
Expand All @@ -242,7 +243,7 @@ public void testGenerateDefaultLocationHierarchyWithRegisteredANMNotSetReturnsNu
List<String> allowedLevels = Arrays.asList("District", "Village");
List<String> result = spyLocationHelper.generateDefaultLocationHierarchy(allowedLevels);

Mockito.verify(spiedAllSharedPreferences).fetchDefaultLocalityId(Mockito.eq(""));
Mockito.verify(spiedAllSharedPreferences).fetchDefaultLocalityId(Mockito.eq("demo"));
Mockito.verify(spyLocationHelper).getDefaultLocationHierarchy(Mockito.isNull(), Mockito.any(), Mockito.anyList(), Mockito.eq(allowedLevels), Mockito.eq(false));
assertNull(result);
}
Expand Down

0 comments on commit cd2bb0f

Please sign in to comment.