albertogpz commented on code in PR #7493:
URL: https://github.com/apache/geode/pull/7493#discussion_r872090768


##########
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/PRClientServerRegionFunctionExecutionNoSingleHopDistributedTest.java:
##########
@@ -657,191 +710,162 @@ private static void 
serverMultiKeyExecutionOnASingleBucket(Boolean isByName) {
     }
     DistributedSystem.setThreadsSocketPolicy(false);
     for (String o : testKeysSet) {
-      try {
-        Set<String> singleKeySet = Collections.singleton(o);
-        Function function = new TestFunction(true, TEST_FUNCTION2);
-        FunctionService.registerFunction(function);
-        Execution dataSet = FunctionService.onRegion(region);
-        ResultCollector rc1 = execute(dataSet, singleKeySet, Boolean.TRUE, 
function, isByName);
-        List l = ((List) rc1.getResult());
-        assertEquals(1, l.size());
-
-        ResultCollector rc2 =
-            execute(dataSet, singleKeySet, new HashSet<>(singleKeySet), 
function, isByName);
-        List l2 = ((List) rc2.getResult());
-
-        assertEquals(1, l2.size());
-        List subList = (List) l2.iterator().next();
-        assertEquals(1, subList.size());
-        assertEquals(region.get(singleKeySet.iterator().next()), 
subList.iterator().next());
-      } catch (Exception expected) {
-        logger.info("Exception : " + expected.getMessage());
-        expected.printStackTrace();
-        fail("Test failed after the put operation");
-      }
+      Set<String> singleKeySet = Collections.singleton(o);
+      Function<Object> function = new TestFunction<>(true, TEST_FUNCTION2);
+      FunctionService.registerFunction(function);
+      Execution dataSet = FunctionService.onRegion(region);
+      ResultCollector<?, ?> rc1 = execute(dataSet, singleKeySet, Boolean.TRUE, 
function, isByName);
+      List<?> l = (List<?>) rc1.getResult();
+      assertThat(l).hasSize(1);
+
+      ResultCollector<?, ?> rc2 =
+          execute(dataSet, singleKeySet, new HashSet<>(singleKeySet), 
function, isByName);
+      List<?> l2 = (List<?>) rc2.getResult();
+
+      assertThat(l2).hasSize(1);
+      List<Integer> subList = (List<Integer>) l2.iterator().next();
+      assertThat(subList).hasSize(1);
+      
assertThat(subList).containsOnly(region.get(singleKeySet.iterator().next()));
     }
   }
 
   private static void serverMultiKeyExecution(Boolean isByName) {
     Region<String, Integer> region = cache.getRegion(PartitionedRegionName);
-    assertNotNull(region);
+    assertThat(region).isNotNull();
     final HashSet<String> testKeysSet = new HashSet<>();
     for (int i = (totalNumBuckets * 2); i > 0; i--) {
       testKeysSet.add("execKey-" + i);
     }
     DistributedSystem.setThreadsSocketPolicy(false);
-    Function function = new TestFunction(true, TEST_FUNCTION2);
+    Function<Object> function = new TestFunction<>(true, TEST_FUNCTION2);
     FunctionService.registerFunction(function);
     Execution dataSet = FunctionService.onRegion(region);
-    try {
-      int j = 0;
-      HashSet<Integer> origVals = new HashSet<>();
-      for (String element : testKeysSet) {
-        Integer val = j++;
-        origVals.add(val);
-        region.put(element, val);
-      }
-      ResultCollector rc1 = execute(dataSet, testKeysSet, Boolean.TRUE, 
function, isByName);
-      List l = ((List) rc1.getResult());
-      logger.info("Result size : " + l.size());
-      assertEquals(3, l.size());
-      for (Object item : l) {
-        assertEquals(Boolean.TRUE, item);
-      }
 
-      ResultCollector rc2 = execute(dataSet, testKeysSet, testKeysSet, 
function, isByName);
-      List l2 = ((List) rc2.getResult());
-      assertEquals(3, l2.size());
-      HashSet<Integer> foundVals = new HashSet<>();
-      for (Object value : l2) {
-        ArrayList subL = (ArrayList) value;
-        assertTrue(subL.size() > 0);
-        for (Object o : subL) {
-          assertTrue(foundVals.add((Integer) o));
-        }
-      }
-      assertEquals(origVals, foundVals);
-
-    } catch (Exception e) {
-      Assert.fail("Test failed after the put operation", e);
+    int j = 0;
+    HashSet<Integer> origVals = new HashSet<>();
+    for (String element : testKeysSet) {
+      Integer val = j++;
+      origVals.add(val);
+      region.put(element, val);
+    }
+    ResultCollector<?, ?> rc1 = execute(dataSet, testKeysSet, Boolean.TRUE, 
function, isByName);
+    List<?> l = (List<?>) rc1.getResult();
+    assertThat(l).hasSize(3);
+    for (Object item : l) {
+      assertThat(item).isEqualTo(Boolean.TRUE);
+    }
 
+    ResultCollector<?, ?> rc2 = execute(dataSet, testKeysSet, testKeysSet, 
function, isByName);
+    List<?> l2 = (List<?>) rc2.getResult();
+    assertThat(l2).hasSize(3);
+    HashSet<Integer> foundVals = new HashSet<>();
+    for (Object value : l2) {
+      List<?> subL = (List<?>) value;
+      assertThat(subL).hasSizeGreaterThan(0);
+      for (Object o : subL) {
+        assertThat(foundVals.add((Integer) o)).isTrue();

Review Comment:
   Not sure I get what you are exactly proposing here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@geode.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to