Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qiarie committed Feb 2, 2021
1 parent 5bf7f75 commit 3f8a56f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 31 deletions.
7 changes: 3 additions & 4 deletions opensrp-app/src/main/java/org/smartregister/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.os.Environment;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.text.Html;
import android.text.Spanned;
import android.text.TextUtils;
Expand All @@ -45,6 +43,9 @@
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
Expand Down Expand Up @@ -99,7 +100,6 @@
import timber.log.Timber;

import static android.content.Context.INPUT_METHOD_SERVICE;
import static org.smartregister.util.Log.logError;


/**
Expand Down Expand Up @@ -515,7 +515,6 @@ public static CommonPersonObjectClient convert(CommonPersonObject commonPersonOb
}

public static boolean getBooleanProperty(String key) {

return CoreLibrary.getInstance().context().getAppProperties().isTrue(key);
}

Expand Down
29 changes: 2 additions & 27 deletions opensrp-app/src/test/java/org/smartregister/ContextTest.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package org.smartregister;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.robolectric.util.ReflectionHelpers;
import org.smartregister.repository.AllAlerts;
import org.smartregister.repository.AllReports;
import org.smartregister.repository.AllServicesProvided;
Expand Down Expand Up @@ -54,12 +50,6 @@ public class ContextTest extends BaseUnitTest {

private Context context;

@Mock
private CoreLibrary coreLibrary;

@Mock
private SyncConfiguration syncConfiguration;

@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
Expand Down Expand Up @@ -317,23 +307,8 @@ public void testGetClientFormRepository() {
}

@Test
public void testAllSharedPreferencesCreatesUnencryptedSharedPreferencesWhenEncryptSharedPreferencesSyncConfigurationFlagIsFalse() {
AllSharedPreferences allSharedPreferences = context.allSharedPreferences();
Assert.assertNotNull(allSharedPreferences);
}

@Test
public void testAllSharedPreferencesCreatesEncryptedSharedPreferencesWhenEncryptSharedPreferencesSyncConfigurationFlagIsTrue() {
ReflectionHelpers.setStaticField(CoreLibrary.class, "instance", coreLibrary);
Mockito.when(coreLibrary.getSyncConfiguration()).thenReturn(syncConfiguration);
Mockito.when(syncConfiguration.encryptSharedPreferences()).thenReturn(true);

public void testAllSharedPreferences() {
AllSharedPreferences allSharedPreferences = context.allSharedPreferences();
Assert.assertNotNull(allSharedPreferences);
}

@After
public void tearDown() {
ReflectionHelpers.setStaticField(CoreLibrary.class, "instance", null);
}
}
}

0 comments on commit 3f8a56f

Please sign in to comment.