geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [2/5] incubator-geode git commit: GEODE-1425: fix callback arg parameter order
Date Wed, 25 May 2016 21:53:58 GMT
GEODE-1425: fix callback arg parameter order


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

Branch: refs/heads/feature/GEODE-1452
Commit: cae8f7fecf893ea4a31f7b06c22130fb646407bb
Parents: 31096fb
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Tue May 24 14:40:10 2016 -0700
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Wed May 25 10:03:57 2016 -0700

----------------------------------------------------------------------
 .../gemstone/gemfire/internal/cache/LocalDataSet.java | 12 +++++++++---
 .../gemfire/internal/cache/LocalDataSetTest.java      | 14 ++++++++++++++
 2 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cae8f7fe/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalDataSet.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalDataSet.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalDataSet.java
index daa7d3f..62c95e1 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalDataSet.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalDataSet.java
@@ -72,7 +72,7 @@ import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
  * 
  *
  */
-public final class LocalDataSet implements Region, QueryExecutor {
+public class LocalDataSet implements Region, QueryExecutor {
 
   private static final Logger logger = LogService.getLogger();
   
@@ -122,9 +122,15 @@ public final class LocalDataSet implements Region, QueryExecutor {
     return new LocalEntriesSet(IteratorType.KEYS);
   }
 
+  /**
+   * This instance method was added so that unit tests could mock it
+   */
+  int getHashKey(Operation op, Object key, Object value, Object callbackArg) {
+    return PartitionedRegionHelper.getHashKey(this.proxy, op, key, value, callbackArg);
+  }
+  
   private boolean isInDataSet(Object key, Object callbackArgument) {
-    int bucketId = PartitionedRegionHelper.getHashKey(this.proxy,
-        Operation.CONTAINS_KEY, key, callbackArgument, null);
+    int bucketId = getHashKey(Operation.CONTAINS_KEY, key, null, callbackArgument);
     Integer bucketIdInt = Integer.valueOf(bucketId);
     return buckets.contains(bucketIdInt);
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cae8f7fe/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/LocalDataSetTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/LocalDataSetTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/LocalDataSetTest.java
index fd813ed..21bac84 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/LocalDataSetTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/LocalDataSetTest.java
@@ -26,6 +26,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import com.gemstone.gemfire.cache.Operation;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
 
 @Category(UnitTest.class)
@@ -49,4 +50,17 @@ public class LocalDataSetTest {
     assertFalse(lds.isEmpty());
   }
   
+  @Test
+  public void verifyThatGetCallbackArgIsCorrectlyPassedToGetHashKey() {
+    PartitionedRegion pr = mock(PartitionedRegion.class);
+    when(pr.getTotalNumberOfBuckets()).thenReturn(33);
+    LocalDataSet lds = new LocalDataSet(pr, Collections.emptySet());
+    LocalDataSet spy = spy(lds);
+    Object key = "key";
+    Object callbackArg = "callbackArg";
+    
+    spy.get(key, callbackArg);
+    
+    verify(spy).getHashKey(Operation.CONTAINS_KEY, key, null, callbackArg);
+  }
 }


Mime
View raw message