Skip to content

Commit 63adabf

Browse files
committed
Fix failing tests
1 parent 17fb2dc commit 63adabf

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

opensrp-app/src/main/java/org/smartregister/login/task/RemoteLoginTask.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.smartregister.view.contract.BaseLoginContract;
2929

3030
import java.util.Arrays;
31+
import java.util.Collections;
3132
import java.util.Locale;
3233

3334
import timber.log.Timber;
@@ -117,7 +118,7 @@ protected LoginResponse doInBackground(Void... params) {
117118
mAccountManager.setUserData(account, AccountHelper.INTENT_KEY.ACCOUNT_LOCAL_PASSWORD_SALT, userData.getString(AccountHelper.INTENT_KEY.ACCOUNT_LOCAL_PASSWORD_SALT));
118119
mAccountManager.setUserData(account, AccountHelper.INTENT_KEY.ACCOUNT_NAME, userData.getString(AccountHelper.INTENT_KEY.ACCOUNT_NAME));
119120
mAccountManager.setUserData(account, AccountHelper.INTENT_KEY.ACCOUNT_REFRESH_TOKEN, response.getRefreshToken());
120-
mAccountManager.setUserData(account,AccountHelper.INTENT_KEY.ACCOUNT_ROLES,user.getRoles().toString());
121+
mAccountManager.setUserData(account, AccountHelper.INTENT_KEY.ACCOUNT_ROLES, user.getRoles() != null ? user.getRoles().toString() : Collections.EMPTY_LIST.toString());
121122
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
122123
mAccountManager.notifyAccountAuthenticated(account);
123124
}

opensrp-app/src/test/java/org/smartregister/login/interactor/BaseLoginInteractorTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public void setUp() {
163163
when(view.getActivityContext()).thenReturn(activity);
164164

165165
loginResponseData = new LoginResponseData();
166-
loginResponseData.user = new User().withUsername(username);
166+
loginResponseData.user = new User().withUsername(username).withRole("READ_ROLE").withRole("WRITE_ROLE").withRole("PROVIDER_ROLE");
167167
loginResponseData.time = new Time(new Date(), TimeZone.getTimeZone("Africa/Nairobi"));
168168

169169
when(context.getHttpAgent()).thenReturn(httpAgent);

opensrp-app/src/test/java/org/smartregister/sync/intent/SyncIntentServiceTest.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import static org.junit.Assert.assertEquals;
4242
import static org.junit.Assert.assertNotNull;
4343
import static org.junit.Assert.assertNull;
44+
import static org.junit.Assert.assertTrue;
4445
import static org.mockito.Mockito.spy;
4546
import static org.mockito.Mockito.times;
4647
import static org.mockito.Mockito.verify;
@@ -493,14 +494,15 @@ public void testGetUrlResponseCreatesValidUrlWithExtraParamsUsingGET() {
493494
responseStatus.setDisplayValue(ResponseErrorStatus.malformed_url.name());
494495
Mockito.doReturn(new Response<>(responseStatus, null))
495496
.when(httpAgent).fetch(stringArgumentCaptor.capture());
496-
497+
String removeParamKey = "some-other-param-to-remove";
497498
BaseSyncIntentService.RequestParamsBuilder builder = new BaseSyncIntentService.RequestParamsBuilder().configureSyncFilter("locationId", "location-1")
498-
.addServerVersion(0).addEventPullLimit(250).addParam("region", "au-west").addParam("is_enabled", true).addParam("some-other-param", 85l);
499+
.addServerVersion(0).addEventPullLimit(250).addParam("region", "au-west").addParam("is_enabled", true).addParam("some-other-param", 85l)
500+
.addParam(removeParamKey, 745).removeParam(removeParamKey);
499501
syncIntentService.getUrlResponse("https://sample-stage.smartregister.org/opensrp/rest/event/sync", builder, syncConfiguration, false);
500502

501503
String syncUrl = stringArgumentCaptor.getValue();
502504
assertEquals("https://sample-stage.smartregister.org/opensrp/rest/event/sync?locationId=location-1&serverVersion=0&limit=250&region=au-west&is_enabled=true&some-other-param=85", syncUrl);
503-
505+
assertTrue(syncIntentService.isEmptyToAdd());
504506
}
505507

506508
@Test

0 commit comments

Comments
 (0)