Search in sources :

Example 1 with WsdlTestRequestStepResult

use of com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStepResult in project microcks by microcks.

the class SoapUITestStepsRunner method extractTestReturn.

/**
 */
private TestReturn extractTestReturn(String testStepName, TestStepResult result) {
    int code = TestReturn.FAILURE_CODE;
    if (result.getStatus() == TestStepStatus.OK) {
        code = TestReturn.SUCCESS_CODE;
    }
    String message = null;
    // Re-build request and response.
    Request request = new Request();
    request.setName(testStepName);
    Response response = new Response();
    // SoapUI step result class do not implement a common interface...
    if (result instanceof WsdlTestRequestStepResult) {
        WsdlTestRequestStepResult wtrsr = (WsdlTestRequestStepResult) result;
        request.setContent(wtrsr.getRequestContent());
        request.setHeaders(buildHeaders(wtrsr.getRequestHeaders()));
        response.setContent(wtrsr.getResponseContent());
        response.setHeaders(buildHeaders(wtrsr.getResponseHeaders()));
        message = buildConsolidatedMessage(wtrsr.getMessages());
    }
    if (result instanceof RestRequestStepResult) {
        RestRequestStepResult rrsr = (RestRequestStepResult) result;
        request.setContent(rrsr.getRequestContent());
        request.setHeaders(buildHeaders(rrsr.getRequestHeaders()));
        response.setContent(rrsr.getResponseContent());
        response.setHeaders(buildHeaders(rrsr.getResponseHeaders()));
        message = buildConsolidatedMessage(rrsr.getMessages());
        // or if endpoint is not reached. Consider 404 as a failure in our case.
        if (result.getStatus() == TestStepStatus.UNKNOWN) {
            if (rrsr.getResponse().getStatusCode() == 404) {
                code = TestReturn.FAILURE_CODE;
            } else {
                code = TestReturn.SUCCESS_CODE;
            }
        }
    }
    return new TestReturn(code, result.getTimeTaken(), message, request, response);
}
Also used : TestReturn(io.github.microcks.domain.TestReturn) WsdlTestRequestStepResult(com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStepResult) RestRequestStepResult(com.eviware.soapui.impl.wsdl.teststeps.RestRequestStepResult)

Aggregations

RestRequestStepResult (com.eviware.soapui.impl.wsdl.teststeps.RestRequestStepResult)1 WsdlTestRequestStepResult (com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStepResult)1 TestReturn (io.github.microcks.domain.TestReturn)1