### Question:
WebResourceTransformation { boolean matches(ResourceLocation location) { String loc = location.getLocation(); if (loc == null || "".equals(loc.trim())) { loc = location.getName(); } return loc.endsWith(extension); } WebResourceTransformation(Element element);   }### Answer:
@Test public void testMatches() throws DocumentException { WebResourceTransformation trans = new WebResourceTransformation(DocumentHelper.parseText( "<transformation extension=\"js\">\n" + "<transformer key=\"foo\" />\n" + "</transformation>").getRootElement()); ResourceLocation loc = mock(ResourceLocation.class); when(loc.getName()).thenReturn("foo.js"); assertTrue(trans.matches(loc)); }
@Test public void testNotMatches() throws DocumentException { WebResourceTransformation trans = new WebResourceTransformation(DocumentHelper.parseText( "<transformation extension=\"js\">\n" + "<transformer key=\"foo\" />\n" + "</transformation>").getRootElement()); ResourceLocation loc = mock(ResourceLocation.class); when(loc.getName()).thenReturn("foo.cs"); assertFalse(trans.matches(loc)); }