@Test
  public void testCache() {
    HystrixConcurrencyStrategy strategy = HystrixConcurrencyStrategyDefault.getInstance();
    HystrixRequestContext context = HystrixRequestContext.initializeContext();
    try {
      HystrixRequestCache cache1 =
          HystrixRequestCache.getInstance(HystrixCommandKey.Factory.asKey("command1"), strategy);
      cache1.putIfAbsent("valueA", new TestObservable("a1"));
      cache1.putIfAbsent("valueA", new TestObservable("a2"));
      cache1.putIfAbsent("valueB", new TestObservable("b1"));

      HystrixRequestCache cache2 =
          HystrixRequestCache.getInstance(HystrixCommandKey.Factory.asKey("command2"), strategy);
      cache2.putIfAbsent("valueA", new TestObservable("a3"));

      assertEquals("a1", cache1.get("valueA").toBlocking().last());
      assertEquals("b1", cache1.get("valueB").toBlocking().last());

      assertEquals("a3", cache2.get("valueA").toBlocking().last());
      assertNull(cache2.get("valueB"));
    } catch (Exception e) {
      fail("Exception: " + e.getMessage());
      e.printStackTrace();
    } finally {
      context.shutdown();
    }

    context = HystrixRequestContext.initializeContext();
    try {
      // with a new context  the instance should have nothing in it
      HystrixRequestCache cache =
          HystrixRequestCache.getInstance(HystrixCommandKey.Factory.asKey("command1"), strategy);
      assertNull(cache.get("valueA"));
      assertNull(cache.get("valueB"));
    } finally {
      context.shutdown();
    }
  }
 public Command(
     String commandKey,
     boolean shouldFail,
     boolean shouldFailWithBadRequest,
     long latencyToAdd,
     int sleepWindow,
     int requestVolumeThreshold) {
   super(
       Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("Command"))
           .andCommandKey(HystrixCommandKey.Factory.asKey(commandKey))
           .andCommandPropertiesDefaults(
               HystrixCommandPropertiesTest.getUnitTestPropertiesSetter()
                   .withExecutionTimeoutInMilliseconds(500)
                   .withCircuitBreakerRequestVolumeThreshold(requestVolumeThreshold)
                   .withCircuitBreakerSleepWindowInMilliseconds(sleepWindow)));
   this.shouldFail = shouldFail;
   this.shouldFailWithBadRequest = shouldFailWithBadRequest;
   this.latencyToAdd = latencyToAdd;
 }