### Question:
TableLoadBalancer extends TabletBalancer { @Override public long balance(SortedMap<TServerInstance,TabletServerStatus> current, Set<KeyExtent> migrations, List<TabletMigration> migrationsOut) { long minBalanceTime = 5 * 1000; TableOperations t = getTableOperations(); if (t == null) return minBalanceTime; for (String s : t.tableIdMap().values()) { ArrayList<TabletMigration> newMigrations = new ArrayList<>(); long tableBalanceTime = getBalancerForTable(TableId.of(s)).balance(current, migrations, newMigrations); if (tableBalanceTime < minBalanceTime) minBalanceTime = tableBalanceTime; migrationsOut.addAll(newMigrations); } return minBalanceTime; }  @Override void getAssignments(SortedMap<TServerInstance,TabletServerStatus> current,
      Map<KeyExtent,TServerInstance> unassigned, Map<KeyExtent,TServerInstance> assignments); @Override long balance(SortedMap<TServerInstance,TabletServerStatus> current,
      Set<KeyExtent> migrations, List<TabletMigration> migrationsOut);  }### Answer:
@Test public void test() { final ServerContext context = createMockContext(); TableConfiguration conf = createMock(TableConfiguration.class); expect(conf.get(Property.TABLE_CLASSPATH)).andReturn("").anyTimes(); expect(context.getTableConfiguration(EasyMock.anyObject())).andReturn(conf).anyTimes(); replay(context, conf); String t1Id = TABLE_ID_MAP.get("t1"), t2Id = TABLE_ID_MAP.get("t2"), t3Id = TABLE_ID_MAP.get("t3"); state = new TreeMap<>(); TServerInstance svr = mkts("10.0.0.1", "0x01020304"); state.put(svr, status(t1Id, 10, t2Id, 10, t3Id, 10)); Set<KeyExtent> migrations = Collections.emptySet(); List<TabletMigration> migrationsOut = new ArrayList<>(); TableLoadBalancer tls = new TableLoadBalancer(); tls.init(context); tls.balance(state, migrations, migrationsOut); assertEquals(0, migrationsOut.size()); state.put(mkts("10.0.0.2", "0x02030405"), status()); tls = new TableLoadBalancer(); tls.init(context); tls.balance(state, migrations, migrationsOut); int count = 0; Map<TableId,Integer> movedByTable = new HashMap<>(); movedByTable.put(TableId.of(t1Id), 0); movedByTable.put(TableId.of(t2Id), 0); movedByTable.put(TableId.of(t3Id), 0); for (TabletMigration migration : migrationsOut) { if (migration.oldServer.equals(svr)) { count++; } TableId key = migration.tablet.tableId(); movedByTable.put(key, movedByTable.get(key) + 1); } assertEquals(15, count); for (Integer moved : movedByTable.values()) { assertEquals(5, moved.intValue()); } }