@Test public void bodyParameterShouldNotBeEmptyForExecutionUpdate() throws Exception { mExpectedException.expect(IllegalArgumentException.class); mExpectedException.expectMessage("Execution params should not be empty"); restApiUnderTest.updateReportExecution("any_id", Collections.<ReportParameter>emptyList()); }
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);  }