Search in sources :

Example 1 with DefaultJaxrsScanner

use of io.swagger.jaxrs.config.DefaultJaxrsScanner in project swagger-core by swagger-api.

the class SwaggerContextServiceTest method initMock.

@BeforeMethod
void initMock() {
    servletContext1 = mock(ServletContext.class);
    servletConfig1 = mock(ServletConfig.class);
    servletContext2 = mock(ServletContext.class);
    servletConfig2 = mock(ServletConfig.class);
    jaxrsScanner = new DefaultJaxrsScanner();
    BeanConfig bc = new BeanConfig();
    bc.setDescription("Bean Config test 1");
    beanConfigScanner1 = bc;
    bc = new BeanConfig();
    bc.setDescription("Bean Config test 2");
    beanConfigScanner2 = bc;
}
Also used : BeanConfig(io.swagger.jaxrs.config.BeanConfig) DefaultJaxrsScanner(io.swagger.jaxrs.config.DefaultJaxrsScanner) ServletConfig(javax.servlet.ServletConfig) ServletContext(javax.servlet.ServletContext) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with DefaultJaxrsScanner

use of io.swagger.jaxrs.config.DefaultJaxrsScanner in project swagger-core by swagger-api.

the class DefaultJaxrsScannerTest method classesFromContextTest.

@Test(description = "should return singletones")
public void classesFromContextTest() {
    Application app = mock(Application.class);
    Set<Object> singletons = Sets.newHashSet(new io.swagger.jaxrs.listing.ApiListingResource(), new DefaultJaxrsScannerTest());
    when(app.getClasses()).thenReturn(null);
    when(app.getSingletons()).thenReturn(singletons);
    DefaultJaxrsScanner scanner = new DefaultJaxrsScanner();
    Set<Class<?>> output = scanner.classesFromContext(app, null);
    Set<Class<?>> classes = Sets.newHashSet(Iterables.transform(singletons, new Function<Object, Class<?>>() {

        @Override
        public Class<?> apply(Object o) {
            return o.getClass();
        }
    }));
    assertEquals(output, classes);
}
Also used : Function(com.google.common.base.Function) DefaultJaxrsScanner(io.swagger.jaxrs.config.DefaultJaxrsScanner) Application(javax.ws.rs.core.Application) Test(org.testng.annotations.Test)

Aggregations

DefaultJaxrsScanner (io.swagger.jaxrs.config.DefaultJaxrsScanner)2 Function (com.google.common.base.Function)1 BeanConfig (io.swagger.jaxrs.config.BeanConfig)1 ServletConfig (javax.servlet.ServletConfig)1 ServletContext (javax.servlet.ServletContext)1 Application (javax.ws.rs.core.Application)1 BeforeMethod (org.testng.annotations.BeforeMethod)1 Test (org.testng.annotations.Test)1