usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject usergrid git commit: passing tests
Date Wed, 26 Aug 2015 21:53:52 GMT
Repository: usergrid
Updated Branches:
  refs/heads/entity-size 8a719733c -> e6b6c0789


passing tests


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

Branch: refs/heads/entity-size
Commit: e6b6c0789b73696040282b364cb1c4c3206a391d
Parents: 8a71973
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Wed Aug 26 15:53:47 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Wed Aug 26 15:53:47 2015 -0600

----------------------------------------------------------------------
 .../service/AggregationServiceImpl.java         | 10 ++++++----
 .../corepersistence/util/CpNamingUtils.java     |  2 +-
 .../corepersistence/AggregationServiceTest.java | 21 ++++++++++++++------
 3 files changed, 22 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/e6b6c078/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/AggregationServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/AggregationServiceImpl.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/AggregationServiceImpl.java
index 5635bee..b8786d1 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/AggregationServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/AggregationServiceImpl.java
@@ -72,10 +72,12 @@ public class AggregationServiceImpl implements AggregationService {
         final IndexLocationStrategy indexLocationStrategy = indexLocationStrategyFactory.getIndexLocationStrategy(applicationScope);
         EntityIndex entityIndex = entityIndexFactory.createEntityIndex(indexLocationStrategy);
         GraphManager graphManager = graphManagerFactory.createEdgeManager(applicationScope);
-        Long sum = ObservableTimer.time( MathObservable.sumLong(graphManager.getEdgeTypesFromSource(new
SimpleSearchEdgeType(applicationScope.getApplication(), CpNamingUtils.EDGE_COLL_PREFIX, Optional.<String>absent()))
-                .map(type -> CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(),
type))
-                .map(edge -> entityIndex.getEntitySize(edge))
-        ), sumTimer).toBlocking().last();
+        Long sum = ObservableTimer.time(
+            MathObservable.sumLong(
+                graphManager.getEdgeTypesFromSource(new SimpleSearchEdgeType(applicationScope.getApplication(),
CpNamingUtils.EDGE_COLL_PREFIX, Optional.<String>absent()))
+                    .map(type -> CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(),
type))
+                    .map(edge -> entityIndex.getEntitySize(edge))
+            ), sumTimer).toBlocking().last();
 
         return sum.longValue();
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/e6b6c078/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
index d5b05a2..acda51f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
@@ -110,7 +110,7 @@ public class CpNamingUtils {
      * To be used only for searching DO NOT use for creation. Use the createCollectionEdge
instead.
      */
     public static String getEdgeTypeFromCollectionName( String collectionName ) {
-        return ( EDGE_COLL_PREFIX + "|" + collectionName ).toLowerCase();
+        return ((collectionName.startsWith(EDGE_COLL_PREFIX) ? collectionName  : EDGE_COLL_PREFIX
+ "|" + collectionName) ).toLowerCase();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/usergrid/blob/e6b6c078/stack/core/src/test/java/org/apache/usergrid/corepersistence/AggregationServiceTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/AggregationServiceTest.java
b/stack/core/src/test/java/org/apache/usergrid/corepersistence/AggregationServiceTest.java
index aa3615d..cc8adf1 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/AggregationServiceTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/AggregationServiceTest.java
@@ -46,7 +46,7 @@ public class AggregationServiceTest extends AbstractCoreIT {
         Map<String,Object> props = new HashMap<>();
          props.put("test", 1234);
         props.put("name", "myname");
-        Entity entity1 = this.app.getEntityManager().create("test",props);
+        Entity entity1 = this.app.getEntityManager().create("test", props);
         Entity entity2 = this.app.getEntityManager().create("test2", props);
         this.app.refreshIndex();
         Thread.sleep(500);
@@ -54,13 +54,22 @@ public class AggregationServiceTest extends AbstractCoreIT {
         long sum = aggregationService.sumAllCollections(applicationScope);
 
         Assert.assertTrue( sum >= 0 );
-        Assert.assertEquals(sum,entity1.getSize() + entity2.getSize());
+        Assert.assertTrue(sum > (entity1.getSize() + entity2.getSize()));
 
-        long sum1 = aggregationService.sum(applicationScope,CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(),"test"));
-        Assert.assertEquals(sum1,entity1.getSize());
+        long sum1 = aggregationService.sum(applicationScope,CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(),"tests"));
+        Assert.assertEquals(sum1, entity1.getSize());
 
-        long sum2 = aggregationService.sum(applicationScope,CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(),"test2"));
-        Assert.assertEquals(sum2,entity2.getSize());
+        long sum2 = aggregationService.sum(applicationScope, CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(),
"test2s"));
+        Assert.assertEquals(sum2, entity2.getSize());
+
+        props = new HashMap<>();
+        props.put("test", 1234);
+        props.put("name", "myname2");
+        Entity entity3 = this.app.getEntityManager().create("test", props);
+
+        this.app.refreshIndex();
+        long sum3 = aggregationService.sum(applicationScope, CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(),
"tests"));
+        Assert.assertEquals(sum3, entity1.getSize()+entity3.getSize());
 
     }
 }


Mime
View raw message