-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optibp master merge #916
base: optibp_main
Are you sure you want to change the base?
Optibp master merge #916
Changes from all commits
3291263
646e553
647ca20
9ce6fbe
c9abcc7
e71b751
9891ded
af16eae
8772243
b4682e7
78632b6
7f79a31
1f2aa07
689fbe9
fd8e380
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ POM_SETTING_LICENCE_NAME=The Apache Software License, Version 2.0 | |
android.useAndroidX=true | ||
android.enableJetifier=true | ||
android.debug.obsoleteApi=true | ||
VERSION_NAME=2.1.0-SNAPSHOT | ||
VERSION_NAME=3.0.0-SNAPSHOT | ||
GROUP=org.smartregister | ||
POM_SETTING_DESCRIPTION=OpenSRP Client ANC Library | ||
POM_SETTING_SCM_CONNECTION=scm\:[email protected]\:OpenSRP/opensrp-client-anc.git | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -245,4 +245,4 @@ public void getCurrentContactStateTest() { | |
|
||
|
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,12 @@ public int getSyncMaxRetries() { | |
|
||
@Override | ||
public SyncFilter getSyncFilterParam() { | ||
return SyncFilter.TEAM_ID; | ||
if(BuildConfig.SYNC_TYPE.equals(SyncFilter.LOCATION_ID.value())) | ||
return SyncFilter.LOCATION_ID; | ||
else if(BuildConfig.SYNC_TYPE.equals(SyncFilter.TEAM_ID.value())) | ||
return SyncFilter.TEAM_ID; | ||
else | ||
return SyncFilter.PROVIDER; | ||
} | ||
|
||
@Override | ||
|
@@ -57,7 +62,14 @@ public String getExtraStringSettingsParameters() { | |
public String getSyncFilterValue() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update or add tests for this method There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added the test |
||
AllSharedPreferences sharedPreferences = | ||
AncLibrary.getInstance().getContext().userService().getAllSharedPreferences(); | ||
return sharedPreferences.fetchDefaultTeamId(sharedPreferences.fetchRegisteredANM()); | ||
|
||
if(BuildConfig.SYNC_TYPE.equals(SyncFilter.LOCATION_ID.value())) | ||
return sharedPreferences.fetchDefaultLocalityId(sharedPreferences.fetchRegisteredANM()); | ||
else if(BuildConfig.SYNC_TYPE.equals(SyncFilter.TEAM_ID.value())) | ||
return sharedPreferences.fetchDefaultTeamId(sharedPreferences.fetchRegisteredANM()); | ||
else | ||
return sharedPreferences.fetchRegisteredANM(); | ||
|
||
} | ||
|
||
@Override | ||
|
@@ -82,7 +94,13 @@ public boolean isSyncSettings() { | |
|
||
@Override | ||
public SyncFilter getEncryptionParam() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add tests for this method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added the test |
||
return SyncFilter.TEAM; | ||
if(BuildConfig.SYNC_TYPE.equals(SyncFilter.LOCATION_ID.value())) | ||
return SyncFilter.LOCATION; | ||
else if(BuildConfig.SYNC_TYPE.equals(SyncFilter.TEAM_ID.value())) | ||
return SyncFilter.TEAM; | ||
else | ||
return SyncFilter.PROVIDER; | ||
|
||
} | ||
|
||
@Override | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package org.smartregister.anc.application; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.ArgumentMatchers; | ||
import org.mockito.Mock; | ||
import org.powermock.api.mockito.PowerMockito; | ||
import org.powermock.core.classloader.annotations.PrepareForTest; | ||
import org.powermock.modules.junit4.PowerMockRunner; | ||
import org.smartregister.Context; | ||
import org.smartregister.SyncFilter; | ||
import org.smartregister.anc.BaseUnitTest; | ||
import org.smartregister.anc.BuildConfig; | ||
import org.smartregister.anc.library.AncLibrary; | ||
import org.smartregister.anc.library.util.Utils; | ||
import org.smartregister.repository.AllSharedPreferences; | ||
import org.smartregister.service.UserService; | ||
|
||
|
||
@RunWith(PowerMockRunner.class) | ||
@PrepareForTest({Utils.class, AncLibrary.class}) | ||
public class ANCSyncConfigurationTest extends BaseUnitTest { | ||
@Mock | ||
AllSharedPreferences allSharedPreferences; | ||
@Mock | ||
AncLibrary ancLibrary; | ||
@Mock | ||
Context context; | ||
@Mock | ||
UserService userService; | ||
AncSyncConfiguration configuration = new AncSyncConfiguration(); | ||
|
||
@Before | ||
public void setup() throws Exception { | ||
PowerMockito.mockStatic(AncLibrary.class); | ||
PowerMockito.when(AncLibrary.getInstance()).thenReturn(ancLibrary); | ||
PowerMockito.when(ancLibrary.getContext()).thenReturn(context); | ||
PowerMockito.when(context, "userService").thenReturn(userService); | ||
PowerMockito.when(userService.getAllSharedPreferences()).thenReturn(allSharedPreferences); | ||
|
||
} | ||
|
||
@Test | ||
public void testGetFilterParamTest() | ||
{ | ||
SyncFilter filter = configuration.getEncryptionParam(); | ||
Assert.assertEquals(filter,SyncFilter.TEAM); | ||
if(BuildConfig.SYNC_TYPE.equals(SyncFilter.LOCATION_ID.value())) | ||
Assert.assertEquals(filter, SyncFilter.LOCATION); | ||
else if(BuildConfig.SYNC_TYPE.equals(SyncFilter.TEAM_ID.value())) | ||
Assert.assertEquals(filter,SyncFilter.TEAM); | ||
else | ||
Assert.assertEquals(filter,SyncFilter.PROVIDER); | ||
} | ||
|
||
@Test | ||
public void getSyncFilterValueTest() | ||
{ | ||
String defaultLocID = "defaultLocalityId"; | ||
String testUser = "testUser"; | ||
String defaultTeamId = "defaultTeamId"; | ||
String anm = "ANM"; | ||
PowerMockito.when(allSharedPreferences.getANMPreferredName(ArgumentMatchers.anyString())).thenReturn(testUser); | ||
PowerMockito.when(allSharedPreferences.fetchDefaultLocalityId(ArgumentMatchers.anyString())).thenReturn(defaultLocID); | ||
PowerMockito.when(allSharedPreferences.fetchDefaultTeamId(ArgumentMatchers.anyString())).thenReturn("defaultTeamId"); | ||
PowerMockito.when(allSharedPreferences.fetchRegisteredANM()).thenReturn(anm); | ||
String syncValue = configuration.getSyncFilterValue(); | ||
|
||
if(BuildConfig.SYNC_TYPE.equals(SyncFilter.LOCATION_ID.value())) | ||
Assert.assertEquals(syncValue, defaultLocID); | ||
else if(BuildConfig.SYNC_TYPE.equals(SyncFilter.TEAM_ID.value())) | ||
Assert.assertEquals(syncValue,defaultTeamId); | ||
else | ||
Assert.assertEquals(syncValue,anm); | ||
|
||
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the tests for this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added the test