Search in sources :

Example 1 with TestRestHelper

use of com.mercedesbenz.sechub.integrationtest.internal.TestRestHelper in project sechub by mercedes-benz.

the class AsPDSUser method markJobAsReadyToStart.

public void markJobAsReadyToStart(UUID jobUUID) {
    TestRestHelper restHelper = getRestHelper();
    TestURLBuilder urlBuilder = getUrlBuilder();
    markJobAsReadyToStart(jobUUID, restHelper, urlBuilder);
}
Also used : TestRestHelper(com.mercedesbenz.sechub.integrationtest.internal.TestRestHelper) TestURLBuilder(com.mercedesbenz.sechub.test.TestURLBuilder)

Example 2 with TestRestHelper

use of com.mercedesbenz.sechub.integrationtest.internal.TestRestHelper in project sechub by mercedes-benz.

the class AsPDSUser method createJobFor.

private String createJobFor(UUID sechubJobUUID, String productId, Map<String, String> params) {
    TestRestHelper restHelper = getRestHelper();
    TestURLBuilder urlBuilder = getUrlBuilder();
    return createJobFor(sechubJobUUID, params, productId, restHelper, urlBuilder);
}
Also used : TestRestHelper(com.mercedesbenz.sechub.integrationtest.internal.TestRestHelper) TestURLBuilder(com.mercedesbenz.sechub.test.TestURLBuilder)

Example 3 with TestRestHelper

use of com.mercedesbenz.sechub.integrationtest.internal.TestRestHelper in project sechub by mercedes-benz.

the class DeveloperAdministration method createTestRestHelperWithErrorHandling.

private TestRestHelper createTestRestHelperWithErrorHandling(ErrorHandler provider, UserContext user, RestHelperTarget restHelperTarget) {
    return new TestRestHelper(user, restHelperTarget) {

        @Override
        protected ResponseErrorHandler createErrorHandler() {
            return new DefaultResponseErrorHandler() {

                @Override
                public void handleError(ClientHttpResponse response) throws IOException {
                    StringBuilder httpResponseProblem = new StringBuilder();
                    String statusText = response.getStatusText();
                    httpResponseProblem.append("status code::");
                    httpResponseProblem.append(response.getStatusCode());
                    if (statusText != null) {
                        httpResponseProblem.append(", text:");
                        httpResponseProblem.append(statusText);
                    }
                    try (BufferedReader br = new BufferedReader(new InputStreamReader(response.getBody(), "UTF-8"))) {
                        String line = null;
                        httpResponseProblem.append(",body:");
                        while ((line = br.readLine()) != null) {
                            httpResponseProblem.append("\n");
                            httpResponseProblem.append(line);
                        }
                    } catch (IOException e) {
                        provider.handleError("failed to read response body:" + e.getMessage());
                    }
                    StringBuilder errorOutput = new StringBuilder();
                    errorOutput.append("******************************************************************\n");
                    errorOutput.append("***                        SENT                                ***\n");
                    errorOutput.append("******************************************************************\n");
                    errorOutput.append("Last URL call:").append(TestRestHelper.getLastUrl());
                    if (TestRestHelper.getLastData() != null) {
                        errorOutput.append("\nWith data:").append(TestRestHelper.getLastData());
                    }
                    errorOutput.append("\n");
                    errorOutput.append("******************************************************************\n");
                    errorOutput.append("***                     RECEIVED                               ***\n");
                    errorOutput.append("******************************************************************\n");
                    errorOutput.append(httpResponseProblem).append("\n");
                    provider.handleError(errorOutput.toString());
                }
            };
        }
    };
}
Also used : TestRestHelper(com.mercedesbenz.sechub.integrationtest.internal.TestRestHelper) DefaultResponseErrorHandler(org.springframework.web.client.DefaultResponseErrorHandler) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) ClientHttpResponse(org.springframework.http.client.ClientHttpResponse)

Aggregations

TestRestHelper (com.mercedesbenz.sechub.integrationtest.internal.TestRestHelper)3 TestURLBuilder (com.mercedesbenz.sechub.test.TestURLBuilder)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 ClientHttpResponse (org.springframework.http.client.ClientHttpResponse)1 DefaultResponseErrorHandler (org.springframework.web.client.DefaultResponseErrorHandler)1