TagRegistry { public static AbstractHtml getNewTagInstance(final String tagName) { return getNewTagInstance(tagName, null, new AbstractAttribute[0]); }  static List<String> getTagNames(); static Integer getIndexByTagName(final String tagName); static void register(final String... tagNamesToRegister); static Map<String, String> getTagClassNameByTagName(); static Map<String, Class<?>> getTagClassByTagName(); static void loadAllTagClasses(); static AbstractHtml getNewTagInstance(final String tagName); static AbstractHtml getNewTagInstance(final String tagName,
            final AbstractHtml parent, final AbstractAttribute... attributes); static AbstractHtml getNewTagInstanceOrNullIfFailed(
            final String tagName, final AbstractHtml parent,
            final AbstractAttribute... attributes); static AbstractHtml getNewTagInstanceOrNullIfFailed(
            final int tagNameIndex, final AbstractHtml parent,
            final AbstractAttribute... attributes);  }
@Test public void testGetNewTagInstance() { final Map<String, Class<?>> tagClassNameByTagName = TagRegistry .getTagClassByTagName(); { for (Entry<String, Class<?>> entry : tagClassNameByTagName .entrySet()) { final AbstractHtml tag = TagRegistry .getNewTagInstance(entry.getKey()); assertNotNull(tag); assertEquals(entry.getValue(), tag.getClass()); } } { for (Entry<String, Class<?>> entry : tagClassNameByTagName .entrySet()) { CustomTag customTag = new CustomTag("custom-tag", null); CustomAttribute customAttribute = new CustomAttribute( "custom-attr-name", "custom-attr-value"); final String tagName = entry.getKey(); final AbstractHtml tag = TagRegistry.getNewTagInstance( tagName, customTag, customAttribute); assertNotNull(tag); assertEquals(entry.getValue(), tag.getClass()); if (tag.toHtmlString().contains("</")) { assertEquals("<" + tagName + " custom-attr-name=\"custom-attr-value\"></" + tagName + ">", tag.toHtmlString()); } else if (tag.toHtmlString().endsWith("/>")) { assertEquals("<" + tagName + " custom-attr-name=\"custom-attr-value\"/>", tag.toHtmlString()); } else if (tag.toHtmlString().endsWith(">")) { assertEquals("<" + tagName + " custom-attr-name=\"custom-attr-value\">", tag.toHtmlString()); } } } }