Default the priority to "normal" in the entity and add additional test for payloads containing nested json.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/58921182 Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/58921182 Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/58921182 Branch: refs/heads/master Commit: 58921182f19c3315ae5a62c8c5da108ad01db36e Parents: ea7e895 Author: Michael Russo <[email protected]> Authored: Thu Jan 7 08:15:10 2016 -0800 Committer: Michael Russo <[email protected]> Committed: Thu Jan 7 08:15:10 2016 -0800 ---------------------------------------------------------------------- .../persistence/entities/Notification.java | 3 +- .../gcm/NotificationsServiceIT.java | 30 +++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/usergrid/blob/58921182/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java ---------------------------------------------------------------------- diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java index f10e0c2..e87b045 100644 --- a/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java +++ b/stack/core/src/main/java/org/apache/usergrid/persistence/entities/Notification.java @@ -180,7 +180,8 @@ public class Notification extends TypedEntity { @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) public String getPriority() { - return priority; + // default the priority to normal if not provided + return priority != null ? priority : "normal"; } public void setPriority(String priority) { http://git-wip-us.apache.org/repos/asf/usergrid/blob/58921182/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java ---------------------------------------------------------------------- diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java index 52a3541..08facf3 100644 --- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java +++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java @@ -39,10 +39,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT { private static final Logger logger = LoggerFactory .getLogger(NotificationsServiceIT.class); - /** - * set to true to run tests against actual GCM servers - but they may not - * all run correctly - */ + /** set to true to use actual connections to GCM servers */ private static final boolean USE_REAL_CONNECTIONS = true; private static final String PROVIDER = USE_REAL_CONNECTIONS ? "google" : "noop"; @@ -224,6 +221,31 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT { } @Test + public void singlePushNotificationWithMapPayload() throws Exception { + + app.clear(); + String payload = "{\"message\":\"Hello, World!\", \"campaign\":\"Hello Campaign\"}"; + Map<String, String> payloads = new HashMap<String, String>(1); + payloads.put(notifier.getUuid().toString(), payload); + app.put("payloads", payloads); + app.put("queued", System.currentTimeMillis()); + app.put("debug",true); + app.put("expire", System.currentTimeMillis() + 300000); // add 5 minutes to current time + + Entity e = app.testRequest(ServiceAction.POST, 1, "devices",device1.getUuid(),"notifications").getEntity(); + app.testRequest(ServiceAction.GET, 1, "notifications", e.getUuid()); + + Notification notification = app.getEntityManager().get(e.getUuid(), Notification.class); + assertEquals( + notification.getPayloads().get(notifier.getUuid().toString()), + payload); + + // perform push // + notification = notificationWaitForComplete(notification); + checkReceipts(notification, 1); + } + + @Test public void singlePushNotificationMultipleDevices() throws Exception { app.clear();
