@Test
  public void testFindBestRemoveRemovesFromMoreLoadedMember() {
    Bucket bucket = mock(Bucket.class);
    Bucket bucket2 = mock(Bucket.class);
    AddressComparor addressComparor = mock(AddressComparor.class);

    PartitionedRegionLoadModel model = new PartitionedRegionLoadModel(bucketOperator, 2, 6,
        addressComparor, Collections.emptySet(), partitionedRegion);
    InternalDistributedMember memberId = mock(InternalDistributedMember.class);
    InternalDistributedMember otherMemberId = mock(InternalDistributedMember.class);
    doReturn(true).when(addressComparor).enforceUniqueZones();
    doReturn(true).when(addressComparor).areSameZone(
        ArgumentMatchers.any(InternalDistributedMember.class),
        ArgumentMatchers.any(InternalDistributedMember.class));
    Set<Member> membersHostingBucket = new HashSet<>();
    Member halfLoadedMember = new Member(addressComparor, memberId, 100, 100, false, false);
    Member fullyLoadedMember = new Member(addressComparor, otherMemberId, 100, 100, false, false);

    when(bucket.getPrimary()).thenReturn(halfLoadedMember);
    when(bucket.getBytes()).thenReturn(10000000L);
    when(bucket.getLoad()).thenReturn(50.0f);
    when(bucket2.getPrimary()).thenReturn(fullyLoadedMember);
    when(bucket2.getBytes()).thenReturn(10000000L);
    when(bucket2.getLoad()).thenReturn(50.0f);

    fullyLoadedMember.addBucket(bucket);
    fullyLoadedMember.addBucket(bucket2);
    halfLoadedMember.addBucket(bucket);
    membersHostingBucket.add(halfLoadedMember);
    membersHostingBucket.add(fullyLoadedMember);

    when(bucket.getMembersHosting()).thenReturn(membersHostingBucket);

    when(clusterDistributionManager.getRedundancyZone(memberId)).thenReturn("zoneA");
    when(clusterDistributionManager.getRedundancyZone(otherMemberId)).thenReturn("zoneA");

    when(bucket.getMembersHosting()).thenReturn(membersHostingBucket);

    org.apache.geode.internal.cache.partitioned.rebalance.model.Move bestRemove =
        model.findBestRemove(bucket);

    assertThat(bestRemove).isNotNull();
    assertThat(bestRemove.getTarget()).isEqualTo(fullyLoadedMember);
  }
Test to make sure than redundancy satisfaction ignores offline members
geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/rebalance/PartitionedRegionLoadModelJUnitTest.java