@Test
public void testGivenEndpoint() throws IOException {

    DiscoveredServiceWorkItemHandler handler = new TestDiscoveredServiceWorkItemHandler("test", "http://testhost:9000"); 
    
    WorkItem workItem = Mockito.mock(WorkItem.class);
    when(workItem.getParameters()).thenReturn(Collections.singletonMap("service", "test"));
    
    Call call = mock(Call.class);
    ResponseBody body = new ResponseBody() {
        private String content = "{\"test\" : \"fake\"}";
        @Override
        public BufferedSource source() {
            Buffer b = new Buffer();
            b.write(content.getBytes());
            return b;
        }
        
        @Override
        public MediaType contentType() {
            return MediaType.parse("application/json");
        }
        
        @Override
        public long contentLength() {
            return content.length();
        }
    };
    Response response = new Response.Builder().body(body).protocol(Protocol.HTTP_1_1).message("test").request(new Request.Builder().url("http://localhost:9000").build()).code(200).build();
            
 
    when(call.execute()).thenReturn(response);
    when(httpClient.newCall(any())).thenReturn(call);
    
    Map<String, Object> results = handler.discoverAndCall(workItem, "", "service", HttpMethods.POST);
    
    assertThat(results).isNotNull().containsKey("test").containsValue("fake");
}