### Question:
ServletMappings { @Nonnull public List<String> getURLPatternsForClass(@Nonnull String classWithPackage) { List<String> mappings = list(); String servletName = null; for (ClassMapping entry : servlets) { if (entry != null && classWithPackage.equals(entry.getClassWithPackage())) { servletName = entry.getServletName(); break; } } for (UrlPatternMapping entry : allServletMappings) { if (entry != null && entry.getServletName().equals(servletName)) { mappings.add(entry.getUrlPattern()); } } return mappings; } ServletMappings(@Nonnull List<UrlPatternMapping> servletMappings,
                           @Nonnull List<ClassMapping> servlets,
                           @Nonnull CachedDirectory cachedDirectory,
                           @Nonnull Map<String, String> contextParams); @Nullable List<UrlPatternMapping> getServletMappings(); @Nullable List<ClassMapping> getClassMappings(); @Nonnull List<String> getURLPatternsForClass(@Nonnull String classWithPackage); @Nonnull String getClassForURL(@Nonnull String path); @Nonnull FrameworkType guessApplicationType(); final static String DEFAULT_SERVLET; }### Answer:
@Test public void testClassToURLMapping() throws IOException { List<Entry<String,String>> tests; ServletMappings mappings = getTestMappings(); tests = makeMappingsList( "myservlets.watermelon", "/fruit/summer/*", "myservlets.list", "/seedlist", "myservlets.garden", "/seeds/*", "myservlets.kiwi", "*.abc", "myservlets.servlet1", "/foo/bar/*", "myservlets.servlet2", "/baz/*", "myservlets.servlet3", "/catalog", "myservlets.servlet4", "*.bop" ); assertTrue("The wrong number of tests were present", tests.size() == 8); for (Entry<String, String> entry : tests) { List<String> result = mappings.getURLPatternsForClass(entry.getKey()); boolean passed = result.get(0) != null && result.get(0).equals(entry.getValue()); assertTrue("Test failed for " + entry.getKey() + " -> " + entry.getValue() + "\nResulting value was " + result.get(0), passed); } }