geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject incubator-geode git commit: GEODE-1424: change isEmpty to use size
Date Tue, 24 May 2016 20:39:26 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop 2234535a8 -> 37974043f


GEODE-1424: change isEmpty to use size


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

Branch: refs/heads/develop
Commit: 37974043fc2f165a9a4f73f07fb0db1c2d8410f0
Parents: 2234535
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Mon May 23 16:31:30 2016 -0700
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Tue May 24 13:39:15 2016 -0700

----------------------------------------------------------------------
 .../gemfire/internal/cache/LocalDataSet.java    |  2 +-
 .../internal/cache/LocalDataSetTest.java        | 52 ++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/37974043/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 d8e48e1..daa7d3f 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
@@ -339,7 +339,7 @@ public final class LocalDataSet implements Region, QueryExecutor {
   }
 
   public boolean isEmpty() {
-    return this.proxy.isEmpty();
+    return size() == 0;
   }
 
   public Object getUserAttribute() {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/37974043/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
new file mode 100644
index 0000000..fd813ed
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/LocalDataSetTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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 com.gemstone.gemfire.internal.cache;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import java.util.Collections;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class LocalDataSetTest {
+
+  @Test
+  public void verifyThatIsEmptyIsTrueWhenEntryCountReturnsZero() {
+    PartitionedRegion pr = mock(PartitionedRegion.class);
+    when(pr.isEmpty()).thenReturn(false);
+    when(pr.entryCount(any())).thenReturn(0);
+    LocalDataSet lds = new LocalDataSet(pr, Collections.emptySet());
+    assertTrue(lds.isEmpty());
+  }
+  
+  @Test
+  public void verifyThatIsEmptyIsFalseWhenEntryCountReturnsNonZero() {
+    PartitionedRegion pr = mock(PartitionedRegion.class);
+    when(pr.isEmpty()).thenReturn(true);
+    when(pr.entryCount(any())).thenReturn(1);
+    LocalDataSet lds = new LocalDataSet(pr, Collections.emptySet());
+    assertFalse(lds.isEmpty());
+  }
+  
+}


Mime
View raw message