Cleaned up the test
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/3c98c2dd Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/3c98c2dd Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/3c98c2dd Branch: refs/heads/release-2.1.1 Commit: 3c98c2ddefc799924d4069b6010eac4e561a69b2 Parents: aa7f776 Author: George Reyes <[email protected]> Authored: Fri Mar 11 16:25:25 2016 -0800 Committer: George Reyes <[email protected]> Committed: Thu Mar 24 09:09:32 2016 -0700 ---------------------------------------------------------------------- .../collection/CollectionsResourceIT.java | 62 +++++--------------- 1 file changed, 15 insertions(+), 47 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/usergrid/blob/3c98c2dd/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 1aa91d1..2e4a3ff 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 @@ -192,73 +192,41 @@ public class CollectionsResourceIT extends AbstractRestIT { @Test public void postToCollectionSchemaWithSchemaFirst() throws Exception { - - - //Creating schema. - //this could be changed to a hashmap. + //Include the property labeled two to be index. ArrayList<String> indexingArray = new ArrayList<>( ); - indexingArray.add( "one" ); - indexingArray.add( "name" ); - - //TODO: add indexing array to the backend/test once you finish the regular selective indexing. - //indexingArray.add( "field.three.index.array" ); + indexingArray.add( "two" ); //field "fields" is required. Entity payload = new Entity(); payload.put( "fields", indexingArray); //Post index to the collection metadata - // Entity thing = this.app().collection( "testCollection" ).collection( "_indexes" ).post( payload ); + this.app().collection( "testCollection" ).collection( "_indexes" ).post( payload ); refreshIndex(); - //Create test collection with test entity that is full text indexed. + //Create test collection with a test entity that is partially indexed. Entity testEntity = new Entity(); - //testEntity.put( "name", "tester"); testEntity.put( "one", "helper" ); - //this field shouldn't persist after reindexing. testEntity.put( "two","query" ); - //TODO: add arrays to the indexing test - //testEntity.put("array","array stuff here"); - - Entity returnedEntity = this.app().collection( "testCollection" ).post( testEntity ); + //Post entity. + this.app().collection( "testCollection" ).post( testEntity ); refreshIndex(); - //testEntity.put( "three","notthree" ); - //ApiResponse updatedEntity = this.app().collection( "testCollection" ).put( null,testEntity ); - - //Below is what needs to be implemented along with the index call above - -// //Get the collection schema and verify that it contains the same schema as posted above. -// 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(); -// -// refreshIndex(); - - //this needs to be a query. not a graph. This should still return the full entity. + //Do a query to see if you can find the indexed query. String query = "two ='query'"; QueryParameters queryParameters = new QueryParameters().setQuery(query); -//having a name breaks it. Need to get rid of the stack trace and also + //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(); //this.app().collection( "testCollection" ).entity( returnedEntity.getUuid() ).get(); + Entity reindexedEntity = tempEntity.getResponse().getEntity(); assertEquals( "helper",reindexedEntity.get( "one" ) ); - assertNull( reindexedEntity.get( "two" ) ); - //not sure if this should have some kind of sleep here because this reindex will be heavily throttled. + + //Verify if you can query on an entity that was not indexed and that no entities are returned. + query = "one = 'helper'"; + queryParameters = new QueryParameters().setQuery(query); + tempEntity = this.app().collection( "testCollection" ).get(queryParameters,true); + assertEquals(0,tempEntity.getResponse().getEntities().size()); }
