### Question:
WebXmlUtils { public static void addFilter(final String filterName, final String filterClass, final String urlPattern, final Document document, final String comment, final WebXmlParam... initParams) { addFilterAtPosition(FilterPosition.LAST, null, null, filterName, filterClass, urlPattern, document, comment, initParams); } private  WebXmlUtils(); static void addContextParam(final WebXmlParam contextParam, final Document document,
      final String comment); static void addErrorCode(final Integer errorCode, final String location,
      final Document document, final String comment); static void addExceptionType(final String exceptionType, final String location,
      final Document document, final String comment); static void addFilter(final String filterName, final String filterClass,
      final String urlPattern, final Document document, final String comment,
      final WebXmlParam... initParams); static void addFilterAtPosition(final FilterPosition filterPosition,
      final String afterFilterName, final String beforeFilterName, final String filterName,
      final String filterClass, final String urlPattern, final Document document,
      final String comment, List<WebXmlParam> initParams, final List<Dispatcher> dispatchers); static void addFilterAtPosition(final FilterPosition filterPosition,
      final String afterFilterName, final String beforeFilterName, final String filterName,
      final String filterClass, final String urlPattern, final Document document,
      final String comment, final WebXmlParam... initParams); static void addListener(final String className, final Document document,
      final String comment); static void addSecurityConstraint(final String displayName,
      final List<WebResourceCollection> webResourceCollections, final List<String> roleNames,
      final String transportGuarantee, final Document document, final String comment); static void addServlet(final String servletName, final String className,
      final String urlPattern, final Integer loadOnStartup, final Document document,
      final String comment, final WebXmlParam... initParams); static void addWelcomeFile(final String path, final Document document, final String comment); static void setDescription(final String description, final Document document,
      final String comment); static void setDisplayName(final String displayName, final Document document,
      final String comment); static void setSessionTimeout(final int timeout, final Document document,
      final String comment);  }### Answer:
@Test public void testAddFilter() { WebXmlUtils.addFilter("filter1", String.class.getName(), "/*", webXml, null, new WebXmlUtils.WebXmlParam("key", "value"), new WebXmlUtils.WebXmlParam("key2", "value2")); final Element filterElement = XmlUtils.findFirstElement("filter", webXml.getDocumentElement()); assertNotNull(filterElement); assertEquals("filter1", XmlUtils.findFirstElement("filter-name", filterElement) .getTextContent()); assertEquals(String.class.getName(), XmlUtils.findFirstElement("filter-class", filterElement) .getTextContent()); final Element filterMapping = XmlUtils.findFirstElement("filter-mapping", webXml.getDocumentElement()); assertNotNull(filterMapping); assertEquals("filter1", XmlUtils.findFirstElement("filter-name", filterMapping) .getTextContent()); assertEquals("/*", XmlUtils.findFirstElement("url-pattern", filterMapping).getTextContent()); final List<Element> initParams = XmlUtils.findElements("init-param", filterElement); assertEquals(2, initParams.size()); assertEquals(2, initParams.get(0).getChildNodes().getLength()); assertEquals("key", XmlUtils.findFirstElement("param-name", initParams.get(0)).getTextContent()); assertEquals("value", XmlUtils.findFirstElement("param-value", initParams.get(0)) .getTextContent()); assertEquals("key2", XmlUtils.findFirstElement("param-name", initParams.get(1)) .getTextContent()); assertEquals("value2", XmlUtils.findFirstElement("param-value", initParams.get(1)) .getTextContent()); }