### Question:
DefaultServletModuleManager implements ServletModuleManager { static <T> void sortedInsert(final List<T> list, final T e, final Comparator<T> comparator) { int insertIndex = Collections.binarySearch(list, e, comparator); if (insertIndex < 0) { insertIndex = -insertIndex - 1; } else { while ((insertIndex < list.size()) && (comparator.compare(list.get(insertIndex), e) == 0)) { insertIndex++; } } list.add(insertIndex, e); } DefaultServletModuleManager(final ServletContext servletContext, final PluginEventManager pluginEventManager);  DefaultServletModuleManager(final PluginEventManager pluginEventManager);  DefaultServletModuleManager(final PluginEventManager pluginEventManager, final PathMapper servletPathMapper, final PathMapper filterPathMapper); void addServletModule(final ServletModuleDescriptor descriptor); HttpServlet getServlet(final String path, final ServletConfig servletConfig); void removeServletModule(final ServletModuleDescriptor descriptor); void addFilterModule(final ServletFilterModuleDescriptor descriptor); Iterable<Filter> getFilters(final FilterLocation location, final String path, final FilterConfig filterConfig); Iterable<Filter> getFilters(FilterLocation location, String path, FilterConfig filterConfig, FilterDispatcherCondition condition); void removeFilterModule(final ServletFilterModuleDescriptor descriptor); @PluginEventListener void onPluginDisabled(final PluginDisabledEvent event);  }### Answer:
@Test public void testSortedInsertInsertsDistinctElementProperly() { List<String> list = newList("cat", "dog", "fish", "monkey"); List<String> endList = newList("cat", "dog", "elephant", "fish", "monkey"); sortedInsert(list, "elephant", naturalOrder(String.class)); assertEquals(endList, list); }
@Test public void testSortedInsertInsertsNonDistinctElementProperly() { List<WeightedValue> list = newList ( new WeightedValue(10, "dog"), new WeightedValue(20, "monkey"), new WeightedValue(20, "tiger"), new WeightedValue(30, "fish"), new WeightedValue(100, "cat") ); List<WeightedValue> endList = newList ( new WeightedValue(10, "dog"), new WeightedValue(20, "monkey"), new WeightedValue(20, "tiger"), new WeightedValue(20, "elephant"), new WeightedValue(30, "fish"), new WeightedValue(100, "cat") ); sortedInsert(list, new WeightedValue(20, "elephant"), WeightedValue.byWeight); assertEquals(endList, list); }