private GeodeCacheFacade getFacadeForResourceManagerOps(final boolean simulate) throws Exception {
    final GemFireCacheImpl mockCache = mock(GemFireCacheImpl.class);
    final InternalResourceManager mockRM = mock(InternalResourceManager.class);
    final RebalanceFactory mockRebalanceFactory = mock(RebalanceFactory.class);
    final RebalanceOperation mockRebalanceOperation = mock(RebalanceOperation.class);
    final RebalanceResults mockRebalanceResults = mock(RebalanceResults.class);

    when(mockCache.isClosed()).thenReturn(false);
    when(mockCache.getResourceManager()).thenReturn(mockRM);
    when(mockRM.createRebalanceFactory()).thenReturn(mockRebalanceFactory);
    when(mockRebalanceFactory.start()).thenReturn(mockRebalanceOperation);
    when(mockRebalanceFactory.simulate()).thenReturn(mockRebalanceOperation);
    when(mockRebalanceOperation.getResults()).thenReturn(mockRebalanceResults);
    if (simulate) {
      when(mockRebalanceResults.getTotalBucketTransferBytes()).thenReturn(12345L);
    }

    return new GeodeCacheFacade(mockCache);
  }
UnitTests for AutoBalancer. All collaborators should be mocked.
geode-rebalancer/src/test/java/org/apache/geode/cache/util/AutoBalancerJUnitTest.java