Repository: usergrid
Updated Branches:
  refs/heads/release-2.1.1 b8f502f9d -> d06918562


Update to newer version of GCM server which lets Usergrid directly set the data 
object within the SDK instead of just adding key/value pairs.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/d0691856
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/d0691856
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/d0691856

Branch: refs/heads/release-2.1.1
Commit: d06918562a6e3f76a3ca98d384d1c5ef6beb1c23
Parents: b8f502f
Author: Michael Russo <[email protected]>
Authored: Tue Apr 19 17:37:41 2016 +0100
Committer: Michael Russo <[email protected]>
Committed: Tue Apr 19 17:37:41 2016 +0100

----------------------------------------------------------------------
 stack/pom.xml                                   |  2 +-
 .../services/notifications/gcm/GCMAdapter.java  | 12 +++-----
 .../gcm/NotificationsServiceIT.java             | 32 ++++++++++++++++++++
 3 files changed, 37 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/d0691856/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index f052bf9..a94233e 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -121,7 +121,7 @@
         <antlr.version>3.4</antlr.version>
         <tika.version>1.4</tika.version>
         <mockito.version>1.10.8</mockito.version>
-        <io.apigee.gcm.version>1.0.0</io.apigee.gcm.version>
+        <io.apigee.gcm.version>1.0.1</io.apigee.gcm.version>
 
         <!-- only use half the cores on the machine for testing -->
         <usergrid.it.parallel>methods</usergrid.it.parallel>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d0691856/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
----------------------------------------------------------------------
diff --git 
a/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
 
b/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
index af0bc78..7929ad4 100644
--- 
a/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
+++ 
b/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
@@ -242,14 +242,10 @@ public class GCMAdapter implements ProviderAdapter {
                     payload.remove(priorityKey);
 
                 }
-//
-//                // add our source notification payload data into the Message 
Builder
-//                // Message.Builder requires the payload to be 
Map<String,String> so blindly cast
-//                Map<String,String> dataMap = (Map<String,String>) payload;
-//
-//                dataMap.forEach( (key, value) -> builder.addData(key, 
value));
-
-                builder.addData("data", JSON.toString(payload));
+
+                builder.setData(payload);
+                // GCM will accept Map<String,Object> but 
builder.build().toString() will throw a class cast
+                // exception, but luckily Message.toString() is not used 
anywhere in the GCM SDK or Usergrid
 
                 Message message = builder.build();
                 MulticastResult multicastResult;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d0691856/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 8782fe3..77abb56 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
@@ -167,6 +167,38 @@ public class NotificationsServiceIT extends 
AbstractServiceNotificationIT {
     }
 
     @Test
+    public void singlePushNotificationMapPayload() throws Exception {
+
+        app.clear();
+        Map<String, Object> topLevel = new HashMap<>();
+        Map<String, String> mapPayload = new HashMap<String, String>(){{
+            put("key1", "value1");
+            put("key2", "value2");
+
+        }};
+        topLevel.put("enabler", mapPayload);
+        Map<String, Object> payloads = new HashMap<>(1);
+        payloads.put(notifier.getUuid().toString(), topLevel);
+        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 singlePushNotificationNoReceipts() throws Exception {
 
         app.clear();

Reply via email to