Search in sources :

Example 11 with ReaderContext

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

the class TagsTest method applyTagsTest2.

@Test(dataProvider = "resourceWithoutApiAnnotation")
public void applyTagsTest2(String methodName, List<String> expected) throws NoSuchMethodException {
    final Operation operation = new Operation();
    final ReaderContext context = createDefaultContextWithoutApi();
    extension.applyTags(context, operation, findMethod(context, methodName));
    Assert.assertEquals(operation.getTags(), expected);
}
Also used : ReaderContext(io.swagger.servlet.ReaderContext) Operation(io.swagger.models.Operation) Test(org.testng.annotations.Test)

Example 12 with ReaderContext

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

the class ConsumesProducesTest method applyConsumesProducesTest2.

@Test(dataProvider = "resourceWithoutApiAnnotation")
public void applyConsumesProducesTest2(String methodName, List<String> expected) throws NoSuchMethodException {
    final Operation operation = new Operation();
    final ReaderContext context = createDefaultContextWithoutApi();
    final Method method = findMethod(context, methodName);
    extension.applyConsumes(context, operation, method);
    extension.applyProduces(context, operation, method);
    Assert.assertEquals(operation.getConsumes(), expected);
    Assert.assertEquals(operation.getProduces(), expected);
}
Also used : ReaderContext(io.swagger.servlet.ReaderContext) Operation(io.swagger.models.Operation) Method(java.lang.reflect.Method) Test(org.testng.annotations.Test)

Example 13 with ReaderContext

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

the class ImplicitParametersTest method detailedTest.

@Test
public void detailedTest() throws NoSuchMethodException {
    final Operation operation = new Operation();
    final ReaderContext context = createDefaultContext();
    extension.applyImplicitParameters(context, operation, findMethod(context, "testMethod3"));
    final List<Parameter> parameters = operation.getParameters();
    final Parameter parameter1 = parameters.get(0);
    Assert.assertNotNull(parameter1);
    Assert.assertTrue(parameter1 instanceof PathParameter);
    Assert.assertEquals(parameter1.getName(), "param1");
    Assert.assertEquals(parameter1.getIn(), "path");
    Assert.assertEquals(parameter1.getDescription(), "Param 1");
    Assert.assertTrue(parameter1.getRequired());
    final Parameter parameter5 = parameters.get(4);
    Assert.assertNotNull(parameter5);
    Assert.assertTrue(parameter5 instanceof BodyParameter);
    Assert.assertEquals(parameter5.getName(), "param5");
    Assert.assertEquals(parameter5.getIn(), "body");
    Assert.assertEquals(parameter5.getDescription(), "Param 5");
    Assert.assertFalse(parameter5.getRequired());
}
Also used : ReaderContext(io.swagger.servlet.ReaderContext) BodyParameter(io.swagger.models.parameters.BodyParameter) PathParameter(io.swagger.models.parameters.PathParameter) Parameter(io.swagger.models.parameters.Parameter) Operation(io.swagger.models.Operation) BodyParameter(io.swagger.models.parameters.BodyParameter) PathParameter(io.swagger.models.parameters.PathParameter) Test(org.testng.annotations.Test)

Example 14 with ReaderContext

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

the class SchemesTest method applySchemesWithoutApiTest.

@Test(dataProvider = "resourceWithoutApiAnnotation")
public void applySchemesWithoutApiTest(String methodName, List<Scheme> expected) throws NoSuchMethodException {
    final Operation operation = new Operation();
    final ReaderContext context = createDefaultContextWithoutApi();
    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 15 with ReaderContext

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

the class SecurityRequirementsTest method securityRequirementsTest2.

@Test(dataProvider = "resourceWithoutApiAnnotation")
public void securityRequirementsTest2(String methodName, SecurityRequirement expected) throws NoSuchMethodException {
    final Operation operation = new Operation();
    final ReaderContext context = createDefaultContextWithoutApi();
    extension.applySecurityRequirements(context, operation, findMethod(context, methodName));
    if (expected == null) {
        Assert.assertNull(operation.getSecurity());
    } else {
        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