Skip to content
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

Open
wants to merge 15 commits into
base: optibp_main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
repositories {
google()
mavenCentral()
jcenter()
gradlePluginPortal()
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven{ url 'https://plugins.gradle.org/m2/' }
Expand Down Expand Up @@ -32,7 +32,7 @@ configure(allprojects) { project ->
repositories {
google()
mavenCentral()
jcenter()
gradlePluginPortal()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url 'https://plugins.gradle.org/m2/'}
mavenLocal()
Expand All @@ -47,14 +47,14 @@ allprojects {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
mavenLocal()
mavenCentral()
gradlePluginPortal()
maven { url 'https://jitpack.io' }
maven { url "https://acra.googlecode.com/svn/repository/releases" }
maven { url "https://repo.maven.apache.org/maven2" }
maven { url "https://cloudant.github.io/cloudant-sync-eap/repository" }
maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
//maven { url "https://dl.bintray.com/ibm-watson-health/ibm-fhir-server-releases" }
google()
jcenter()
}

subprojects {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion opensrp-anc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ dependencies {
exclude group: 'org.yaml', module: 'snakeyaml'
exclude group: 'io.ona.rdt-capture', module: 'lib'
}
implementation('org.smartregister:opensrp-client-core:6.0.0-BETA3-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-core:6.0.0-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.github.bmelnychuk', module: 'atv'
exclude group: 'com.google.guava', module: 'guava'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,4 @@ public void getCurrentContactStateTest() {


}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public void setUp() {
//This test is already covered in Login Interactor
@Ignore
@Test
@Ignore
public void testIsUserLoggedOutShouldReturnTrue() {
Assert.assertTrue(model.isUserLoggedOut());
}
Expand All @@ -55,6 +56,7 @@ public void testIsPasswordValidShouldTrueWhenPasswordValidatesCorrectly() {
}

@Test
@Ignore
public void testIsPasswordValidShouldFalseWhenPasswordValidationFails() {
boolean result = model.isPasswordValid("".toCharArray());
Assert.assertFalse(result);
Expand Down
3 changes: 1 addition & 2 deletions reference-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ dependencies {
exclude group: 'org.yaml', module: 'snakeyaml'
exclude group: 'io.ona.rdt-capture', module: 'lib'
}

implementation('org.smartregister:opensrp-client-core:6.0.0-BETA3-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-core:6.0.0-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.github.bmelnychuk', module: 'atv'
exclude group: 'com.google.guava', module: 'guava'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ public int getSyncMaxRetries() {

@Override
public SyncFilter getSyncFilterParam() {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the test

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
Expand Down Expand Up @@ -57,7 +62,14 @@ public String getExtraStringSettingsParameters() {
public String getSyncFilterValue() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update or add tests for this method

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Expand All @@ -82,7 +94,13 @@ public boolean isSyncSettings() {

@Override
public SyncFilter getEncryptionParam() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add tests for this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Expand Down
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);


}
}