@Test public void requestForOutputShouldParseIsFinalHeader() throws Exception { MockResponse mockResponse = MockResponseFactory.create200() .setBody("") .addHeader("output-final", "true"); mWebMockRule.enqueue(mockResponse); ExportOutputResource resource = restApiUnderTest.requestExportOutput(EXECUTION_ID, EXPORT_ID); assertThat(resource.isFinal(), is(true)); }
@NotNull public ExportOutputResource requestExportOutput(@NotNull String executionId, @NotNull String exportId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(exportId, "Export id should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reportExecutions") .addPath(executionId) .addPath("exports") .addPath(exportId) .addPath("outputResource") .build() .resolve(mNetworkClient.getBaseUrl()) .newBuilder() .addQueryParameter("suppressContentDisposition", "true") .build(); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .get() .url(url) .build(); com.squareup.okhttp.Response response = mNetworkClient.makeCall(request); com.squareup.okhttp.Headers headers = response.headers(); RetrofitOutputResource exportInput = new RetrofitOutputResource(response.body()); String pages = headers.get("report-pages"); boolean isFinal = Boolean.parseBoolean(headers.get("output-final")); return ExportOutputResource.create(exportInput, pages, isFinal); }
ReportExportRestApi { @NotNull public ExportOutputResource requestExportOutput(@NotNull String executionId, @NotNull String exportId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(exportId, "Export id should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reportExecutions") .addPath(executionId) .addPath("exports") .addPath(exportId) .addPath("outputResource") .build() .resolve(mNetworkClient.getBaseUrl()) .newBuilder() .addQueryParameter("suppressContentDisposition", "true") .build(); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .get() .url(url) .build(); com.squareup.okhttp.Response response = mNetworkClient.makeCall(request); com.squareup.okhttp.Headers headers = response.headers(); RetrofitOutputResource exportInput = new RetrofitOutputResource(response.body()); String pages = headers.get("report-pages"); boolean isFinal = Boolean.parseBoolean(headers.get("output-final")); return ExportOutputResource.create(exportInput, pages, isFinal); } }
ReportExportRestApi { @NotNull public ExportOutputResource requestExportOutput(@NotNull String executionId, @NotNull String exportId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(exportId, "Export id should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reportExecutions") .addPath(executionId) .addPath("exports") .addPath(exportId) .addPath("outputResource") .build() .resolve(mNetworkClient.getBaseUrl()) .newBuilder() .addQueryParameter("suppressContentDisposition", "true") .build(); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .get() .url(url) .build(); com.squareup.okhttp.Response response = mNetworkClient.makeCall(request); com.squareup.okhttp.Headers headers = response.headers(); RetrofitOutputResource exportInput = new RetrofitOutputResource(response.body()); String pages = headers.get("report-pages"); boolean isFinal = Boolean.parseBoolean(headers.get("output-final")); return ExportOutputResource.create(exportInput, pages, isFinal); } ReportExportRestApi(NetworkClient networkClient); }
ReportExportRestApi { @NotNull public ExportOutputResource requestExportOutput(@NotNull String executionId, @NotNull String exportId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(exportId, "Export id should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reportExecutions") .addPath(executionId) .addPath("exports") .addPath(exportId) .addPath("outputResource") .build() .resolve(mNetworkClient.getBaseUrl()) .newBuilder() .addQueryParameter("suppressContentDisposition", "true") .build(); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .get() .url(url) .build(); com.squareup.okhttp.Response response = mNetworkClient.makeCall(request); com.squareup.okhttp.Headers headers = response.headers(); RetrofitOutputResource exportInput = new RetrofitOutputResource(response.body()); String pages = headers.get("report-pages"); boolean isFinal = Boolean.parseBoolean(headers.get("output-final")); return ExportOutputResource.create(exportInput, pages, isFinal); } ReportExportRestApi(NetworkClient networkClient); @NotNull ExportExecutionDescriptor runExportExecution(@NotNull String executionId,
                                                        @NotNull ExecutionRequestOptions executionOptions); @NotNull ExecutionStatus checkExportExecutionStatus(@NotNull String executionId,
                                                      @NotNull String exportId); @NotNull ExportOutputResource requestExportOutput(@NotNull String executionId,
                                                    @NotNull String exportId); @NotNull OutputResource requestExportAttachment(@NotNull String executionId,
                                                  @NotNull String exportId,
                                                  @NotNull String attachmentId); }
ReportExportRestApi { @NotNull public ExportOutputResource requestExportOutput(@NotNull String executionId, @NotNull String exportId) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(exportId, "Export id should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reportExecutions") .addPath(executionId) .addPath("exports") .addPath(exportId) .addPath("outputResource") .build() .resolve(mNetworkClient.getBaseUrl()) .newBuilder() .addQueryParameter("suppressContentDisposition", "true") .build(); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .get() .url(url) .build(); com.squareup.okhttp.Response response = mNetworkClient.makeCall(request); com.squareup.okhttp.Headers headers = response.headers(); RetrofitOutputResource exportInput = new RetrofitOutputResource(response.body()); String pages = headers.get("report-pages"); boolean isFinal = Boolean.parseBoolean(headers.get("output-final")); return ExportOutputResource.create(exportInput, pages, isFinal); } ReportExportRestApi(NetworkClient networkClient); @NotNull ExportExecutionDescriptor runExportExecution(@NotNull String executionId,
                                                        @NotNull ExecutionRequestOptions executionOptions); @NotNull ExecutionStatus checkExportExecutionStatus(@NotNull String executionId,
                                                      @NotNull String exportId); @NotNull ExportOutputResource requestExportOutput(@NotNull String executionId,
                                                    @NotNull String exportId); @NotNull OutputResource requestExportAttachment(@NotNull String executionId,
                                                  @NotNull String exportId,
                                                  @NotNull String attachmentId);  }