@Test
public void testReallocate() {

    final Allocations allocations = new Allocations(Lists.<Allocation>newArrayList());
    // 0123456789
    // AAAAABBBBB
    allocations.allocate(control, 5);
    allocations.allocate(withLogin, 5);
    // 0123456789
    // AAAAAAAABB
    allocations.reallocate(withLogin, control, 3);
    assertEquals(
        "reallocation should have partly replaced second allocation and merged with first allocation",
        Lists.newArrayList(
            new Allocation(control, 0, 8),
            new Allocation(withLogin, 8, 2)
        ),
        allocations.getAllocations()
    );
}