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


##########
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/PRClientServerRegionFunctionExecutionNoSingleHopDistributedTest.java:
##########
@@ -596,139 +584,123 @@ private static void putOperation() {
   }
 
   private void createScenario() {
-    ArrayList commonAttributes =
+    ArrayList<Object> commonAttributes =
         createCommonServerAttributes("TestPartitionedRegion", null, 0, null);
     createClientServerScenarioNoSingleHop(commonAttributes, 20, 20, 20);
   }
 
   private void createScenarioWithClientConnectTimeout(int connectTimeout, int 
maxThreads) {
-    ArrayList commonAttributes =
+    ArrayList<Object> commonAttributes =
         createCommonServerAttributes("TestPartitionedRegion", null, 0, null);
     createClientServerScenarioNoSingleHop(commonAttributes, 20, 20, 20, 
maxThreads, connectTimeout);
   }
 
 
   private void createScenarioForBucketFilter() {
-    ArrayList commonAttributes = 
createCommonServerAttributes("TestPartitionedRegion",
+    ArrayList<Object> commonAttributes = 
createCommonServerAttributes("TestPartitionedRegion",
         new BucketFilterPRResolver(), 0, null);
     createClientServerScenarioNoSingleHop(commonAttributes, 20, 20, 20);
   }
 
   private static void checkBucketsOnServer() {
     PartitionedRegion region = (PartitionedRegion) 
cache.getRegion(PartitionedRegionName);
-    HashMap localBucket2RegionMap = (HashMap) 
region.getDataStore().getSizeLocally();
+    HashMap<Integer, Integer> localBucket2RegionMap =
+        (HashMap<Integer, Integer>) region.getDataStore().getSizeLocally();
     logger.info(
         "Size of the " + PartitionedRegionName + " in this VM :- " + 
localBucket2RegionMap.size());
-    Set entrySet = localBucket2RegionMap.entrySet();
-    assertNotNull(entrySet);
+    Set<Map.Entry<Integer, Integer>> entrySet = 
localBucket2RegionMap.entrySet();
+    assertThat(entrySet).isNotNull();
   }
 
   private static void serverAllKeyExecution(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 item : testKeysSet) {
-        Integer val = j++;
-        origVals.add(val);
-        region.put(item, val);
-      }
-      ResultCollector rc1 = executeOnAll(dataSet, Boolean.TRUE, function, 
isByName);
-      List resultList = (List) rc1.getResult();
-      logger.info("Result size : " + resultList.size());
-      logger.info("Result are SSSS : " + resultList);
-      assertEquals(3, resultList.size());
-
-      for (Object result : resultList) {
-        assertEquals(Boolean.TRUE, result);
-      }
-      ResultCollector rc2 = executeOnAll(dataSet, 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 item : testKeysSet) {
+      Integer val = j++;
+      origVals.add(val);
+      region.put(item, val);
+    }
+    ResultCollector<?, ?> rc1 = executeOnAll(dataSet, Boolean.TRUE, function, 
isByName);
+    List<?> resultList = (List<?>) rc1.getResult();
+    logger.info("Result size : " + resultList.size());
+    logger.info("Result are SSSS : " + resultList);
+    assertThat(resultList.size()).isEqualTo(3);
+
+    for (Object result : resultList) {
+      assertThat(result).isEqualTo(Boolean.TRUE);
+    }
+    ResultCollector<?, ?> rc2 = executeOnAll(dataSet, testKeysSet, function, 
isByName);
+    List<?> l2 = (List<?>) rc2.getResult();
+    assertThat(l2.size()).isEqualTo(3);
+    HashSet<Integer> foundVals = new HashSet<>();
+    for (Object value : l2) {
+      List<?> subL = (List<?>) value;
+      assertThat(subL.size()).isGreaterThan(0);
+      for (Object o : subL) {
+        assertThat(foundVals.add((Integer) o)).isTrue();
+      }
     }
+    assertThat(foundVals).isEqualTo(origVals);
   }
 
   public static void getAll() {
     Region<String, Integer> region = cache.getRegion(PartitionedRegionName);
-    assertNotNull(region);
+    assertThat(region).isNotNull();
     final List<String> testKeysList = new ArrayList<>();
     for (int i = (totalNumBuckets * 3); i > 0; i--) {
       testKeysList.add("execKey-" + i);
     }
     DistributedSystem.setThreadsSocketPolicy(false);
-    try {
-      int j = 0;
-      Map<String, Integer> origVals = new HashMap<>();
-      for (String key : testKeysList) {
-        Integer val = j++;
-        origVals.put(key, val);
-        region.put(key, val);
-      }
-      Map resultMap = region.getAll(testKeysList);
-      assertEquals(resultMap, origVals);
-      Wait.pause(2000);
-      Map secondResultMap = region.getAll(testKeysList);
-      assertEquals(secondResultMap, origVals);
-
-    } catch (Exception e) {
-      Assert.fail("Test failed after the put operation", e);
-
+    int j = 0;
+    Map<String, Integer> origVals = new HashMap<>();
+    for (String key : testKeysList) {
+      Integer val = j++;
+      origVals.put(key, val);
+      region.put(key, val);
     }
+    Map<String, Integer> resultMap = region.getAll(testKeysList);
+    assertThat(resultMap).isEqualTo(origVals);

Review Comment:
   I had to use: 
`assertThat(foundVals).containsExactlyInAnyOrderElementsOf(origVals);`



-- 
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