geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject geode git commit: cleaned up unit test
Date Tue, 06 Jun 2017 17:17:06 GMT
Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-3027 01675fa29 -> 4a901bfcc


cleaned up unit test


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

Branch: refs/heads/feature/GEODE-3027
Commit: 4a901bfcc9b1644d5bed02a329612b895188cdc3
Parents: 01675fa
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Tue Jun 6 10:16:56 2017 -0700
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Tue Jun 6 10:16:56 2017 -0700

----------------------------------------------------------------------
 .../StringPrefixPartitionResolverJUnitTest.java | 41 +++++++++-----------
 1 file changed, 18 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/4a901bfc/geode-core/src/test/java/org/apache/geode/cache/StringPrefixPartitionResolverJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache/StringPrefixPartitionResolverJUnitTest.java
b/geode-core/src/test/java/org/apache/geode/cache/StringPrefixPartitionResolverJUnitTest.java
index e311453..2b53315 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/StringPrefixPartitionResolverJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/StringPrefixPartitionResolverJUnitTest.java
@@ -44,56 +44,51 @@ public class StringPrefixPartitionResolverJUnitTest {
 
   @Test
   public void testNonStringKey() {
-    @SuppressWarnings("unchecked")
-    EntryOperation<String, Object> eo =
-        new EntryOperationImpl(null, null, new Object(), null, null);
+    Object key = new Object();
     StringPrefixPartitionResolver pr = new StringPrefixPartitionResolver();
-    assertThatThrownBy(() -> pr.getRoutingObject(eo)).isInstanceOf(ClassCastException.class);
+    assertThatThrownBy(() -> pr.getRoutingObject(createEntryOperation(key)))
+        .isInstanceOf(ClassCastException.class);
   }
 
   @Test
   public void testNoDelimiterKey() {
-    @SuppressWarnings("unchecked")
-    EntryOperation<String, Object> eo = new EntryOperationImpl(null, null, "foobar",
null, null);
+    String key = "foobar";
     StringPrefixPartitionResolver pr = new StringPrefixPartitionResolver();
-    assertThatThrownBy(() -> pr.getRoutingObject(eo)).isInstanceOf(IllegalArgumentException.class)
+    assertThatThrownBy(() -> pr.getRoutingObject(createEntryOperation(key)))
+        .isInstanceOf(IllegalArgumentException.class)
         .hasMessage("The key \"foobar\" does not contains the \"" + DELIMITER + "\" delimiter.");
   }
 
   @Test
   public void testEmptyPrefix() {
-    @SuppressWarnings("unchecked")
-    EntryOperation<String, Object> eo =
-        new EntryOperationImpl(null, null, DELIMITER + "foobar", null, null);
+    String key = DELIMITER + "foobar";
     StringPrefixPartitionResolver pr = new StringPrefixPartitionResolver();
-    assertEquals("", pr.getRoutingObject(eo));
+    assertEquals("", pr.getRoutingObject(createEntryOperation(key)));
   }
 
   @Test
   public void testAllPrefix() {
-    @SuppressWarnings("unchecked")
-    EntryOperation<String, Object> eo =
-        new EntryOperationImpl(null, null, "foobar" + DELIMITER, null, null);
+    String key = "foobar" + DELIMITER;
     StringPrefixPartitionResolver pr = new StringPrefixPartitionResolver();
-    assertEquals("foobar", pr.getRoutingObject(eo));
+    assertEquals("foobar", pr.getRoutingObject(createEntryOperation(key)));
   }
 
   @Test
   public void testSimpleKey() {
-    @SuppressWarnings("unchecked")
-    EntryOperation<String, Object> eo =
-        new EntryOperationImpl(null, null, "1" + DELIMITER + "2", null, null);
+    String key = "1" + DELIMITER + "2";
     StringPrefixPartitionResolver pr = new StringPrefixPartitionResolver();
-    assertEquals("1", pr.getRoutingObject(eo));
+    assertEquals("1", pr.getRoutingObject(createEntryOperation(key)));
   }
 
   @Test
   public void testMulitPrefix() {
-    @SuppressWarnings("unchecked")
-    EntryOperation<String, Object> eo = new EntryOperationImpl(null, null,
-        "one" + DELIMITER + "two" + DELIMITER + "three", null, null);
+    String key = "one" + DELIMITER + "two" + DELIMITER + "three";
     StringPrefixPartitionResolver pr = new StringPrefixPartitionResolver();
-    assertEquals("one", pr.getRoutingObject(eo));
+    assertEquals("one", pr.getRoutingObject(createEntryOperation(key)));
   }
 
+  @SuppressWarnings("unchecked")
+  private EntryOperation<String, Object> createEntryOperation(Object key) {
+    return new EntryOperationImpl(null, null, key, null, null);
+  }
 }


Mime
View raw message