usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject git commit: moving mock query and changing entity ref
Date Wed, 10 Sep 2014 21:16:47 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o f0eda9f65 -> 0a9c9540d


moving mock query and changing entity ref


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

Branch: refs/heads/two-dot-o
Commit: 0a9c9540d2d0513d793126ce07cd12f424ccbc6a
Parents: f0eda9f
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Wed Sep 10 15:16:32 2014 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Wed Sep 10 15:16:32 2014 -0600

----------------------------------------------------------------------
 .../main/java/org/apache/usergrid/persistence/PathQuery.java | 8 +++++++-
 .../services/notifications/ApplicationQueueManager.java      | 5 ++---
 .../services/notifications/NotificationsService.java         | 5 +++--
 .../services/notifications/apns/NotificationsServiceIT.java  | 6 +++---
 .../services/notifications/gcm/NotificationsServiceIT.java   | 8 ++++----
 5 files changed, 19 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0a9c9540/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java b/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java
index 6d252fd..6a49f39 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/PathQuery.java
@@ -17,6 +17,7 @@
 package org.apache.usergrid.persistence;
 
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import org.apache.usergrid.persistence.index.query.Query;
 import java.util.Iterator;
 import java.util.UUID;
@@ -26,6 +27,7 @@ import org.apache.usergrid.persistence.index.query.Query.Level;
 
 public class PathQuery<E> {
 
+    private  EntityRef head;
     private PathQuery source;
     private Query query;
     private UUID uuid;
@@ -44,6 +46,7 @@ public class PathQuery<E> {
     public PathQuery( EntityRef head ) {
         this.uuid = head.getUuid();
         this.type = head.getType();
+        this.head = head;
         this.query = null;
     }
 
@@ -60,6 +63,7 @@ public class PathQuery<E> {
         }
         this.uuid = head.getUuid();
         this.type = head.getType();
+        this.head = head;
         this.query = query;
     }
 
@@ -100,7 +104,7 @@ public class PathQuery<E> {
 
 
     protected Results getHeadResults( EntityManager em ) throws Exception {
-        EntityRef ref = new SimpleEntityRef(type,uuid);
+        EntityRef ref = head != null ? head : new SimpleEntityRef(type,uuid);
         return ( query.getCollection() != null ) ? 
                em.searchCollection( ref, query.getCollection(), query ) :
                em.searchConnectedEntities( ref, query );
@@ -127,6 +131,8 @@ public class PathQuery<E> {
     }
 
 
+
+
     public String getType(){return type;}
 
     public UUID getUuid(){return uuid;}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0a9c9540/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
index 4197610..4d2eccb 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/ApplicationQueueManager.java
@@ -58,8 +58,7 @@ public class ApplicationQueueManager implements QueueManager {
     public static final long MESSAGE_TRANSACTION_TIMEOUT =  5 * 60 * 1000;
     private static final Logger LOG = LoggerFactory.getLogger(ApplicationQueueManager.class);
 
-    //need a mocking framework, this is to substitute for no mocking
-    public static PathQuery<Device> TEST_PATH_QUERY = null;
+
 
     //this is for tests, will not mark initial post complete, set to false for tests
     private final Meter sendMeter;
@@ -139,7 +138,7 @@ public class ApplicationQueueManager implements QueueManager {
 
         long startTime = System.currentTimeMillis();
         LOG.info("notification {} start queuing", notification.getUuid());
-        final PathQuery<Device> pathQuery = TEST_PATH_QUERY == null ? notification.getPathQuery()
: TEST_PATH_QUERY; //devices query
+        final PathQuery<Device> pathQuery = notification.getPathQuery() ; //devices
query
         final AtomicInteger deviceCount = new AtomicInteger(); //count devices so you can
make a judgement on batching
         final ConcurrentLinkedQueue<String> errorMessages = new ConcurrentLinkedQueue<String>();
//build up list of issues
         final HashMap<Object,Notifier> notifierMap =  getNotifierMap();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0a9c9540/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
index 5a64cbc..17e3d15 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/NotificationsService.java
@@ -56,7 +56,8 @@ public class NotificationsService extends AbstractCollectionService {
 
     private static final int PAGE = 100;
     private static final Logger LOG = LoggerFactory.getLogger(NotificationsService.class);
-
+    //need a mocking framework, this is to substitute for no mocking
+    public static PathQuery<Device> TEST_PATH_QUERY = null;
 
     public static final String NOTIFIER_ID_POSTFIX = ".notifier.id";
 
@@ -133,7 +134,7 @@ public class NotificationsService extends AbstractCollectionService {
         postMeter.mark();
         try {
             validate(null, context.getPayload());
-            PathQuery<Device> pathQuery = getPathQuery(context.getRequest().getOriginalParameters());
+            PathQuery<Device> pathQuery = TEST_PATH_QUERY != null ? TEST_PATH_QUERY
: getPathQuery(context.getRequest().getOriginalParameters());
             context.getProperties().put("state", Notification.State.CREATED);
             context.getProperties().put("pathQuery", pathQuery);
             context.setOwner(sm.getApplication());

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0a9c9540/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
index bf32e61..bbd0b52 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
@@ -126,7 +126,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT
{
         query.setResultsLevel(Query.Level.ALL_PROPERTIES);
         PathQuery pathQuery = new PathQuery( new SimpleEntityRef(app.getEm().getApplicationRef()),
query);
 
-        ns.getQueueManager().TEST_PATH_QUERY = pathQuery;
+        ns.TEST_PATH_QUERY = pathQuery;
 
         ApplicationQueueManager.QUEUE_NAME = "notifications/test/" + UUID.randomUUID().toString();
         listener = new QueueListener(ns.getServiceManagerFactory(),ns.getEntityManagerFactory(),ns.getMetricsFactory(),
new Properties());
@@ -155,7 +155,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT
{
         pQuery.setCollection("devices");
         pQuery.setResultsLevel(Query.Level.ALL_PROPERTIES);
         pQuery.addIdentifier(new ServiceParameter.NameParameter(device1.getUuid().toString()).getIdentifier());
-        ns.getQueueManager().TEST_PATH_QUERY =  new PathQuery( new SimpleEntityRef(app.getEm().getApplicationRef()),
pQuery);
+        ns.TEST_PATH_QUERY =  new PathQuery( new SimpleEntityRef(app.getEm().getApplicationRef()),
pQuery);
 
         // create a "hellow world" notification
         String payload = getPayload();
@@ -246,7 +246,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT
{
         pQuery.setCollection("devices");
         pQuery.setResultsLevel(Query.Level.ALL_PROPERTIES);
         pQuery.addIdentifier(new ServiceParameter.NameParameter("1234").getIdentifier());
-        ns.getQueueManager().TEST_PATH_QUERY =   new PathQuery( new SimpleEntityRef(app.getEm().getApplicationRef()),
pQuery);
+        ns.TEST_PATH_QUERY =   new PathQuery( new SimpleEntityRef(app.getEm().getApplicationRef()),
pQuery);
         e = app.testRequest(ServiceAction.POST, 1, "notifications").getEntity();
         app.testRequest(ServiceAction.GET, 1, "notifications", e.getUuid());
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0a9c9540/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 002dce4..3db763c 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
@@ -101,7 +101,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT
{
         query.setResultsLevel(Query.Level.ALL_PROPERTIES);
         PathQuery pathQuery =  new PathQuery(new SimpleEntityRef(  app.getEm().getApplicationRef()),
query);
 
-        ns.getQueueManager().TEST_PATH_QUERY = pathQuery;
+        ns.TEST_PATH_QUERY = pathQuery;
         ApplicationQueueManager.QUEUE_NAME = "notifications/test/" + UUID.randomUUID().toString();
         listener = new QueueListener(ns.getServiceManagerFactory(),
                 ns.getEntityManagerFactory(),ns.getMetricsFactory(), new Properties());
@@ -155,7 +155,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT
{
         pQuery.setCollection("devices");
         pQuery.setResultsLevel(Query.Level.ALL_PROPERTIES);
         pQuery.addIdentifier(new ServiceParameter.NameParameter(device1.getUuid().toString()).getIdentifier());
-        ns.getQueueManager().TEST_PATH_QUERY =  new PathQuery(new SimpleEntityRef( app.getEm().getApplicationRef()),
pQuery);
+        ns.TEST_PATH_QUERY =  new PathQuery(new SimpleEntityRef( app.getEm().getApplicationRef()),
pQuery);
 
         app.clear();
         String payload = "Hello, World!";
@@ -198,12 +198,12 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT
{
         // create query that searches for that device by providing UUID of the user
         Query pQuery = new Query();
         pQuery.setLimit(100);
-        pQuery.setCollection("devices");
+        pQuery.setCollection("users");
         pQuery.setResultsLevel(Query.Level.ALL_PROPERTIES);
 
         pQuery.addIdentifier(new ServiceParameter.NameParameter(
             user.getUuid().toString()).getIdentifier()); 
-        ns.getQueueManager().TEST_PATH_QUERY =  new PathQuery( user, pQuery );
+        ns.TEST_PATH_QUERY =  new PathQuery( user, pQuery );
 
         // create a push notification 
         String payload = "Hello, World!";


Mime
View raw message