@Test
public void testErrorHandlingWhenMapToResponseFails() throws Exception {

    TestCollapserTimer timer = new TestCollapserTimer();
    HystrixCollapser<List<String>, String, String> collapser1 = new TestRequestCollapserWithFaultyMapToResponse(timer, "1");
    Future<String> response1 = collapser1.queue();
    Future<String> response2 = new TestRequestCollapserWithFaultyMapToResponse(timer, "2").queue();
    timer.incrementTime(10); // let time pass that equals the default delay/period
    try {
        response1.get(1000, TimeUnit.MILLISECONDS);
        fail("we should have received an exception");
    } catch (ExecutionException e) {
        // what we expect
    }
    try {
        response2.get(1000, TimeUnit.MILLISECONDS);
        fail("we should have received an exception");
    } catch (ExecutionException e) {
        // what we expect
    }
    // the batch failed so no executions
    // but it still executed the command once
    assertEquals(1, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
    Iterator<HystrixInvokableInfo<?>> cmdIterator = HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().iterator();
    assertEquals(2, cmdIterator.next().getNumberCollapsed());
}