### Question:
Ec2InstanceDataAccessor implements Ec2InstanceData { @Override public String getInstanceId() { if (instanceId == null) { instanceId = readMetadata("/instance-id"); logger.debug("Retrieved EC2 instance id: [" + instanceId + "]"); } return instanceId; } Ec2InstanceDataAccessor(final HttpClient client); @Override String getInstanceId();  }### Answer:
@Test public void shouldReturnInstanceId_onGetInstanceId() { final String instanceId = Randoms.randomString(); final Response mockResponse = mock(Response.class); when(mockHttpClient.get("/meta-data/instance-id")).thenReturn(mockResponse); when(mockResponse.readEntity(String.class)).thenReturn(instanceId); final Ec2InstanceDataAccessor ec2InstanceDataAccessor = new Ec2InstanceDataAccessor(mockHttpClient); final String actualInstanceId = ec2InstanceDataAccessor.getInstanceId(); assertEquals(instanceId, actualInstanceId); }