Skip to content

Commit 1b1505a

Browse files
committed
fix(tests): Fix for broken unit tests by renaming method isManifestSetUp to isManifestSetup.
1 parent 3d65b56 commit 1b1505a

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

AndroidSDKTests/src/test/java/com/leanplum/LeanplumCloudMessagingProviderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ public String getRegistrationId() {
102102
}
103103

104104
@Override
105-
public boolean isManifestSetUp() {
105+
public boolean isInitialized() {
106106
return false;
107107
}
108108

109109
@Override
110-
public boolean isInitialized() {
110+
public boolean isManifestSetup() {
111111
return false;
112112
}
113113

AndroidSDKTests/src/test/java/com/leanplum/LeanplumNotificationChannelTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import android.app.NotificationChannelGroup;
2525

2626
import com.leanplum.__setup.AbstractTest;
27+
import com.leanplum.utils.BuildUtil;
2728

2829
import org.json.JSONArray;
2930
import org.junit.Test;
@@ -45,7 +46,8 @@
4546
sdk = 26
4647
)
4748
@PrepareForTest(value = {
48-
LeanplumNotificationChannel.class
49+
LeanplumNotificationChannel.class,
50+
BuildUtil.class
4951
})
5052
/**
5153
* Notifiction channels tests
@@ -62,7 +64,8 @@ public void after() {
6264
public void before() throws Exception {
6365
super.before();
6466
spy(LeanplumNotificationChannel.class);
65-
doReturn(26).when(LeanplumNotificationChannel.class, "getTargetSdkVersion", Matchers.anyObject());
67+
spy(BuildUtil.class);
68+
doReturn(26).when(BuildUtil.class, "getTargetSdkVersion", Matchers.anyObject());
6669
}
6770

6871
@Test

AndroidSDKTests/src/test/java/com/leanplum/LeanplumPushServiceTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@ public void testInitPushService() throws Exception {
140140
when(LeanplumPushService.isFirebaseEnabled()).thenReturn(true);
141141

142142
// Test if Manifest is not set up and provider is initialized.
143-
doReturn(false).when(fcmProviderMock).isManifestSetUp();
143+
doReturn(false).when(fcmProviderMock).isManifestSetup();
144144
doReturn(true).when(fcmProviderMock).isInitialized();
145145
initPushServiceMethod.invoke(pushService);
146146
assertNotNull(initPushServiceMethod);
147147
verifyPrivate(LeanplumPushService.class, times(0)).invoke("registerInBackground");
148148

149149
// Test if Manifest is set up and provider is initialized.
150-
doReturn(true).when(fcmProviderMock).isManifestSetUp();
150+
doReturn(true).when(fcmProviderMock).isManifestSetup();
151151
doReturn(true).when(fcmProviderMock).isInitialized();
152152
initPushServiceMethod.invoke(pushService);
153153
assertNotNull(initPushServiceMethod);
@@ -157,21 +157,21 @@ public void testInitPushService() throws Exception {
157157
when(LeanplumPushService.isFirebaseEnabled()).thenReturn(false);
158158

159159
// Test if Manifest is not set up and provider is initialized.
160-
doReturn(false).when(gcmProviderMock).isManifestSetUp();
160+
doReturn(false).when(gcmProviderMock).isManifestSetup();
161161
doReturn(true).when(gcmProviderMock).isInitialized();
162162
initPushServiceMethod.invoke(pushService);
163163
assertNotNull(initPushServiceMethod);
164164
verifyPrivate(LeanplumPushService.class, times(1)).invoke("registerInBackground");
165165

166166
// Test if Manifest is set up and provider not initialized.
167-
doReturn(true).when(gcmProviderMock).isManifestSetUp();
167+
doReturn(true).when(gcmProviderMock).isManifestSetup();
168168
doReturn(false).when(gcmProviderMock).isInitialized();
169169
initPushServiceMethod.invoke(pushService);
170170
assertNotNull(initPushServiceMethod);
171171
verifyPrivate(LeanplumPushService.class, times(1)).invoke("registerInBackground");
172172

173173
// Test if Manifest is set up and provider is initialized.
174-
doReturn(true).when(gcmProviderMock).isManifestSetUp();
174+
doReturn(true).when(gcmProviderMock).isManifestSetup();
175175
doReturn(true).when(gcmProviderMock).isInitialized();
176176
initPushServiceMethod.invoke(pushService);
177177
assertNotNull(initPushServiceMethod);
@@ -343,14 +343,14 @@ public void testRegister() throws Exception {
343343

344344
LeanplumGcmProvider gcmProviderMock = spy(new LeanplumGcmProvider());
345345
whenNew(LeanplumGcmProvider.class).withNoArguments().thenReturn(gcmProviderMock);
346-
doReturn(true).when(gcmProviderMock).isManifestSetUp();
346+
doReturn(true).when(gcmProviderMock).isManifestSetup();
347347
doReturn(true).when(gcmProviderMock).isInitialized();
348348

349349
LeanplumPushService.onStart();
350350

351351
LeanplumFcmProvider fcmProviderMock = spy(new LeanplumFcmProvider());
352352
whenNew(LeanplumFcmProvider.class).withNoArguments().thenReturn(fcmProviderMock);
353-
doReturn(true).when(fcmProviderMock).isManifestSetUp();
353+
doReturn(true).when(fcmProviderMock).isManifestSetup();
354354
doReturn(true).when(fcmProviderMock).isInitialized();
355355

356356
PowerMockito.doReturn(true).when(LeanplumPushService.class, "isFirebaseEnabled");

0 commit comments

Comments
 (0)