@Test
public void testResponseFromCacheDoesNotGetLatencyTracked() {

    HystrixCommandKey key = HystrixCommandKey.Factory.asKey("CMD-Latency-G");
    stream = RollingCommandLatencyDistributionStream.getInstance(key, 10, 100);
    stream.startCachingStreamValuesIfUnstarted();
    //should get 1 SUCCESS and 1 RESPONSE_FROM_CACHE
    List<Command> commands = Command.getCommandsWithResponseFromCache(groupKey, key);
    final CountDownLatch latch = new CountDownLatch(1);
    stream.observe().take(10).subscribe(new Subscriber<CachedValuesHistogram>() {
        @Override
        public void onCompleted() {
            latch.countDown();
        }
        @Override
        public void onError(Throwable e) {
            fail(e.getMessage());
        }
        @Override
        public void onNext(CachedValuesHistogram distribution) {
            System.out.println(System.currentTimeMillis() + " : " + Thread.currentThread().getName() + " Received distribution with count : " + distribution.getTotalCount() + " and mean : " + distribution.getMean());
            assertTrue(distribution.getTotalCount() <= 1);
        }
    });
    for (Command cmd: commands) {
        cmd.observe();
    }
    try {
        assertTrue(latch.await(10000, TimeUnit.MILLISECONDS));
    } catch (InterruptedException ex) {
        fail("Interrupted ex");
    }
    assertEquals(1, stream.getLatest().getTotalCount());
    assertBetween(0, 30, stream.getLatestMean());
    System.out.println("ReqLog : " + HystrixRequestLog.getCurrentRequest().getExecutedCommandsAsString());
}