Skip to content

Commit

Permalink
Change use of deprecated GMLibrary.init
Browse files Browse the repository at this point in the history
  • Loading branch information
qiarie committed Nov 15, 2022
1 parent 791f26d commit e5a4eff
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
import org.smartregister.Context;
import org.smartregister.repository.Repository;

Expand All @@ -26,12 +25,12 @@ public class GrowthMonitoringLibraryTest {

@Before
public void setUp() throws Exception {
GrowthMonitoringLibrary.init(Mockito.mock(Context.class), Mockito.mock(Repository.class), 1, 1);
GrowthMonitoringLibrary.init(Mockito.mock(Context.class), Mockito.mock(Repository.class), 1, "1.0.0", 1);
}

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

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void onCreate() {
SyncConfiguration syncConfiguration = Mockito.mock(SyncConfiguration.class);
Mockito.doReturn(SyncFilter.LOCATION).when(syncConfiguration).getEncryptionParam();
CoreLibrary.init(context, syncConfiguration);
GrowthMonitoringLibrary.init(context, repository, 0, 0);
GrowthMonitoringLibrary.init(context, repository, 0, "1.0.0", 0);
setTheme(R.style.Theme_AppCompat);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class EditGrowthDialogFragmentTest extends BaseUnitTest {
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
GrowthMonitoringLibrary.init(context, repository, 0, 0);
GrowthMonitoringLibrary.init(context, repository, 0, "1.0.0", 0);

PowerMockito.mockStatic(GrowthMonitoringLibrary.class);
PowerMockito.when(GrowthMonitoringLibrary.getInstance()).thenReturn(growthMonitoringLibrary);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class GrowthDialogFragmentTest extends BaseUnitTest {
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
GrowthMonitoringLibrary.init(context, repository, 0, 0);
GrowthMonitoringLibrary.init(context, repository, 0, "1.0.0", 0);

PowerMockito.mockStatic(GrowthMonitoringLibrary.class);
PowerMockito.when(GrowthMonitoringLibrary.getInstance()).thenReturn(growthMonitoringLibrary);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class RecordGrowthDialogFragmentTest extends BaseUnitTest {
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
GrowthMonitoringLibrary.init(context, repository, 0, 0);
GrowthMonitoringLibrary.init(context, repository, 0, "1.0.0", 0);

activity = Mockito.spy(Robolectric.buildActivity(FragmentActivity.class).create().get());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import java.util.ArrayList;

import static org.smartregister.util.Log.logError;
import timber.log.Timber;

/**
* Created by keyman on 27/07/2017.
Expand Down Expand Up @@ -50,8 +50,7 @@ public void onCreate() {
GrowthMonitoringConfig config = new GrowthMonitoringConfig();
config.setFemaleWeightZScoreFile("zscores/custom_female_zscore_file.txt");
config.setWeightForHeightZScoreFile("weight_for_height.csv");
GrowthMonitoringLibrary
.init(context, getRepository(), BuildConfig.VERSION_CODE, BuildConfig.DATABASE_VERSION, config);
GrowthMonitoringLibrary.init(context, getRepository(), BuildConfig.VERSION_CODE, BuildConfig.VERSION_NAME, BuildConfig.DATABASE_VERSION, config);

startWeightForHeightIntentService();
startZscoreRefreshService();
Expand All @@ -69,8 +68,7 @@ public Repository getRepository() {
repository = new SampleRepository(getInstance().getApplicationContext(), context);
}
} catch (UnsatisfiedLinkError e) {
logError("Error on getRepository: " + e);

Timber.e(e, "Error on getRepository");
}
return repository;
}
Expand Down

0 comments on commit e5a4eff

Please sign in to comment.