@Test
public void testUpdateStatistics(TestContext context){

    Async async = context.async();
    String circuitHash = "anotherCircuitHash";
    PatternAndCircuitHash patternAndCircuitHash = buildPatternAndCircuitHash("/anotherCircuit", circuitHash);
    context.assertFalse(jedis.exists(key(circuitHash, QueueResponseType.SUCCESS)));
    context.assertFalse(jedis.exists(key(circuitHash, QueueResponseType.FAILURE)));
    context.assertFalse(jedis.exists(STORAGE_OPEN_CIRCUITS));
    int errorThreshold = 50;
    long entriesMaxAgeMS = 10;
    long minQueueSampleCount = 1;
    long maxQueueSampleCount = 3;
    storage.updateStatistics(patternAndCircuitHash, "req_1", 1, errorThreshold, entriesMaxAgeMS, minQueueSampleCount, maxQueueSampleCount, QueueResponseType.SUCCESS).setHandler(event -> {
        context.assertTrue(event.succeeded());
        context.assertTrue(jedis.exists(key(circuitHash, QueueResponseType.SUCCESS)));
        context.assertFalse(jedis.exists(key(circuitHash, QueueResponseType.FAILURE)));
        context.assertEquals(1L, jedis.zcard(key(circuitHash, QueueResponseType.SUCCESS)));
        context.assertEquals(UpdateStatisticsResult.OK, event.result());
        storage.updateStatistics(patternAndCircuitHash, "req_2", 2, errorThreshold, entriesMaxAgeMS, minQueueSampleCount, maxQueueSampleCount, QueueResponseType.SUCCESS).setHandler(event1 -> {
            context.assertFalse(jedis.exists(key(circuitHash, QueueResponseType.FAILURE)));
            context.assertEquals(2L, jedis.zcard(key(circuitHash, QueueResponseType.SUCCESS)));
            context.assertEquals(UpdateStatisticsResult.OK, event1.result());
            storage.updateStatistics(patternAndCircuitHash, "req_3", 3, errorThreshold, entriesMaxAgeMS, minQueueSampleCount, maxQueueSampleCount, QueueResponseType.SUCCESS).setHandler(event2 -> {
                context.assertFalse(jedis.exists(key(circuitHash, QueueResponseType.FAILURE)));
                context.assertEquals(3L, jedis.zcard(key(circuitHash, QueueResponseType.SUCCESS)));
                context.assertEquals(UpdateStatisticsResult.OK, event2.result());
                storage.updateStatistics(patternAndCircuitHash, "req_4", 4, errorThreshold, entriesMaxAgeMS, minQueueSampleCount, maxQueueSampleCount, QueueResponseType.SUCCESS).setHandler(event3 -> {
                    context.assertFalse(jedis.exists(key(circuitHash, QueueResponseType.FAILURE)));
                    context.assertEquals(3L, jedis.zcard(key(circuitHash, QueueResponseType.SUCCESS)));
                    context.assertEquals(UpdateStatisticsResult.OK, event3.result());
                    async.complete();
                });
            });
        });
    });
}