@Test
  public void testFacadeCollectMemberDetails2Regions() {
    final LoadProbe mockProbe = mock(LoadProbe.class);
    final GemFireCacheImpl mockCache = mock(GemFireCacheImpl.class);
    final InternalResourceManager mockRM = mock(InternalResourceManager.class);
    final PartitionedRegion mockR1 = mock(PartitionedRegion.class, "r1");
    final PartitionedRegion mockR2 = mock(PartitionedRegion.class, "r2");
    final PRHARedundancyProvider mockRedundancyProviderR1 =
        mock(PRHARedundancyProvider.class, "prhaR1");
    final InternalPRInfo mockR1PRInfo = mock(InternalPRInfo.class, "prInforR1");
    final PRHARedundancyProvider mockRedundancyProviderR2 =
        mock(PRHARedundancyProvider.class, "prhaR2");
    final InternalPRInfo mockR2PRInfo = mock(InternalPRInfo.class, "prInforR2");
    final HashSet<PartitionedRegion> regions = new HashSet<>();
    regions.add(mockR1);
    regions.add(mockR2);

    when(mockCache.isClosed()).thenReturn(false);
    when(mockCache.getPartitionedRegions()).thenReturn(regions);
    when(mockCache.getResourceManager()).thenReturn(mockRM);
    when(mockCache.getInternalResourceManager()).thenReturn(mockRM);
    when(mockRM.getLoadProbe()).thenReturn(mockProbe);
    when(mockR1.getRedundancyProvider()).thenReturn(mockRedundancyProviderR1);
    when(mockR2.getRedundancyProvider()).thenReturn(mockRedundancyProviderR2);
    when(mockRedundancyProviderR1.buildPartitionedRegionInfo(eq(true), any(LoadProbe.class)))
        .thenReturn(mockR1PRInfo);
    when(mockRedundancyProviderR2.buildPartitionedRegionInfo(eq(true), any(LoadProbe.class)))
        .thenReturn(mockR2PRInfo);

    GeodeCacheFacade facade = new GeodeCacheFacade(mockCache);
    Map<PartitionedRegion, InternalPRInfo> map = facade.getRegionMemberDetails();
    assertThat(map).isNotNull();
    assertThat(map.size()).isEqualTo(2);
    assertThat(map.get(mockR1)).isEqualTo(mockR1PRInfo);
    assertThat(map.get(mockR2)).isEqualTo(mockR2PRInfo);
  }
UnitTests for AutoBalancer. All collaborators should be mocked.
geode-rebalancer/src/test/java/org/apache/geode/cache/util/AutoBalancerJUnitTest.java