### Question:
ReportExportRestApi { @NotNull public ExportExecutionDescriptor runExportExecution(@NotNull String executionId, @NotNull ExecutionRequestOptions executionOptions) throws IOException, HttpException { Utils.checkNotNull(executionId, "Execution id should not be null"); Utils.checkNotNull(executionOptions, "Execution options should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reportExecutions") .addPath(executionId) .addPath("exports") .build() .resolve(mNetworkClient.getBaseUrl()); RequestBody jsonRequestBody = mNetworkClient.createJsonRequestBody(executionOptions); 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); return mNetworkClient.deserializeJson(response, ExportExecutionDescriptor.class); } 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);  }### Answer:
@Test public void executionIdShouldNotBeNullForRunRequestExecution() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution id should not be null"); restApiUnderTest.runExportExecution(null, ExecutionRequestOptions.create()); }
@Test public void shouldRunExportExecution() throws Exception { MockResponse mockResponse = MockResponseFactory.create200(); mWebMockRule.enqueue(mockResponse); restApiUnderTest.runExportExecution(EXECUTION_ID, ExecutionRequestOptions.create()); 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/exports")); assertThat(request, wasMethod("POST")); }
@Test public void runExportExecutionShouldThrowRestErrorOn500() throws Exception { mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); restApiUnderTest.runExportExecution("any_id", ExecutionRequestOptions.create()); }
@Test public void bodyShouldNotBeNullForRunRequestExecution() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Execution options should not be null"); restApiUnderTest.runExportExecution("any_id", null); }