OfficeListTag extends BodyTagSupport { void getAboveBranches(XmlBuilder html, List<OfficeBO> officeList, String regional, String subregional, String area) { if (null != officeList) { XmlBuilder regionalHtml = null; XmlBuilder subregionalHtml = null; XmlBuilder areaHtml = null; for (int i = 0; i < officeList.size(); i++) { OfficeBO office = officeList.get(i); if (office.getOfficeLevel() == OfficeLevel.HEADOFFICE) { html.singleTag("br"); html.startTag("span", "class", "fontnormalbold"); html.append(getLink(office.getOfficeId(), office.getOfficeName())); html.singleTag("br"); html.endTag("span"); } else if (office.getOfficeLevel() == OfficeLevel.REGIONALOFFICE) { regionalHtml = processOffice(regionalHtml, office, regional); } else if (office.getOfficeLevel() == OfficeLevel.SUBREGIONALOFFICE) { subregionalHtml = processOffice(subregionalHtml, office, subregional); } else if (office.getOfficeLevel() == OfficeLevel.AREAOFFICE) { areaHtml = processOffice(areaHtml, office, area); } } outputLevel(html, regionalHtml); outputLevel(html, subregionalHtml); outputLevel(html, areaHtml); } } OfficeListTag();  OfficeListTag(String action, String method, String flow); @Override int doStartTag(); String getActionName(); void setActionName(String actionName); String getMethodName(); void setMethodName(String methodName); String getOnlyBranchOffices(); void setOnlyBranchOffices(String onlyBranchOffices); String replaceSpaces(String officeName); String getFlowKey(); void setFlowKey(String flowKey);  }
@Test public void testNothingAboveBranches() throws Exception { new OfficeListTag().getAboveBranches(result, null, null, null, null); Assert.assertEquals("", result.toString()); }
@Test public void testAboveBranches() throws Exception { List<OfficeBO> offices = new ArrayList<OfficeBO>(); offices.add(makeOffice("Trinidad&Tobago", OfficeLevel.HEADOFFICE)); offices.add(makeOffice("Ontario&Quebec", OfficeLevel.REGIONALOFFICE)); offices.add(makeOffice("Alberta", OfficeLevel.REGIONALOFFICE)); offices.add(makeOffice("Vancouver", OfficeLevel.SUBREGIONALOFFICE)); offices.add(makeOffice("Toronto&Ottawa", OfficeLevel.SUBREGIONALOFFICE)); offices.add(makeOffice("SoHo", OfficeLevel.AREAOFFICE)); offices.add(makeOffice("Tribeca&Chelsea", OfficeLevel.AREAOFFICE)); new OfficeListTag().getAboveBranches(result, offices, "Province <State>", "County <Duchy>", "Parish <City>"); String html = result.toString(); assertWellFormedFragment(html); StringAssert.assertContains("Toronto&amp;Ottawa", html); }