Removed 10 app limit Fixed idea excludes
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/65064baf Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/65064baf Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/65064baf Branch: refs/heads/two-dot-o Commit: 65064baf4551ccbec49c5ded9dad320c639d9a6b Parents: 7f50cae Author: Todd Nine <[email protected]> Authored: Mon Mar 3 19:15:42 2014 -0700 Committer: Todd Nine <[email protected]> Committed: Mon Mar 3 19:15:42 2014 -0700 ---------------------------------------------------------------------- stack/pom.xml | 2 +- .../applications/ApplicationsIT.java | 84 ++++++++++++++++++++ .../cassandra/ManagementServiceImpl.java | 27 ++++--- 3 files changed, 101 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/65064baf/stack/pom.xml ---------------------------------------------------------------------- diff --git a/stack/pom.xml b/stack/pom.xml index bdf2137..1e4214c 100644 --- a/stack/pom.xml +++ b/stack/pom.xml @@ -1772,7 +1772,7 @@ <!-- git and IDE project files --> <exclude>**/.git/**</exclude> <exclude>**/.gitignore</exclude> - <exclude>**..idea/**</exclude> + <exclude>**/.idea/**</exclude> <exclude>**/*.iml</exclude> <exclude>**/nbactions.xml</exclude> <exclude>**/nb-configuration.xml</exclude> http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/65064baf/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsIT.java ---------------------------------------------------------------------- diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsIT.java new file mode 100644 index 0000000..424c01c --- /dev/null +++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsIT.java @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.usergrid.rest.management.organizations.applications; + + +import java.util.HashSet; +import java.util.Set; + +import org.codehaus.jackson.JsonNode; +import org.junit.Rule; +import org.junit.Test; + +import org.apache.usergrid.rest.AbstractRestIT; +import org.apache.usergrid.rest.TestContextSetup; + +import static org.junit.Assert.assertEquals; + + +/** + * + * + */ +public class ApplicationsIT extends AbstractRestIT { + + @Rule + public TestContextSetup context = new TestContextSetup( this ); + + + @Test + public void test10AppLimit() { + + int size = 11; + + Set<String> appNames = new HashSet<String>( size ); + + for ( int i = 0; i < size; i++ ) { + final String name = i + ""; + + appNames.add( name ); + + context.withApp( name ).createAppForOrg(); + } + + //now go through and ensure each entry is present + + final JsonNode apps = context.management().orgs().organization( context.getOrgName() ).apps().get(); + + final JsonNode data = apps.get( "data" ); + + final String orgName = context.getOrgName(); + + + final Set<String> copy = new HashSet<String> (appNames); + + for(String appName: copy){ + + final String mapEntryName = String.format( "%s/%s", orgName.toLowerCase(), appName.toLowerCase()); + + JsonNode orgApp = data.get( mapEntryName); + + if(orgApp != null){ + appNames.remove( appName ); + } + + } + + assertEquals("All elements removed", 0, appNames.size()); + + } +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/65064baf/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java ---------------------------------------------------------------------- diff --git a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java index af30325..07175ec 100644 --- a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java +++ b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java @@ -55,6 +55,7 @@ import org.apache.usergrid.persistence.EntityManager; import org.apache.usergrid.persistence.EntityManagerFactory; import org.apache.usergrid.persistence.EntityRef; import org.apache.usergrid.persistence.Identifier; +import org.apache.usergrid.persistence.PagingResultsIterator; import org.apache.usergrid.persistence.Results; import org.apache.usergrid.persistence.Results.Level; import org.apache.usergrid.persistence.SimpleEntityRef; @@ -1640,24 +1641,28 @@ public class ManagementServiceImpl implements ManagementService { if ( organizationId == null ) { return null; } - BiMap<UUID, String> applications = HashBiMap.create(); - EntityManager em = emf.getEntityManager( MANAGEMENT_APPLICATION_ID ); - Results results = em.getConnectedEntities( organizationId, "owns", APPLICATION_INFO, Level.ALL_PROPERTIES ); - if ( !results.isEmpty() ) { + final BiMap<UUID, String> applications = HashBiMap.create(); + final EntityManager em = emf.getEntityManager( MANAGEMENT_APPLICATION_ID ); + final Results results = em.getConnectedEntities( organizationId, "owns", APPLICATION_INFO, Level.ALL_PROPERTIES ); + final PagingResultsIterator itr = new PagingResultsIterator( results ); - String entityName = null; - for ( Entity entity : results.getEntities() ) { - entityName = entity.getName(); + String entityName; - if ( entityName != null ) { - entityName = entityName.toLowerCase(); - } + while ( itr.hasNext() ) { + + final Entity entity = ( Entity ) itr.next(); - applications.put( entity.getUuid(), entityName ); + entityName = entity.getName(); + + if ( entityName != null ) { + entityName = entityName.toLowerCase(); } + + applications.put( entity.getUuid(), entityName ); } + return applications; }
