SwaggerInitializer implements ServletContextListener { public void contextInitialized(ServletContextEvent servletContextEvent) { BeanConfig beanConfig = new BeanConfig() { @Override public List<Class<?>> classesFromContext(Application app, ServletConfig sc) { return resourceClasses; } }; beanConfig.setVersion("1.0.2"); beanConfig.setBasePath(baseUrlPattern); beanConfig.setDescription("RESTful resources"); beanConfig.setTitle("RESTful API"); beanConfig.setScan(true); } SwaggerInitializer(ServerData serverData); void contextInitialized(ServletContextEvent servletContextEvent); void contextDestroyed(ServletContextEvent servletContextEvent);  }
@Test public void testContextInitialized() { SwaggerInitializer initializer = new SwaggerInitializer(ServerData.builder().resources(LinkedListX.of(new ServletStatusResource())).build()); ServerData serverData = new ServerData(8080, ImmutableList.of(new ServletStatusResource()), null, "url", () -> "context"); initializer.contextInitialized(null); }