Search in sources :

Example 6 with ReaderContext

use of io.swagger.servlet.ReaderContext in project swagger-core by swagger-api.

the class PathGetterTest method getPathTest.

@Test(dataProvider = "resourceWithAnnotations")
public void getPathTest(String methodName, String expected) throws NoSuchMethodException {
    final ReaderContext context = createDefaultContext();
    context.setParentPath("/tests");
    Assert.assertEquals(extension.getPath(context, findMethod(context, methodName)), expected);
}
Also used : ReaderContext(io.swagger.servlet.ReaderContext) Test(org.testng.annotations.Test)

Example 7 with ReaderContext

use of io.swagger.servlet.ReaderContext in project swagger-core by swagger-api.

the class ResponsesTest method applyResponsesTest.

@Test(dataProvider = "resourceWithAnnotations")
public void applyResponsesTest(String methodName, Response expected) throws NoSuchMethodException {
    final Operation operation = new Operation();
    final ReaderContext context = createDefaultContext();
    extension.applyResponses(context, operation, findMethod(context, methodName));
    if (expected == null) {
        Assert.assertNull(operation.getResponses());
    } else {
        final Response response = operation.getResponses().get("200");
        Assert.assertEquals(response.getDescription(), expected.getDescription());
    }
}
Also used : Response(io.swagger.models.Response) ReaderContext(io.swagger.servlet.ReaderContext) Operation(io.swagger.models.Operation) Test(org.testng.annotations.Test)

Example 8 with ReaderContext

use of io.swagger.servlet.ReaderContext in project swagger-core by swagger-api.

the class ResponsesTest method detailedResponsesTest.

@Test
public void detailedResponsesTest() throws NoSuchMethodException {
    final Operation operation = new Operation();
    final ReaderContext context = createDefaultContext();
    extension.applyResponses(context, operation, findMethod(context, "testMethod3"));
    final Map<String, Response> responses = operation.getResponses();
    Assert.assertEquals(responses.size(), 7);
    for (Map.Entry<String, String> entry : ResponsesTest.responses.entrySet()) {
        Assert.assertEquals(responses.get(entry.getKey()).getDescription(), entry.getValue());
    }
}
Also used : Response(io.swagger.models.Response) ReaderContext(io.swagger.servlet.ReaderContext) Operation(io.swagger.models.Operation) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Example 9 with ReaderContext

use of io.swagger.servlet.ReaderContext in project swagger-core by swagger-api.

the class SchemesTest method applySchemesTest.

@Test(dataProvider = "resourceWithAnnotations")
public void applySchemesTest(String methodName, List<Scheme> expected) throws NoSuchMethodException {
    final Operation operation = new Operation();
    final ReaderContext context = createDefaultContext();
    extension.applySchemes(context, operation, findMethod(context, methodName));
    Assert.assertEquals(operation.getSchemes(), expected);
}
Also used : ReaderContext(io.swagger.servlet.ReaderContext) Operation(io.swagger.models.Operation) Test(org.testng.annotations.Test)

Example 10 with ReaderContext

use of io.swagger.servlet.ReaderContext in project swagger-core by swagger-api.

the class SecurityRequirementsTest method securityRequirementsTest1.

@Test(dataProvider = "resourceWithAnnotations")
public void securityRequirementsTest1(String methodName, SecurityRequirement expected) throws NoSuchMethodException {
    final Operation operation = new Operation();
    final ReaderContext context = createDefaultContext();
    extension.applySecurityRequirements(context, operation, findMethod(context, methodName));
    Assert.assertEquals(operation.getSecurity().get(0), expected.getRequirements());
}
Also used : ReaderContext(io.swagger.servlet.ReaderContext) Operation(io.swagger.models.Operation) Test(org.testng.annotations.Test)

Aggregations

ReaderContext (io.swagger.servlet.ReaderContext)16 Test (org.testng.annotations.Test)15 Operation (io.swagger.models.Operation)12 Response (io.swagger.models.Response)2 Method (java.lang.reflect.Method)2 BodyParameter (io.swagger.models.parameters.BodyParameter)1 Parameter (io.swagger.models.parameters.Parameter)1 PathParameter (io.swagger.models.parameters.PathParameter)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1