/**
   * Run the command via {@link com.netflix.hystrix.HystrixCommand#observe()}, let the {@link
   * rx.Observable} terminal states unblock a {@link java.util.concurrent.CountDownLatch} and then
   * assert
   *
   * @param command command to run
   * @param assertion assertions to check
   * @param isSuccess should the command succeed?
   */
  protected void assertNonBlockingObserve(C command, Action1<C> assertion, boolean isSuccess) {
    System.out.println(
        "Running command.observe(), awaiting terminal state of Observable, then running assertions...");
    final CountDownLatch latch = new CountDownLatch(1);

    Observable<Integer> o = command.observe();

    o.subscribe(
        new Subscriber<Integer>() {
          @Override
          public void onCompleted() {
            latch.countDown();
          }

          @Override
          public void onError(Throwable e) {
            latch.countDown();
          }

          @Override
          public void onNext(Integer i) {
            // do nothing
          }
        });

    try {
      latch.await(3, TimeUnit.SECONDS);
      assertion.call(command);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }

    if (isSuccess) {
      try {
        o.toList().toBlocking().single();
      } catch (Exception ex) {
        throw new RuntimeException(ex);
      }
    } else {
      try {
        o.toList().toBlocking().single();
        fail("Expected a command failure!");
      } catch (Exception ex) {
        System.out.println("Received expected ex : " + ex);
        ex.printStackTrace();
      }
    }
  }
 @Override
 public Observable<List<CachedValuesHistogram>> call(
     Observable<CachedValuesHistogram> windowOf2) {
   return windowOf2.toList();
 }