@Test
  public void testBalancerAfterContainerSameCustomAssignmentAndContainerIncrease() {
    Set<TaskModel> taskModels = generateTaskModels(6);

    Map<TaskName, String> prevTaskToContainerMapping = new HashMap<>();
    prevTaskToContainerMapping.put(getTaskName(0), "0");
    prevTaskToContainerMapping.put(getTaskName(1), "1");
    prevTaskToContainerMapping.put(getTaskName(2), "1");
    prevTaskToContainerMapping.put(getTaskName(3), "1");
    prevTaskToContainerMapping.put(getTaskName(4), "1");
    prevTaskToContainerMapping.put(getTaskName(5), "1");
    GrouperMetadataImpl grouperMetadata = new GrouperMetadataImpl(new HashMap<>(), new HashMap<>(), new HashMap<>(), prevTaskToContainerMapping);

    Set<ContainerModel> containers = new GroupByContainerCount(3).group(taskModels, grouperMetadata);

    Map<String, ContainerModel> containersMap = new HashMap<>();
    for (ContainerModel container : containers) {
      containersMap.put(container.getId(), container);
    }

    assertEquals(3, containers.size());
    ContainerModel container0 = containersMap.get("0");
    ContainerModel container1 = containersMap.get("1");
    ContainerModel container2 = containersMap.get("2");
    assertNotNull(container0);
    assertNotNull(container1);
    assertNotNull(container2);
    assertEquals("0", container0.getId());
    assertEquals("1", container1.getId());
    assertEquals("2", container2.getId());
    assertEquals(2, container0.getTasks().size());
    assertEquals(2, container1.getTasks().size());
    assertEquals(2, container1.getTasks().size());

    assertTrue(container0.getTasks().containsKey(getTaskName(0)));
    assertTrue(container0.getTasks().containsKey(getTaskName(5)));
    assertTrue(container1.getTasks().containsKey(getTaskName(1)));
    assertTrue(container1.getTasks().containsKey(getTaskName(2)));
    assertTrue(container2.getTasks().containsKey(getTaskName(4)));
    assertTrue(container2.getTasks().containsKey(getTaskName(3)));
  }
Verifies the ability to have a custom task-container mapping that is *deliberately* unbalanced.

Before:
 C0  C1
--------
 T0  T1
     T2
     T3
     T4
     T5

 After:
 C0  C1  C2
------------
 T0  T1  T4
 T5  T2  T3

 The key here is that C0, which is not one of the new containers was under-allocated.
 This is an important case because this scenario, while impossible with GroupByContainerCount.group()
 could occur when the grouper class is switched or if there is a custom mapping.
samza-core/src/test/java/org/apache/samza/container/grouper/task/TestGroupByContainerCount.java