@Test
  public void testFacadeTotalBytes2Regions() {
    final PartitionedRegion mockR1 = mock(PartitionedRegion.class, "r1");
    final InternalPRInfo mockR1PRInfo = mock(InternalPRInfo.class, "prInforR1");
    final PartitionMemberInfo mockR1M1Info = mock(PartitionMemberInfo.class, "r1M1");
    final PartitionMemberInfo mockR1M2Info = mock(PartitionMemberInfo.class, "r1M2");
    final HashSet<PartitionMemberInfo> r1Members = new HashSet<>();
    r1Members.add(mockR1M1Info);
    r1Members.add(mockR1M2Info);
    when(mockR1PRInfo.getPartitionMemberInfo()).thenReturn(r1Members);
    when(mockR1M1Info.getSize()).thenReturn(123L);
    when(mockR1M2Info.getSize()).thenReturn(74L);

    final PartitionedRegion mockR2 = mock(PartitionedRegion.class, "r2");
    final InternalPRInfo mockR2PRInfo = mock(InternalPRInfo.class, "prInforR2");
    final PartitionMemberInfo mockR2M1Info = mock(PartitionMemberInfo.class, "r2M1");
    final HashSet<PartitionMemberInfo> r2Members = new HashSet<>();
    r2Members.add(mockR2M1Info);
    when(mockR2PRInfo.getPartitionMemberInfo()).thenReturn(r2Members);
    when(mockR2M1Info.getSize()).thenReturn(3475L);

    final Map<PartitionedRegion, InternalPRInfo> details = new HashMap<>();
    details.put(mockR1, mockR1PRInfo);
    details.put(mockR2, mockR2PRInfo);

    GeodeCacheFacade facade = new GeodeCacheFacade() {
      @Override
      public Map<PartitionedRegion, InternalPRInfo> getRegionMemberDetails() {
        return details;
      }
    };

    assertThat(facade.getTotalDataSize(details)).isEqualTo(123 + 74 + 3475);
    verify(mockR1M1Info, atLeastOnce()).getSize();
    verify(mockR1M2Info, atLeastOnce()).getSize();
    verify(mockR2M1Info, atLeastOnce()).getSize();
  }
UnitTests for AutoBalancer. All collaborators should be mocked.
geode-rebalancer/src/test/java/org/apache/geode/cache/util/AutoBalancerJUnitTest.java