@Test
  public void testOOBWhenBelowSizeThreshold() {
    final long totalSize = 1000L;
    final Map<PartitionedRegion, InternalPRInfo> details = new HashMap<>();
    when(mockCacheFacade.getRegionMemberDetails()).thenReturn(details);
    when(mockCacheFacade.getTotalDataSize(details)).thenReturn(totalSize);
    // First Run: half of threshold limit. Second Run: nothing to transfer.
    when(mockCacheFacade.getTotalTransferSize())
        .thenReturn((AutoBalancer.DEFAULT_SIZE_THRESHOLD_PERCENT * totalSize / 100) / 2, 0L);

    AutoBalancer balancer = new AutoBalancer(null, null, null, mockCacheFacade);
    Properties config = getBasicConfig();
    config.put(AutoBalancer.MINIMUM_SIZE, "10");
    balancer.initialize(null, config);
    SizeBasedOOBAuditor auditor = (SizeBasedOOBAuditor) balancer.getOOBAuditor();

    // First run
    assertThat(auditor.needsRebalancing()).isFalse();

    // Second run
    assertThat(auditor.needsRebalancing()).isFalse();
  }
UnitTests for AutoBalancer. All collaborators should be mocked.
geode-rebalancer/src/test/java/org/apache/geode/cache/util/AutoBalancerJUnitTest.java