Search in sources :

Example 1 with RefUtils.computeRefFormat

use of io.swagger.v3.parser.util.RefUtils.computeRefFormat in project swagger-parser by swagger-api.

the class OperationProcessorTest method testProcessOperation.

@Test
public void testProcessOperation(@Injectable final List<Parameter> inputParameterList, @Injectable final List<Parameter> outputParameterList, @Injectable final ApiResponse incomingResponse, @Injectable final ApiResponse resolvedResponse) throws Exception {
    Operation operation = new Operation();
    operation.setParameters(inputParameterList);
    final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
    ApiResponse refResponse = new ApiResponse().$ref(ref);
    operation.responses(new ApiResponses().addApiResponse("200", refResponse));
    operation.getResponses().addApiResponse("400", incomingResponse);
    new Expectations() {

        {
            new ParameterProcessor(cache, openAPI);
            times = 1;
            result = parameterProcessor;
            new ResponseProcessor(cache, openAPI);
            times = 1;
            result = responseProcessor;
            parameterProcessor.processParameters(inputParameterList);
            times = 1;
            result = outputParameterList;
            responseProcessor.processResponse(refResponse);
            times = 1;
            RefUtils.computeRefFormat(ref);
            times = 1;
            cache.loadRef(ref, RefFormat.URL, ApiResponse.class);
            times = 1;
            result = resolvedResponse;
            RefUtils.computeRefFormat(ref);
            times = 1;
            incomingResponse.get$ref();
            times = 1;
            responseProcessor.processResponse(incomingResponse);
            times = 1;
            responseProcessor.processResponse(resolvedResponse);
            times = 1;
        }
    };
    new OperationProcessor(cache, openAPI).processOperation(operation);
    new FullVerifications() {

        {
        }
    };
    assertEquals(operation.getResponses().get("200"), resolvedResponse);
    assertEquals(operation.getParameters(), outputParameterList);
}
Also used : Expectations(mockit.Expectations) FullVerifications(mockit.FullVerifications) Operation(io.swagger.v3.oas.models.Operation) ApiResponse(io.swagger.v3.oas.models.responses.ApiResponse) ApiResponses(io.swagger.v3.oas.models.responses.ApiResponses) Test(org.testng.annotations.Test)

Aggregations

Operation (io.swagger.v3.oas.models.Operation)1 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)1 ApiResponses (io.swagger.v3.oas.models.responses.ApiResponses)1 Expectations (mockit.Expectations)1 FullVerifications (mockit.FullVerifications)1 Test (org.testng.annotations.Test)1