Ejemplo n.º 1
0
 /** Utility method for creating {@link HystrixCommandMetrics} for unit tests. */
 private static HystrixCommandMetrics getMetrics(HystrixCommandProperties.Setter properties) {
   return HystrixCommandMetrics.getInstance(
       CommandKeyForUnitTest.KEY_ONE,
       CommandOwnerForUnitTest.OWNER_ONE,
       ThreadPoolKeyForUnitTest.THREAD_POOL_ONE,
       HystrixCommandPropertiesTest.asMock(properties));
 }
  @Test
  public void should_gather_json_metrics() throws Exception {
    HystrixCommandKey hystrixCommandKey = HystrixCommandKey.Factory.asKey("commandKey");
    HystrixCommandMetrics.getInstance(
        hystrixCommandKey,
        HystrixCommandGroupKey.Factory.asKey("commandGroupKey"),
        new HystrixPropertiesCommandDefault(
            hystrixCommandKey, HystrixCommandProperties.defaultSetter()));
    given(this.discoveryClient.getLocalServiceInstance()).willReturn(this.serviceInstance);

    this.hystrixStreamTask.gatherMetrics();

    assertThat(this.hystrixStreamTask.jsonMetrics.isEmpty(), is(false));
  }