@Test public void responseShouldBeCancelledIfResponseIs200() throws Exception { MockResponse response = MockResponseFactory.create200().setBody(cancelledResponse.asString()); mWebMockRule.enqueue(response); boolean cancelled = restApiUnderTest.cancelReportExecution("any_id"); assertThat(cancelled, is(true)); }
public boolean cancelReportExecution(@NotNull String executionId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); HttpUrl url = mNetworkClient.getBaseUrl() .resolve("rest_v2/reportExecutions") .newBuilder() .addPathSegment(executionId) .addPathSegment("status") .build(); RequestBody jsonRequestBody = mNetworkClient.createJsonRequestBody(ExecutionStatus.cancelledStatus()); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .put(jsonRequestBody) .url(url) .build(); com.squareup.okhttp.Response response = mNetworkClient.makeCall(request); int status = response.code(); return status != 204; }
ReportExecutionRestApi { public boolean cancelReportExecution(@NotNull String executionId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); HttpUrl url = mNetworkClient.getBaseUrl() .resolve("rest_v2/reportExecutions") .newBuilder() .addPathSegment(executionId) .addPathSegment("status") .build(); RequestBody jsonRequestBody = mNetworkClient.createJsonRequestBody(ExecutionStatus.cancelledStatus()); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .put(jsonRequestBody) .url(url) .build(); com.squareup.okhttp.Response response = mNetworkClient.makeCall(request); int status = response.code(); return status != 204; } }
ReportExecutionRestApi { public boolean cancelReportExecution(@NotNull String executionId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); HttpUrl url = mNetworkClient.getBaseUrl() .resolve("rest_v2/reportExecutions") .newBuilder() .addPathSegment(executionId) .addPathSegment("status") .build(); RequestBody jsonRequestBody = mNetworkClient.createJsonRequestBody(ExecutionStatus.cancelledStatus()); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .put(jsonRequestBody) .url(url) .build(); com.squareup.okhttp.Response response = mNetworkClient.makeCall(request); int status = response.code(); return status != 204; } ReportExecutionRestApi(NetworkClient networkClient); }
ReportExecutionRestApi { public boolean cancelReportExecution(@NotNull String executionId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); HttpUrl url = mNetworkClient.getBaseUrl() .resolve("rest_v2/reportExecutions") .newBuilder() .addPathSegment(executionId) .addPathSegment("status") .build(); RequestBody jsonRequestBody = mNetworkClient.createJsonRequestBody(ExecutionStatus.cancelledStatus()); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .put(jsonRequestBody) .url(url) .build(); com.squareup.okhttp.Response response = mNetworkClient.makeCall(request); int status = response.code(); return status != 204; } ReportExecutionRestApi(NetworkClient networkClient); @NotNull ReportExecutionDescriptor runReportExecution(@NotNull ReportExecutionRequestOptions executionOptions); @NotNull ReportExecutionDescriptor requestReportExecutionDetails(@NotNull String executionId); @NotNull ExecutionStatus requestReportExecutionStatus(@NotNull String executionId); boolean cancelReportExecution(@NotNull String executionId); boolean updateReportExecution(@NotNull String executionId,
                                         @NotNull List<ReportParameter> params); }
ReportExecutionRestApi { public boolean cancelReportExecution(@NotNull String executionId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); HttpUrl url = mNetworkClient.getBaseUrl() .resolve("rest_v2/reportExecutions") .newBuilder() .addPathSegment(executionId) .addPathSegment("status") .build(); RequestBody jsonRequestBody = mNetworkClient.createJsonRequestBody(ExecutionStatus.cancelledStatus()); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .put(jsonRequestBody) .url(url) .build(); com.squareup.okhttp.Response response = mNetworkClient.makeCall(request); int status = response.code(); return status != 204; } ReportExecutionRestApi(NetworkClient networkClient); @NotNull ReportExecutionDescriptor runReportExecution(@NotNull ReportExecutionRequestOptions executionOptions); @NotNull ReportExecutionDescriptor requestReportExecutionDetails(@NotNull String executionId); @NotNull ExecutionStatus requestReportExecutionStatus(@NotNull String executionId); boolean cancelReportExecution(@NotNull String executionId); boolean updateReportExecution(@NotNull String executionId,
                                         @NotNull List<ReportParameter> params);  }