usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [14/36] usergrid git commit: Cleaned up the updating test to verify that a collection of 10 will be indexed.
Date Fri, 08 Apr 2016 20:21:01 GMT
Cleaned up the updating test to verify that a collection of 10 will be indexed.


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

Branch: refs/heads/release-2.1.1
Commit: e1d60b4c2111f9eea47bf6824becb1c09cc81d6c
Parents: 975616b
Author: George Reyes <grey@apache.org>
Authored: Wed Mar 23 09:24:12 2016 -0700
Committer: George Reyes <grey@apache.org>
Committed: Thu Mar 24 09:15:01 2016 -0700

----------------------------------------------------------------------
 .../collection/CollectionsResourceIT.java       | 56 ++++++++++++--------
 1 file changed, 34 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/e1d60b4c/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
index 11a1878..5900dd5 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
@@ -128,17 +128,13 @@ public class CollectionsResourceIT extends AbstractRestIT {
 
         //Create test collection with test entity that is full text indexed.
         Entity testEntity = new Entity();
-        testEntity.put( "one", "value1" );
-        //this field shouldn't persist after reindexing.
-        testEntity.put( "two","valuetwo1" );
 
-        this.app().collection( "testCollection" ).post( testEntity );
-
-        testEntity.put( "one", "value2" );
-        //this field shouldn't persist after reindexing.
-        testEntity.put( "two","valuetwo2" );
 
-        this.app().collection( "testCollection" ).post( testEntity );
+        for(int i = 0; i < 10; i++){
+            testEntity.put( "one","value"+i );
+            testEntity.put( "two","valuetwo"+i );
+            this.app().collection( "testCollection" ).post( testEntity );
+        }
 
 
         //Creating schema.
@@ -155,25 +151,41 @@ public class CollectionsResourceIT extends AbstractRestIT {
         Entity thing = this.app().collection( "testCollection" ).collection( "_indexes" ).post(
payload );
         refreshIndex();
 
+        //TODO: write a test to verify the data below.
+
+        //        Collection collection = this.app().collection( "testCollection" ).collection(
"_index" ).get();
+        //
+        //        LinkedHashMap testCollectionSchema = (LinkedHashMap)collection.getResponse().getData();
+        //        //TODO: the below will have to be replaced by the values that I deem correct.
+        //        assertEquals( ( thing ).get( "lastUpdated" ), testCollectionSchema.get(
"lastUpdated" ));
+        //        assertEquals( ( thing ).get( "lastUpdateBy" ),testCollectionSchema.get(
"lastUpdateBy" ) );
+        //        assertEquals( ( thing ).get( "lastReindexed" ),testCollectionSchema.get(
"lastReindexed" ) );
+        //
+        //        //TODO: this test doesn't check to see if create checks the schema. Only
that the reindex removes whats already there.
+        //        ArrayList<String> schema = ( ArrayList<String> ) testCollectionSchema.get(
"fields" );
+        //        assertEquals( "one",schema.get( 0 ) );
+
+
         //Reindex and verify that the entity only has field one index.
         this.app().collection( "testCollection" ).collection( "_reindex" ).post();
-        Thread.sleep( 1000 );
+        Thread.sleep( 10000 );
         refreshIndex();
 
-        String query = "one ='value1'";
-        QueryParameters queryParameters = new QueryParameters().setQuery(query);
+        for(int i = 0; i < 10; i++) {
+            String query = "one ='value"+ i + "'";
+            QueryParameters queryParameters = new QueryParameters().setQuery( query );
 
-        //having a name breaks it. Need to get rid of the stack trace and also
-        Collection tempEntity = this.app().collection( "testCollection" ).get(queryParameters,true);
-        Entity reindexedEntity = tempEntity.getResponse().getEntity();
-        assertEquals( "value1",reindexedEntity.get( "one" ) );
-        tempEntity=null;
+            //having a name breaks it. Need to get rid of the stack trace and also
+            Collection tempEntity = this.app().collection( "testCollection" ).get( queryParameters,
true );
+            Entity reindexedEntity = tempEntity.getResponse().getEntity();
+            assertEquals( "value"+i, reindexedEntity.get( "one" ) );
 
-        //Verify if you can query on an entity that was not indexed and that no entities
are returned.
-        query = "two = 'valuetwo1'";
-        queryParameters = new QueryParameters().setQuery(query);
-        tempEntity = this.app().collection( "testCollection" ).get(queryParameters,true);
-        assertEquals(0,tempEntity.getResponse().getEntities().size());
+            //Verify if you can query on an entity that was not indexed and that no entities
are returned.
+            query = "two = 'valuetwo1"+ i + "'";
+            queryParameters = new QueryParameters().setQuery( query );
+            tempEntity = this.app().collection( "testCollection" ).get( queryParameters,
true );
+            assertEquals( 0, tempEntity.getResponse().getEntities().size() );
+        }
     }
 
     /**


Mime
View raw message