Search in sources :

Example 1 with OperationGenerator

use of org.apache.servicecomb.swagger.generator.core.OperationGenerator in project incubator-servicecomb-java-chassis by apache.

the class ApiOperationProcessorTest method testConvertTags.

@Test
public void testConvertTags() throws NoSuchMethodException {
    ApiOperationProcessor apiOperationProcessor = new ApiOperationProcessor();
    Method function = TestClass.class.getMethod("function");
    SwaggerGenerator swaggerGenerator = new SwaggerGenerator(new PojoSwaggerGeneratorContext(), TestClass.class);
    OperationGenerator operationGenerator = new OperationGenerator(swaggerGenerator, function);
    apiOperationProcessor.process(function.getAnnotation(ApiOperation.class), operationGenerator);
    assertThat(operationGenerator.getOperation().getTags(), containsInAnyOrder("tag1", "tag2"));
}
Also used : SwaggerGenerator(org.apache.servicecomb.swagger.generator.core.SwaggerGenerator) ApiOperation(io.swagger.annotations.ApiOperation) Method(java.lang.reflect.Method) PojoSwaggerGeneratorContext(org.apache.servicecomb.swagger.generator.pojo.PojoSwaggerGeneratorContext) OperationGenerator(org.apache.servicecomb.swagger.generator.core.OperationGenerator) Test(org.junit.Test)

Example 2 with OperationGenerator

use of org.apache.servicecomb.swagger.generator.core.OperationGenerator in project incubator-servicecomb-java-chassis by apache.

the class ApiOperationProcessorTest method testConvertTagsOnMethodWithNoTag.

@Test
public void testConvertTagsOnMethodWithNoTag() throws NoSuchMethodException {
    ApiOperationProcessor apiOperationProcessor = new ApiOperationProcessor();
    Method function = TestClass.class.getMethod("functionWithNoTag");
    SwaggerGenerator swaggerGenerator = new SwaggerGenerator(new PojoSwaggerGeneratorContext(), TestClass.class);
    OperationGenerator operationGenerator = new OperationGenerator(swaggerGenerator, function);
    apiOperationProcessor.process(function.getAnnotation(ApiOperation.class), operationGenerator);
    List<String> tagList = operationGenerator.getOperation().getTags();
    assertNull(tagList);
}
Also used : SwaggerGenerator(org.apache.servicecomb.swagger.generator.core.SwaggerGenerator) ApiOperation(io.swagger.annotations.ApiOperation) Method(java.lang.reflect.Method) PojoSwaggerGeneratorContext(org.apache.servicecomb.swagger.generator.pojo.PojoSwaggerGeneratorContext) OperationGenerator(org.apache.servicecomb.swagger.generator.core.OperationGenerator) Test(org.junit.Test)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)2 Method (java.lang.reflect.Method)2 OperationGenerator (org.apache.servicecomb.swagger.generator.core.OperationGenerator)2 SwaggerGenerator (org.apache.servicecomb.swagger.generator.core.SwaggerGenerator)2 PojoSwaggerGeneratorContext (org.apache.servicecomb.swagger.generator.pojo.PojoSwaggerGeneratorContext)2 Test (org.junit.Test)2