FacetNameFormatter implements Formatter { @Override public Element buildCategoryTag(CategorySummary result) { Element categoryTag = new Element(dimension.getName()); categoryTag.setAttribute("count", Integer.toString(result.count)); categoryTag.setAttribute("name", result.value); if (!result.label.trim().isEmpty()) { categoryTag.setAttribute("label", result.label); } return categoryTag; } FacetNameFormatter(Dimension dimension); @Override Element buildDimensionTag(int count); @Override Element buildCategoryTag(CategorySummary result);  }
@Test public void testBuildCategoryTag() { CategorySummary result = new CategorySummary(); result.value = "oceans"; result.label = "Oceans"; result.count = 3; Element categoryTag = formatter.buildCategoryTag(result); assertEquals("keyword", categoryTag.getName()); assertEquals(0, categoryTag.getContent().size()); assertEquals(3, categoryTag.getAttributes().size()); assertEquals("oceans", categoryTag.getAttributeValue("name")); assertEquals("Oceans", categoryTag.getAttributeValue("label")); assertEquals("3", categoryTag.getAttributeValue("count")); }