Search in sources :

Example 1 with FullVerifications

use of mockit.FullVerifications in project swagger-parser by swagger-api.

the class PropertyProcessorTest method testProcessRefProperty_ExternalRef.

@Test
public void testProcessRefProperty_ExternalRef() throws Exception {
    expectCreationOfExternalRefProcessor();
    final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
    final RefProperty refProperty = new RefProperty(ref);
    expectCallToExternalRefProcessor(ref, RefFormat.URL, "bar");
    new PropertyProcessor(cache, swagger).processProperty(refProperty);
    new FullVerifications() {

        {
        }
    };
    assertEquals(refProperty.get$ref(), "#/definitions/bar");
}
Also used : FullVerifications(mockit.FullVerifications) RefProperty(io.swagger.models.properties.RefProperty) Test(org.testng.annotations.Test)

Example 2 with FullVerifications

use of mockit.FullVerifications in project swagger-parser by swagger-api.

the class PropertyProcessorTest method testProcessArrayProperty_ItemsIsRefProperty.

@Test
public void testProcessArrayProperty_ItemsIsRefProperty() throws Exception {
    expectCreationOfExternalRefProcessor();
    final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
    final RefProperty refProperty = new RefProperty(ref);
    ArrayProperty arrayProperty = new ArrayProperty();
    arrayProperty.setItems(refProperty);
    expectCallToExternalRefProcessor(ref, RefFormat.URL, "bar");
    new PropertyProcessor(cache, swagger).processProperty(arrayProperty);
    new FullVerifications() {

        {
        }
    };
    assertEquals(((RefProperty) arrayProperty.getItems()).get$ref(), "#/definitions/bar");
}
Also used : ArrayProperty(io.swagger.models.properties.ArrayProperty) FullVerifications(mockit.FullVerifications) RefProperty(io.swagger.models.properties.RefProperty) Test(org.testng.annotations.Test)

Example 3 with FullVerifications

use of mockit.FullVerifications 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 Response incomingResponse, @Injectable final Response resolvedResponse) throws Exception {
    Operation operation = new Operation();
    operation.setParameters(inputParameterList);
    final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
    RefResponse refResponse = new RefResponse(ref);
    operation.response(200, refResponse);
    operation.response(400, incomingResponse);
    new Expectations() {

        {
            new ParameterProcessor(cache, swagger);
            times = 1;
            result = parameterProcessor;
            new ResponseProcessor(cache, swagger);
            times = 1;
            result = responseProcessor;
            parameterProcessor.processParameters(inputParameterList);
            times = 1;
            result = outputParameterList;
            cache.loadRef(ref, RefFormat.URL, Response.class);
            times = 1;
            result = resolvedResponse;
            responseProcessor.processResponse(incomingResponse);
            times = 1;
            responseProcessor.processResponse(resolvedResponse);
            times = 1;
        }
    };
    new OperationProcessor(cache, swagger).processOperation(operation);
    new FullVerifications() {

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

Example 4 with FullVerifications

use of mockit.FullVerifications in project swagger-parser by swagger-api.

the class PropertyProcessorTest method testProcessRefProperty_InternalRef.

@Test
public void testProcessRefProperty_InternalRef() throws Exception {
    expectCreationOfExternalRefProcessor();
    final String expectedRef = "#/definitions/foo";
    final RefProperty property = new RefProperty(expectedRef);
    new PropertyProcessor(cache, swagger).processProperty(property);
    new FullVerifications() {

        {
        }
    };
    assertEquals(property.get$ref(), expectedRef);
}
Also used : FullVerifications(mockit.FullVerifications) RefProperty(io.swagger.models.properties.RefProperty) Test(org.testng.annotations.Test)

Example 5 with FullVerifications

use of mockit.FullVerifications in project swagger-parser by swagger-api.

the class PropertyProcessorTest method testProcessMapProperty_AdditionalPropertiesIsRefProperty.

@Test
public void testProcessMapProperty_AdditionalPropertiesIsRefProperty() throws Exception {
    expectCreationOfExternalRefProcessor();
    final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
    final RefProperty refProperty = new RefProperty(ref);
    MapProperty mapProperty = new MapProperty();
    mapProperty.setAdditionalProperties(refProperty);
    expectCallToExternalRefProcessor(ref, RefFormat.URL, "bar");
    new PropertyProcessor(cache, swagger).processProperty(mapProperty);
    new FullVerifications() {

        {
        }
    };
    assertEquals(((RefProperty) mapProperty.getAdditionalProperties()).get$ref(), "#/definitions/bar");
}
Also used : MapProperty(io.swagger.models.properties.MapProperty) FullVerifications(mockit.FullVerifications) RefProperty(io.swagger.models.properties.RefProperty) Test(org.testng.annotations.Test)

Aggregations

FullVerifications (mockit.FullVerifications)6 Test (org.testng.annotations.Test)6 RefProperty (io.swagger.models.properties.RefProperty)4 Operation (io.swagger.models.Operation)1 RefResponse (io.swagger.models.RefResponse)1 Response (io.swagger.models.Response)1 ArrayProperty (io.swagger.models.properties.ArrayProperty)1 MapProperty (io.swagger.models.properties.MapProperty)1 Expectations (mockit.Expectations)1 StrictExpectations (mockit.StrictExpectations)1