ContainerHeartbeatClient { public ContainerHeartbeatResponse requestHeartbeat() { ObjectMapper mapper = new ObjectMapper(); ContainerHeartbeatResponse response; String reply = ""; try { reply = httpGet(new URL(heartbeatEndpoint)); LOG.debug("Container Heartbeat got response {}", reply); response = mapper.readValue(reply, ContainerHeartbeatResponse.class); return response; } catch (Exception e) { LOG.error("Error in container heartbeat to JobCoordinator.", e); } LOG.error("Container heartbeat expired"); response = new ContainerHeartbeatResponse(false); return response; } ContainerHeartbeatClient(String coordinatorUrl, String executionEnvContainerId); ContainerHeartbeatResponse requestHeartbeat();  }
@Test public void testClientResponseForHeartbeatAlive() throws IOException { client.setHttpOutput("{\"alive\": true}"); ContainerHeartbeatResponse response = client.requestHeartbeat(); Assert.assertTrue(response.isAlive()); }
@Test public void testClientResponseForHeartbeatDead() throws IOException { client.setHttpOutput("{\"alive\": false}"); ContainerHeartbeatResponse response = client.requestHeartbeat(); Assert.assertFalse(response.isAlive()); }
@Test public void testClientResponseOnBadRequest() throws IOException { client.shouldThrowException(true); ContainerHeartbeatResponse response = client.requestHeartbeat(); Assert.assertFalse(response.isAlive()); }