@Test
  public void testBalancerAfterContainerSameCustomAssignment() {
    Set<TaskModel> taskModels = generateTaskModels(9);

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

    GrouperMetadataImpl grouperMetadata = new GrouperMetadataImpl(new HashMap<>(), new HashMap<>(), new HashMap<>(), prevTaskToContainerMapping);
    Set<ContainerModel> containers = new GroupByContainerCount(2).group(taskModels, grouperMetadata);

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

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

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

Before:
 C0  C1
--------
 T0  T6
 T1  T7
 T2  T8
 T3
 T4
 T5

 After:
 C0  C1
--------
 T0  T6
 T1  T7
 T2  T8
 T3
 T4
 T5
samza-core/src/test/java/org/apache/samza/container/grouper/task/TestGroupByContainerCount.java