Fixed test to properly verify issue and ignored it due to not currently supporting keeping custom collections. Commented out the code for dynamic collections as it isn't currently supported.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/68b079a3 Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/68b079a3 Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/68b079a3 Branch: refs/heads/release-2.1.1 Commit: 68b079a39db53b61429949857f72dec66330203f Parents: 12d344f Author: George Reyes <[email protected]> Authored: Fri Feb 19 10:58:41 2016 -0800 Committer: George Reyes <[email protected]> Committed: Fri Feb 19 10:58:41 2016 -0800 ---------------------------------------------------------------------- .../corepersistence/CpEntityManager.java | 21 ++++++++++---------- .../collection/CollectionsResourceIT.java | 11 ++++++++-- 2 files changed, 20 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/usergrid/blob/68b079a3/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java ---------------------------------------------------------------------- diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java index d2f549b..9d2963c 100644 --- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java +++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java @@ -747,16 +747,17 @@ public class CpEntityManager implements EntityManager { Set<String> existingCollections = getRelationManager( getApplication() ).getCollections(); - Set<String> dynamic_collections = cast( getDictionaryAsSet( getApplicationRef(), Schema.DICTIONARY_COLLECTIONS ) ); - if ( dynamic_collections != null ) { - for ( String collection : dynamic_collections ) { - if ( !Schema.isAssociatedEntityType( collection ) ) { - if(!existingCollections.contains( collection )) { - existingCollections.add( collection ); - } - } - } - } + //Handles reading custom collections. +// Set<String> dynamic_collections = cast( getDictionaryAsSet( getApplicationRef(), Schema.DICTIONARY_COLLECTIONS ) ); +// if ( dynamic_collections != null ) { +// for ( String collection : dynamic_collections ) { +// if ( !Schema.isAssociatedEntityType( collection ) ) { +// if(!existingCollections.contains( collection )) { +// existingCollections.add( collection ); +// } +// } +// } +// } Set<String> system_collections = Schema.getDefaultSchema().getCollectionNames( Application.ENTITY_TYPE ); if ( system_collections != null ) { for ( String collection : system_collections ) { http://git-wip-us.apache.org/repos/asf/usergrid/blob/68b079a3/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 66c94ce..9752035 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 @@ -248,8 +248,10 @@ public class CollectionsResourceIT extends AbstractRestIT { } } + @Ignore("Ignored because we no longer retain custom collections after deleting the last entity in a collection" + + "This test can be used to verify that works when we implement it") @Test - public void testNewlyCreatedCollectionReturnWhenEmpty(){ + public void testNewlyCreatedCollectionReturnsWhenEmpty(){ String collectionName = "testDefaultCollectionReturnings"; Map<String,Object> payload = new HashMap( ); @@ -265,6 +267,7 @@ public class CollectionsResourceIT extends AbstractRestIT { this.refreshIndex(); this.app().collection( collectionName ).entity( testEntity.getEntity().getUuid() ).delete(); + this.refreshIndex(); //Verify that the collection still exists despite deleting its only entity.) @@ -272,7 +275,11 @@ public class CollectionsResourceIT extends AbstractRestIT { collectionHashMap = ( LinkedHashMap ) usersDefaultCollection.getEntity().get( "metadata" ); - assertNotSame( null,((LinkedHashMap)(collectionHashMap.get( "collections" ))).get( collectionName )); + assertNotSame( null,((LinkedHashMap)(collectionHashMap.get( "collections" ))).get( collectionName.toLowerCase() )); + + Collection createdCollectionResponse = this.app().collection( collectionName ).get(); + + assertEquals( 0,createdCollectionResponse.getNumOfEntities() ); }
