### Question:
HtmlElementUtil { public static boolean hasAttribute(HtmlElement element, String attributeName) { return element.getAttributesMap().containsKey(attributeName); } private  HtmlElementUtil(); static boolean hasNonEmptyAttribute(HtmlElement element, String attributeName); static boolean hasAttribute(HtmlElement element, String attributeName);  }### Answer:
@Test public void hasAttributeReturnsTrueIfAnEmptyAttributeExists() throws Exception { HtmlElement elementWithEmptyAttribute = createHtmlElement("<img src=\"\" alt=\"\"/>"); assertTrue(HtmlElementUtil.hasAttribute(elementWithEmptyAttribute, "alt")); }
@Test public void hasAttributeReturnsTrueIfAnNonEmptyAttributeExists() throws Exception { HtmlElement elementWithNonEmptyAttribute = createHtmlElement("<img src=\"\" alt=\"Hello World\"/>"); assertTrue(HtmlElementUtil.hasAttribute(elementWithNonEmptyAttribute, "alt")); }
@Test public void hasAttributeReturnsFalseIfTheAttributeDoesNotExist() throws Exception { HtmlElement elementWithMissingAttribute = createHtmlElement("<img src=\"\"/>"); assertFalse(HtmlElementUtil.hasAttribute(elementWithMissingAttribute, "alt")); }