@Test
  public void testGetNodeToBucketMap() {
    int totalNodes = 100;
    String prPrefix = name.getMethodName();
    String localMaxMemory = "0";
    final int redundancy = 1;
    final int totalNoOfBuckets = 5;
    PartitionedRegion pr = (PartitionedRegion) PartitionedRegionTestHelper
        .createPartitionedRegion(prPrefix, localMaxMemory, redundancy);

    HashSet<Integer> bucketsToQuery = new HashSet<>();
    for (int i = 0; i < totalNoOfBuckets; i++) {
      bucketsToQuery.add(i);
    }
    final String expectedUnknownHostException = UnknownHostException.class.getName();
    pr.getCache().getLogger().info(
        "<ExpectedException action=add>" + expectedUnknownHostException + "</ExpectedException>");
    final ArrayList nodes = createNodeList(totalNodes);
    pr.getCache().getLogger().info("<ExpectedException action=remove>"
        + expectedUnknownHostException + "</ExpectedException>");
    // populating bucket2Node of the partition region
    // ArrayList<InternalDistributedMember>
    final ArrayList dses = createDataStoreList(totalNodes);
    populateBucket2Node(pr, dses, totalNoOfBuckets);

    populateAllPartitionedRegion(pr, nodes);

    // running the algorithm and getting the list of bucktes to grab
    PartitionedRegionQueryEvaluator evalr =
        new PartitionedRegionQueryEvaluator(pr.getSystem(), pr, null, null, null, null,
            bucketsToQuery);
    Map n2bMap = null;
    try {
      n2bMap = evalr.buildNodeToBucketMap();
    } catch (Exception ignored) {

    }
    ArrayList buckList = new ArrayList();
    for (final Object o : n2bMap.entrySet()) {
      Map.Entry entry = (Map.Entry) o;
      if (entry.getValue() != null) {
        buckList.addAll((List) entry.getValue());
      }
    }
    // checking size of the two lists
    assertEquals("Unexpected number of buckets", totalNoOfBuckets, buckList.size());
    for (int i = 0; i < totalNoOfBuckets; i++) {
      assertTrue(" Bucket with Id = " + i + " not present in bucketList.",
          buckList.contains(i));
    }

    pr.destroyRegion();
  }
Test for the helper method getNodeToBucketMap.
geode-core/src/integrationTest/java/org/apache/geode/internal/cache/PartitionedRegionQueryEvaluatorIntegrationTest.java