@Test
public void testRemoveExpired() throws Exception {

    now = 42;
    Solution<String> solExp1 = new Solution<>(5, 0, bindings, now + 1000L * 10);
    Solution<String> solExp2 = new Solution<>(new Solution<>(5, 1, bindings, now + 1000L * 5), 2);
    Solution<String> solNonExp1 = new Solution<>(new Solution<>(5, 4, bindings, 0), 1);
    Solution<String> solNonExp2 = new Solution<>(new Solution<>(5, 3, bindings, 0), 1);
    // this solution inherits the short lifetime of its second component solution,
    // rather than the unlimited lifetime of the first
    Solution<String> solExp3 = new Solution<>(5,
            new Solution<>(5, 3, bindings, 0),
            new Solution<>(5, 4, bindings, now + 1000L * 20));
    SolutionGroup<String> g = new SolutionGroup<>(bindings);
    g.add(solExp1, now);
    g.add(solExp2, now);
    g.add(solNonExp1, now);
    g.add(solNonExp2, now);
    g.add(solExp3, now);
    assertEquals(5, g.getSolutions().length());
    g.removeExpired(now);
    assertEquals(5, g.getSolutions().length());
    now += 1000L * 6;
    g.removeExpired(now);
    assertEquals(4, g.getSolutions().length());
    now += 1000L * 5;
    g.removeExpired(now);
    assertEquals(3, g.getSolutions().length());
    now += 1000L * 10;
    g.removeExpired(now);
    assertEquals(2, g.getSolutions().length());
}