PlatformResource { @GET @Path("health") @ApiOperation(value = "Get platform health status", response = PlatformHealthDTO.class, authorizations = {}) @ApiResponses(value = { @ApiResponse(code = 200, message = "Server health is ok. A JSON object is sent in the body"), @ApiResponse(code = 500, message = "Server health is ko or partial") }) @Produces(MediaType.APPLICATION_JSON) public PlatformHealthDTO getPlatformHealthStatus() throws PlatformHealthException { long before=System.currentTimeMillis(); platformHealthManager.runHealthCheck(); long after=System.currentTimeMillis(); PlatformHealthDTO platformHealthDTO = new PlatformHealthDTO(); platformHealthDTO.setStatus("ok"); platformHealthDTO.setExecutionTime(after-before); return platformHealthDTO; } PlatformResource(); @GET @Path("health") @ApiOperation(value = "Get platform health status", response = PlatformHealthDTO.class, authorizations = {}) @ApiResponses(value = { @ApiResponse(code = 200, message = "Server health is ok. A JSON object is sent in the body"), @ApiResponse(code = 500, message = "Server health is ko or partial") }) @Produces(MediaType.APPLICATION_JSON) PlatformHealthDTO getPlatformHealthStatus();  }
@Test public void getPlatformHealthStatusTest() throws ApplicationException { Mockito.doNothing().when(platformHealthManager).runHealthCheck(); PlatformHealthDTO platformHealthStatus = platformResource.getPlatformHealthStatus(); Assert.assertEquals("ok", platformHealthStatus.getStatus()); Mockito.doThrow(new PlatformHealthException("ooops")).when(platformHealthManager).runHealthCheck(); try { platformResource.getPlatformHealthStatus(); Assert.fail("Should have thrown"); } catch (PlatformHealthException e){ Assert.assertEquals("ooops",e.getMessage()); } }