OfficeListTag extends BodyTagSupport { XmlBuilder getLink(Short officeId, String officeName) { String urlencodedOfficeName = URLEncoder.encode(officeName); XmlBuilder builder = new XmlBuilder(); String url = (actionName + "?method=" + methodName + "&office.officeId=" + officeId + "&office.officeName=" + urlencodedOfficeName + "&officeId=" + officeId + "&officeName=" + urlencodedOfficeName + "&currentFlowKey=" + flowKey); builder.startTag("a", "href", url); builder.text(officeName); builder.endTag("a"); return builder; } 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 testGetLink() throws Exception { OfficeListTag tag = new OfficeListTag("action", "method", "flow"); XmlBuilder link = tag.getLink((short) 234, "My Office"); Assert.assertEquals("<a href=\"action?method=method&amp;" + "office.officeId=234&amp;office.officeName=My+Office&amp;" + "officeId=234&amp;officeName=My+Office&amp;" + "currentFlowKey=flow\">My Office</a>", link .getOutput()); }