@Test public void shouldUpdateReportExecution() throws Exception { MockResponse response = MockResponseFactory.create204(); mWebMockRule.enqueue(response); restApiUnderTest.updateReportExecution(EXEC_ID, PARAMS); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request, containsHeader("Accept", "application/json; charset=UTF-8")); assertThat(request, hasPath("/rest_v2/reportExecutions/f3a9805a-4089-4b53-b9e9-b54752f91586/parameters")); assertThat(request, hasBody("[{\"name\":\"key\",\"value\":[\"value\"]}]")); assertThat(request, wasMethod("POST")); }
public boolean updateReportExecution(@NotNull String executionId, @NotNull List<ReportParameter> params) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(params, "Execution params should not be null"); Utils.checkArgument(params.isEmpty(), "Execution params should not be empty"); HttpUrl url = mNetworkClient.getBaseUrl() .resolve("rest_v2/reportExecutions") .newBuilder() .addPathSegment(executionId) .addPathSegment("parameters") .build(); RequestBody jsonRequestBody = mNetworkClient.createJsonRequestBody(params); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .post(jsonRequestBody) .url(url) .build(); com.squareup.okhttp.Response response = mNetworkClient.makeCall(request); int status = response.code(); return status == 204; }
ReportExecutionRestApi { public boolean updateReportExecution(@NotNull String executionId, @NotNull List<ReportParameter> params) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(params, "Execution params should not be null"); Utils.checkArgument(params.isEmpty(), "Execution params should not be empty"); HttpUrl url = mNetworkClient.getBaseUrl() .resolve("rest_v2/reportExecutions") .newBuilder() .addPathSegment(executionId) .addPathSegment("parameters") .build(); RequestBody jsonRequestBody = mNetworkClient.createJsonRequestBody(params); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .post(jsonRequestBody) .url(url) .build(); com.squareup.okhttp.Response response = mNetworkClient.makeCall(request); int status = response.code(); return status == 204; } }
ReportExecutionRestApi { public boolean updateReportExecution(@NotNull String executionId, @NotNull List<ReportParameter> params) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(params, "Execution params should not be null"); Utils.checkArgument(params.isEmpty(), "Execution params should not be empty"); HttpUrl url = mNetworkClient.getBaseUrl() .resolve("rest_v2/reportExecutions") .newBuilder() .addPathSegment(executionId) .addPathSegment("parameters") .build(); RequestBody jsonRequestBody = mNetworkClient.createJsonRequestBody(params); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .post(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 updateReportExecution(@NotNull String executionId, @NotNull List<ReportParameter> params) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(params, "Execution params should not be null"); Utils.checkArgument(params.isEmpty(), "Execution params should not be empty"); HttpUrl url = mNetworkClient.getBaseUrl() .resolve("rest_v2/reportExecutions") .newBuilder() .addPathSegment(executionId) .addPathSegment("parameters") .build(); RequestBody jsonRequestBody = mNetworkClient.createJsonRequestBody(params); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .post(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 updateReportExecution(@NotNull String executionId, @NotNull List<ReportParameter> params) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(params, "Execution params should not be null"); Utils.checkArgument(params.isEmpty(), "Execution params should not be empty"); HttpUrl url = mNetworkClient.getBaseUrl() .resolve("rest_v2/reportExecutions") .newBuilder() .addPathSegment(executionId) .addPathSegment("parameters") .build(); RequestBody jsonRequestBody = mNetworkClient.createJsonRequestBody(params); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .post(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);  }