Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add event for remote and local notifications (close #478)
- Loading branch information
Showing
6 changed files
with
426 additions
and
1 deletion.
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
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
55 changes: 55 additions & 0 deletions
55
...er/src/androidTest/java/com/snowplowanalytics/snowplow/event/MessageNotificationTest.java
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.snowplowanalytics.snowplow.event; | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class MessageNotificationTest { | ||
|
||
@Test | ||
public void testExpectedForm() { | ||
MessageNotification event = new MessageNotification("title", "body", MessageNotificationTrigger.push) | ||
.notificationTimestamp("2020-12-31T15:59:60-08:00") | ||
.action("action") | ||
.bodyLocKey("loc key") | ||
.bodyLocArgs(Arrays.asList("loc arg1", "loc arg2")) | ||
.sound("chime.mp3") | ||
.notificationCount(9) | ||
.category("category1") | ||
.attachments(Arrays.asList(new MessageNotificationAttachment("id", "type", "url"))); | ||
|
||
Map<String, Object> payload = event.getDataPayload(); | ||
assertNotNull(payload); | ||
assertEquals("title", payload.get(MessageNotification.PARAM_MESSAGENOTIFICATION_TITLE)); | ||
assertEquals("body", payload.get(MessageNotification.PARAM_MESSAGENOTIFICATION_BODY)); | ||
assertEquals("push", payload.get(MessageNotification.PARAM_MESSAGENOTIFICATION_TRIGGER)); | ||
assertEquals("2020-12-31T15:59:60-08:00", payload.get(MessageNotification.PARAM_MESSAGENOTIFICATION_NOTIFICATIONTIMESTAMP)); | ||
assertEquals("action", payload.get(MessageNotification.PARAM_MESSAGENOTIFICATION_ACTION)); | ||
assertEquals("loc key", payload.get(MessageNotification.PARAM_MESSAGENOTIFICATION_BODYLOCKEY)); | ||
List<String> locArgs = (List<String>)payload.get(MessageNotification.PARAM_MESSAGENOTIFICATION_BODYLOCARGS); | ||
assertNotNull(locArgs); | ||
assertEquals(2, locArgs.size()); | ||
assertEquals("loc arg1", locArgs.get(0)); | ||
assertEquals("loc arg2", locArgs.get(1)); | ||
assertEquals("chime.mp3", payload.get(MessageNotification.PARAM_MESSAGENOTIFICATION_SOUND)); | ||
assertEquals(9, payload.get(MessageNotification.PARAM_MESSAGENOTIFICATION_NOTIFICATIONCOUNT)); | ||
assertEquals("category1", payload.get(MessageNotification.PARAM_MESSAGENOTIFICATION_CATEGORY)); | ||
List<MessageNotificationAttachment> attachments = (List<MessageNotificationAttachment>)payload.get(MessageNotification.PARAM_MESSAGENOTIFICATION_MESSAGENOTIFICATIONATTACHMENTS); | ||
assertNotNull(attachments); | ||
assertEquals(1, attachments.size()); | ||
MessageNotificationAttachment attachment = attachments.get(0); | ||
assertEquals("id", attachment.get(MessageNotificationAttachment.PARAM_MESSAGENOTIFICATIONATTACHMENT_IDENTIFIER)); | ||
assertEquals("type", attachment.get(MessageNotificationAttachment.PARAM_MESSAGENOTIFICATIONATTACHMENT_TYPE)); | ||
assertEquals("url", attachment.get(MessageNotificationAttachment.PARAM_MESSAGENOTIFICATIONATTACHMENT_URL)); | ||
} | ||
} |
Oops, something went wrong.