@Test(dataProvider = "failureStatusCodes") public void testGetTaskWrongResponseCode(int status) throws IOException { setupMocks("IGNORED", status); TasksApi tasksApi = new TasksRestApi(this.restClient); try { tasksApi.getTask("foo"); fail("Unexpected success invoking api"); } catch (Exception e) { assertTrue(e.getMessage().contains("HTTP request failed with: " + status)); } }
@Override public Task getTask(final String taskId) throws IOException { String path = getBasePath() + "/" + taskId; Future<HttpResponse> response = this.restClient.performAsync( Method.GET, path, null , null ); try { return parseGetTaskHttpResponse(response.get()); } catch (InterruptedException e) { throw new RuntimeException(e); } catch (ExecutionException e) { throw new RuntimeException(e); } }
TasksRestApi extends ApiBase implements TasksApi { @Override public Task getTask(final String taskId) throws IOException { String path = getBasePath() + "/" + taskId; Future<HttpResponse> response = this.restClient.performAsync( Method.GET, path, null , null ); try { return parseGetTaskHttpResponse(response.get()); } catch (InterruptedException e) { throw new RuntimeException(e); } catch (ExecutionException e) { throw new RuntimeException(e); } } }
TasksRestApi extends ApiBase implements TasksApi { @Override public Task getTask(final String taskId) throws IOException { String path = getBasePath() + "/" + taskId; Future<HttpResponse> response = this.restClient.performAsync( Method.GET, path, null , null ); try { return parseGetTaskHttpResponse(response.get()); } catch (InterruptedException e) { throw new RuntimeException(e); } catch (ExecutionException e) { throw new RuntimeException(e); } } TasksRestApi(RestClient restClient); }
TasksRestApi extends ApiBase implements TasksApi { @Override public Task getTask(final String taskId) throws IOException { String path = getBasePath() + "/" + taskId; Future<HttpResponse> response = this.restClient.performAsync( Method.GET, path, null , null ); try { return parseGetTaskHttpResponse(response.get()); } catch (InterruptedException e) { throw new RuntimeException(e); } catch (ExecutionException e) { throw new RuntimeException(e); } } TasksRestApi(RestClient restClient); @Override String getBasePath(); @Override Task getTask(final String taskId); @Override void getTaskAsync(final String taskId, final FutureCallback<Task> responseCallback); }
TasksRestApi extends ApiBase implements TasksApi { @Override public Task getTask(final String taskId) throws IOException { String path = getBasePath() + "/" + taskId; Future<HttpResponse> response = this.restClient.performAsync( Method.GET, path, null , null ); try { return parseGetTaskHttpResponse(response.get()); } catch (InterruptedException e) { throw new RuntimeException(e); } catch (ExecutionException e) { throw new RuntimeException(e); } } TasksRestApi(RestClient restClient); @Override String getBasePath(); @Override Task getTask(final String taskId); @Override void getTaskAsync(final String taskId, final FutureCallback<Task> responseCallback);  }