@SuppressWarnings({"unchecked", "boxing"})
  @Test
  public void testDoHealthCheckSingleQueueCheckConsumerDown() throws Exception {
    Queue queue = generateQueue("test");
    healthIndicator.addQueueCheck(queue, 10000, 2);

    RabbitQueueProperties properties = new RabbitQueueProperties();
    properties.setConsumerCount(1);
    properties.setMessageCount(5883);
    propertiesManager.request(queue);
    PowerMock.expectLastCall().andReturn(properties);

    PowerMock.replayAll();
    Builder builder = new Builder(Status.OUT_OF_SERVICE);
    healthIndicator.doHealthCheck(builder);
    PowerMock.verifyAll();

    Health health = builder.build();
    Assert.assertEquals(Status.DOWN, health.getStatus());
    Assert.assertNotNull(health.getDetails().get("test"));
    Map<String, Object> details = (Map<String, Object>) health.getDetails().get("test");
    Assert.assertEquals(Status.DOWN.getCode(), details.get("status"));
    Assert.assertEquals(5883, details.get("currentMessageCount"));
    Assert.assertEquals(10000, details.get("maxMessageCount"));
    Assert.assertEquals(1, details.get("currentConsumerCount"));
    Assert.assertEquals(2, details.get("minConsumerCount"));
  }
 @RequestMapping
 @ResponseBody
 public Object invoke(Principal principal) {
   if (!this.delegate.isEnabled()) {
     // Shouldn't happen because the request mapping should not be registered
     return new ResponseEntity<Map<String, String>>(
         Collections.singletonMap("message", "This endpoint is disabled"), HttpStatus.NOT_FOUND);
   }
   Health health = getHealth(principal);
   HttpStatus status = this.statusMapping.get(health.getStatus().getCode());
   if (status != null) {
     return new ResponseEntity<Health>(health, status);
   }
   return health;
 }
  @Test
  public void testDoHealthCheckSingleQueueCheckMetricException() throws Exception {
    Queue queue = generateQueue("test");
    healthIndicator.addQueueCheck(queue, 10000, 2);

    propertiesManager.request(queue);
    PowerMock.expectLastCall().andThrow(new RuntimeException());

    PowerMock.replayAll();
    Builder builder = new Builder(Status.OUT_OF_SERVICE);
    healthIndicator.doHealthCheck(builder);
    PowerMock.verifyAll();

    Health health = builder.build();
    Assert.assertEquals(Status.DOWN, health.getStatus());
    Assert.assertNull(health.getDetails().get("test"));
  }