Skip to content

Commit 84c4a5a

Browse files
committed
Add tests for isGhostPush
1 parent 044df14 commit 84c4a5a

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import android.content.Intent;
44
import android.os.Bundle;
55

6-
import com.google.firebase.iid.FirebaseInstanceId;
76
import com.google.firebase.messaging.RemoteMessage;
87

98
import org.junit.After;
@@ -21,6 +20,8 @@
2120

2221
import static com.iterable.iterableapi.IterableTestUtils.bundleToMap;
2322
import static junit.framework.Assert.assertEquals;
23+
import static junit.framework.TestCase.assertFalse;
24+
import static junit.framework.TestCase.assertTrue;
2425
import static org.mockito.ArgumentMatchers.any;
2526
import static org.mockito.ArgumentMatchers.eq;
2627
import static org.mockito.Mockito.doNothing;
@@ -112,4 +113,20 @@ public void testSilentPushInAppRemoved() throws Exception {
112113
verify(inAppManagerSpy).removeMessage("1234567890abcdef");
113114
}
114115

116+
@Test
117+
public void testIsGhostPushWithGhostPushMessage() throws Exception {
118+
RemoteMessage.Builder builder = new RemoteMessage.Builder("[email protected]");
119+
builder.setData(IterableTestUtils.getMapFromJsonResource("push_payload_ghost_push.json"));
120+
assertTrue(IterableFirebaseMessagingService.isGhostPush(builder.build()));
121+
verify(notificationHelperSpy).isGhostPush(any(Bundle.class));
122+
}
123+
124+
@Test
125+
public void testIsGhostPushWithNotificationMessage() throws Exception {
126+
RemoteMessage.Builder builder = new RemoteMessage.Builder("[email protected]");
127+
builder.setData(IterableTestUtils.getMapFromJsonResource("push_payload_legacy_deep_link.json"));
128+
assertFalse(IterableFirebaseMessagingService.isGhostPush(builder.build()));
129+
verify(notificationHelperSpy).isGhostPush(any(Bundle.class));
130+
}
131+
115132
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"itbl": {
3+
"campaignId": 1234,
4+
"templateId": 4321,
5+
"messageId": "123456789abcdef",
6+
"isGhostPush": true
7+
}
8+
}

0 commit comments

Comments
 (0)