@Test public void testShouldReturnEmptyListForNoRegistrations() { ServletContext servletContext = mock(ServletContext.class); when(servletContext.getMajorVersion()).thenReturn(3); when(servletContext.getServletRegistrations()).thenReturn(new HashMap()); Servlet3ServletRegistrationProvider provider = new Servlet3ServletRegistrationProvider(); List<ServletRegistration> result = provider.getServletRegistrations(servletContext); assertNotNull(result); assertEquals(0, result.size()); }
@Override public List<ServletRegistration> getServletRegistrations(ServletContext context) { if (context.getMajorVersion() >= 3) { List<ServletRegistration> result = new ArrayList<ServletRegistration>(); for (javax.servlet.ServletRegistration r : context.getServletRegistrations().values()) { ServletRegistration registration = new ServletRegistration(); registration.setClassName(r.getClassName()); registration.addMappings(r.getMappings()); result.add(registration); } return result; } return null; }
Servlet3ServletRegistrationProvider implements ServletRegistrationProvider { @Override public List<ServletRegistration> getServletRegistrations(ServletContext context) { if (context.getMajorVersion() >= 3) { List<ServletRegistration> result = new ArrayList<ServletRegistration>(); for (javax.servlet.ServletRegistration r : context.getServletRegistrations().values()) { ServletRegistration registration = new ServletRegistration(); registration.setClassName(r.getClassName()); registration.addMappings(r.getMappings()); result.add(registration); } return result; } return null; } }
Servlet3ServletRegistrationProvider implements ServletRegistrationProvider { @Override public List<ServletRegistration> getServletRegistrations(ServletContext context) { if (context.getMajorVersion() >= 3) { List<ServletRegistration> result = new ArrayList<ServletRegistration>(); for (javax.servlet.ServletRegistration r : context.getServletRegistrations().values()) { ServletRegistration registration = new ServletRegistration(); registration.setClassName(r.getClassName()); registration.addMappings(r.getMappings()); result.add(registration); } return result; } return null; }  }
Servlet3ServletRegistrationProvider implements ServletRegistrationProvider { @Override public List<ServletRegistration> getServletRegistrations(ServletContext context) { if (context.getMajorVersion() >= 3) { List<ServletRegistration> result = new ArrayList<ServletRegistration>(); for (javax.servlet.ServletRegistration r : context.getServletRegistrations().values()) { ServletRegistration registration = new ServletRegistration(); registration.setClassName(r.getClassName()); registration.addMappings(r.getMappings()); result.add(registration); } return result; } return null; }  @Override int priority(); @Override List<ServletRegistration> getServletRegistrations(ServletContext context); }
Servlet3ServletRegistrationProvider implements ServletRegistrationProvider { @Override public List<ServletRegistration> getServletRegistrations(ServletContext context) { if (context.getMajorVersion() >= 3) { List<ServletRegistration> result = new ArrayList<ServletRegistration>(); for (javax.servlet.ServletRegistration r : context.getServletRegistrations().values()) { ServletRegistration registration = new ServletRegistration(); registration.setClassName(r.getClassName()); registration.addMappings(r.getMappings()); result.add(registration); } return result; } return null; }  @Override int priority(); @Override List<ServletRegistration> getServletRegistrations(ServletContext context);  }