Test for doubly nested field, plus some formatting changes.

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

Branch: refs/heads/release-2.1.1
Commit: 0b4162035ee7d54199bd2250c2b3ac31354516b1
Parents: 3eec8e5
Author: Dave Johnson <[email protected]>
Authored: Thu May 19 08:57:42 2016 -0400
Committer: Dave Johnson <[email protected]>
Committed: Thu May 19 08:57:42 2016 -0400

----------------------------------------------------------------------
 .../read/search/CandidateEntityFilter.java      | 16 +++++++-----
 .../apache/usergrid/persistence/IndexIT.java    | 27 +++++++++++++++-----
 2 files changed, 30 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/0b416203/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
----------------------------------------------------------------------
diff --git 
a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
 
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
index 261259b..e02e6c7 100644
--- 
a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
+++ 
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
@@ -52,9 +52,9 @@ import rx.Observable;
 
 
 /**
- * Loads entities from an incoming CandidateResult emissions into entities, 
then streams them on
- * performs internal buffering for efficiency.  Note that all entities may not 
be emitted if our load crosses page boundaries.  It is up to the
- * collector to determine when to stop streaming entities.
+ * Loads entities from an incoming CandidateResult emissions into entities, 
then streams them on performs internal
+ * buffering for efficiency.  Note that all entities may not be emitted if our 
load crosses page boundaries.
+ * It is up to the collector to determine when to stop streaming entities.
  */
 public class CandidateEntityFilter extends 
AbstractFilter<FilterResult<Candidate>, FilterResult<Entity>> {
 
@@ -93,11 +93,12 @@ public class CandidateEntityFilter extends 
AbstractFilter<FilterResult<Candidate
             entityCollectionManagerFactory.createCollectionManager( 
applicationScope );
 
 
-        final EntityIndex applicationIndex =
-            
entityIndexFactory.createEntityIndex(indexLocationStrategyFactory.getIndexLocationStrategy(applicationScope)
 );
+        final EntityIndex applicationIndex = entityIndexFactory
+            
.createEntityIndex(indexLocationStrategyFactory.getIndexLocationStrategy(applicationScope)
 );
 
         //buffer them to get a page size we can make 1 network hop
-        final Observable<FilterResult<Entity>> searchIdSetObservable = 
candidateResultsObservable.buffer( pipelineContext.getLimit() )
+        final Observable<FilterResult<Entity>> searchIdSetObservable =
+            candidateResultsObservable.buffer( pipelineContext.getLimit() )
 
             //load them
             .flatMap( candidateResults -> {
@@ -198,7 +199,8 @@ public class CandidateEntityFilter extends 
AbstractFilter<FilterResult<Candidate
 
 
     /**
-     * Our collector to collect entities.  Not quite a true collector, but 
works within our operational flow as this state is mutable and difficult to 
represent functionally
+     * Our collector to collect entities.  Not quite a true collector, but 
works within our operational
+     * flow as this state is mutable and difficult to represent functionally
      */
     private static final class EntityVerifier {
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0b416203/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
----------------------------------------------------------------------
diff --git 
a/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java 
b/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
index 3b9f95a..aaf4c33 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
@@ -477,6 +477,10 @@ public class IndexIT extends AbstractCoreIT {
                 put("xfactor", 5.1);
                 put("rando", "bar");
                 put("mondo", "2000");
+                put("frosting", "chocolate");
+                put("misc", new HashMap() {{
+                    put("range", "open");
+                }});
             }});
         }};
         em.create("names", entity1);
@@ -488,12 +492,17 @@ public class IndexIT extends AbstractCoreIT {
                 put("xfactor", 5.1);
                 put("rando", "bar");
                 put("mondo", "2001");
+                put("frosting", "orange");
+                put("misc", new HashMap() {{
+                    put("range", "open");
+                }});
             }});
         }};
         em.create("names", entity2);
 
         app.refreshIndex();
 
+        // simple single-field select mapping
         {
             Query query = Query.fromQL("select status where status = 
'pickled'");
             Results r = em.searchCollection( em.getApplicationRef(), "names", 
query );
@@ -502,6 +511,7 @@ public class IndexIT extends AbstractCoreIT {
             assertTrue(first.getDynamicProperties().size() == 2);
         }
 
+        // simple single-field plus nested field select mapping
         {
             Query query = Query.fromQL( "select status, data.rando where 
data.rando = 'bar'" );
             Results r = em.searchCollection( em.getApplicationRef(), "names", 
query );
@@ -518,23 +528,28 @@ public class IndexIT extends AbstractCoreIT {
             assertTrue( first.getDynamicProperties().size() == 3 );
         }
 
+        // multiple nested fields with one doubly-nesed field
         {
-            //  query for only one bogus field name should return empty 
entities
-            Query query = Query.fromQL( "select data.rando,data.mondo where 
status = 'pickled'" );
+            Query query = Query.fromQL( "select data.rando, data.mondo, 
data.misc.range where status = 'pickled'" );
             Results r = em.searchCollection( em.getApplicationRef(), "names", 
query );
             assertTrue( r.getEntities() != null && r.getEntities().size() == 2 
);
 
             Entity first = r.getEntities().get( 0 );
 
-            assertNotNull( first.getProperty("data") );
-            assertEquals( ((Map<String, 
Object>)first.getProperty("data")).get("rando"), "bar" );
-            assertEquals( ((Map<String, 
Object>)first.getProperty("data")).get("mondo"), "2001" );
+            Map<String, Object> data = ((Map<String, 
Object>)first.getProperty("data"));
+            assertNotNull( data );
+            assertEquals( data.get("rando"), "bar" );
+            assertEquals( data.get("mondo"), "2001" );
+            assertNull( data.get("frosting") );
+
+            Map<String, Object> misc = (Map<String, Object>)data.get("misc");
+            assertEquals( misc.get("range"), "open" );
 
             assertTrue( first.getDynamicProperties().size() == 2 );
         }
 
+        //  query for one bogus field name should return empty entities
         {
-            //  query for only one bogus field name should return empty 
entities
             Query query = Query.fromQL( "select data.bogusfieldname where 
status = 'pickled'" );
             Results r = em.searchCollection( em.getApplicationRef(), "names", 
query );
             assertTrue( r.getEntities() != null && r.getEntities().size() == 2 
);

Reply via email to