-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #498 from opensrp/issue/support/30-duplicate-zeir-ids
- Loading branch information
Showing
11 changed files
with
159 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,17 +2,30 @@ | |
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import android.content.Context; | ||
import android.util.Log; | ||
|
||
import androidx.work.Configuration; | ||
import androidx.work.WorkInfo; | ||
import androidx.work.WorkManager; | ||
import androidx.work.impl.utils.SynchronousExecutor; | ||
import androidx.work.testing.WorkManagerTestInitHelper; | ||
|
||
import com.google.common.util.concurrent.ListenableFuture; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
import org.robolectric.RuntimeEnvironment; | ||
import org.smartregister.giz.BaseRobolectricTest; | ||
import org.smartregister.giz.shadow.ShadowBaseJob; | ||
import org.smartregister.growthmonitoring.job.HeightIntentServiceJob; | ||
import org.smartregister.growthmonitoring.job.WeightIntentServiceJob; | ||
import org.smartregister.growthmonitoring.job.ZScoreRefreshIntentServiceJob; | ||
import org.smartregister.immunization.job.RecurringServiceJob; | ||
import org.smartregister.immunization.job.VaccineServiceJob; | ||
import org.smartregister.job.DuplicateZeirIdsCleanerWorker; | ||
import org.smartregister.job.ImageUploadServiceJob; | ||
import org.smartregister.job.PullUniqueIdsServiceJob; | ||
import org.smartregister.job.SyncServiceJob; | ||
|
@@ -21,6 +34,8 @@ | |
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
/** | ||
* Created by Ephraim Kigamba - [email protected] on 05-03-2020. | ||
|
@@ -31,7 +46,8 @@ public class LoginInteractorTest extends BaseRobolectricTest { | |
|
||
@Before | ||
public void setUp() throws Exception { | ||
loginInteractor = new LoginInteractor(Mockito.mock(BaseLoginContract.Presenter.class)); | ||
loginInteractor = Mockito.spy(new LoginInteractor(Mockito.mock(BaseLoginContract.Presenter.class))); | ||
Mockito.doReturn((Context) RuntimeEnvironment.application).when(loginInteractor).getApplicationContext(); | ||
} | ||
|
||
@Test | ||
|
@@ -53,7 +69,9 @@ public void scheduleJobsPeriodically() { | |
} | ||
|
||
@Test | ||
public void scheduleJobsImmediatelyShouldCallEachJobToScheduleImmediateExecution() { | ||
public void scheduleJobsImmediatelyShouldCallEachJobToScheduleImmediateExecution() throws ExecutionException, InterruptedException { | ||
initializeWorkManager(); | ||
|
||
loginInteractor.scheduleJobsImmediately(); | ||
|
||
Assert.assertTrue(ShadowBaseJob.getShadowHelper().isCalled(ShadowBaseJob.scheduleJobImmediatelyMN)); | ||
|
@@ -65,5 +83,22 @@ public void scheduleJobsImmediatelyShouldCallEachJobToScheduleImmediateExecution | |
assertEquals(ZScoreRefreshIntentServiceJob.TAG, methodCalls.get(3).get(0)); | ||
assertEquals(ImageUploadServiceJob.TAG, methodCalls.get(4).get(0)); | ||
ShadowBaseJob.getShadowHelper().getMethodCalls().clear(); | ||
|
||
ListenableFuture<List<WorkInfo>> listenableFuture = WorkManager.getInstance(RuntimeEnvironment.application) | ||
.getWorkInfosForUniqueWork(DuplicateZeirIdsCleanerWorker.TAG); | ||
|
||
assertEquals(1, listenableFuture.get().size()); | ||
} | ||
|
||
|
||
private void initializeWorkManager() { | ||
Configuration config = new Configuration.Builder() | ||
.setMinimumLoggingLevel(Log.DEBUG) | ||
.setExecutor(new SynchronousExecutor()) | ||
.build(); | ||
|
||
// Initialize WorkManager for instrumentation tests. | ||
WorkManagerTestInitHelper.initializeTestWorkManager( | ||
RuntimeEnvironment.application, config); | ||
} | ||
} |
Oops, something went wrong.