@Test
public void testRequestsOverTime() throws Exception {

    TestCollapserTimer timer = new TestCollapserTimer();
    HystrixCollapser<List<String>, String, String> collapser1 = new TestRequestCollapser(timer, 1);
    Future<String> response1 = collapser1.queue();
    timer.incrementTime(5);
    Future<String> response2 = new TestRequestCollapser(timer, 2).queue();
    timer.incrementTime(8);
    // should execute here
    Future<String> response3 = new TestRequestCollapser(timer, 3).queue();
    timer.incrementTime(6);
    Future<String> response4 = new TestRequestCollapser(timer, 4).queue();
    timer.incrementTime(8);
    // should execute here
    Future<String> response5 = new TestRequestCollapser(timer, 5).queue();
    timer.incrementTime(10);
    // should execute here
    // wait for all tasks to complete
    assertEquals("1", response1.get(1000, TimeUnit.MILLISECONDS));
    assertEquals("2", response2.get(1000, TimeUnit.MILLISECONDS));
    assertEquals("3", response3.get(1000, TimeUnit.MILLISECONDS));
    assertEquals("4", response4.get(1000, TimeUnit.MILLISECONDS));
    assertEquals("5", response5.get(1000, TimeUnit.MILLISECONDS));
    assertEquals(3, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
    Iterator<HystrixInvokableInfo<?>> cmdIterator = HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().iterator();
    assertEquals(2, cmdIterator.next().getNumberCollapsed());
    assertEquals(2, cmdIterator.next().getNumberCollapsed());
    assertEquals(1, cmdIterator.next().getNumberCollapsed());
}