Skip to content

Commit 98348e3

Browse files
committed
Fix tests
1 parent 037782c commit 98348e3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

iterableapi/src/test/java/com/iterable/iterableapi/IterableFirebaseMessagingServiceTest.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,24 @@
1313
import org.junit.Before;
1414
import org.junit.Test;
1515
import org.mockito.ArgumentCaptor;
16+
import org.mockito.Mockito;
1617
import org.powermock.api.mockito.PowerMockito;
1718
import org.powermock.core.MockRepository;
1819
import org.powermock.core.classloader.annotations.PrepareForTest;
1920
import org.robolectric.Robolectric;
2021
import org.robolectric.RuntimeEnvironment;
2122
import org.robolectric.android.controller.ServiceController;
2223

24+
import java.util.HashMap;
25+
import java.util.Map;
26+
2327
import okhttp3.mockwebserver.MockWebServer;
2428

2529
import static com.iterable.iterableapi.unit.IterableTestUtils.bundleToMap;
2630
import static com.iterable.iterableapi.unit.IterableTestUtils.getMapFromJsonResource;
31+
import static junit.framework.Assert.assertEquals;
2732
import static junit.framework.Assert.assertTrue;
33+
import static org.mockito.ArgumentMatchers.any;
2834
import static org.mockito.ArgumentMatchers.eq;
2935
import static org.mockito.Mockito.mock;
3036
import static org.mockito.Mockito.spy;
@@ -72,15 +78,18 @@ public void tearDown() throws Exception {
7278
@Test
7379
public void testOnMessageReceived() throws Exception {
7480
PowerMockito.mockStatic(IterableNotificationBuilder.class);
81+
Mockito.when(IterableNotificationBuilder.isIterablePush(any(Bundle.class))).thenCallRealMethod();
7582

7683
RemoteMessage.Builder builder = new RemoteMessage.Builder("[email protected]");
77-
builder.setData(getMapFromJsonResource("push_payload_custom_action.json"));
84+
builder.addData(IterableConstants.ITERABLE_DATA_KEY, IterableTestUtils.getResourceString("push_payload_custom_action.json"));
7885
controller.get().onMessageReceived(builder.build());
7986

8087
PowerMockito.verifyStatic(IterableNotificationBuilder.class);
8188
ArgumentCaptor<Bundle> bundleCaptor = ArgumentCaptor.forClass(Bundle.class);
8289
IterableNotificationBuilder.createNotification(eq(RuntimeEnvironment.application), bundleCaptor.capture());
83-
assertTrue(bundleToMap(bundleCaptor.getValue()).equals(getMapFromJsonResource("push_payload_custom_action.json")));
90+
Map<String, String> expectedPayload = new HashMap<>();
91+
expectedPayload.put(IterableConstants.ITERABLE_DATA_KEY, IterableTestUtils.getResourceString("push_payload_custom_action.json"));
92+
assertEquals(expectedPayload, bundleToMap(bundleCaptor.getValue()));
8493
}
8594

8695
}

0 commit comments

Comments
 (0)