### Question:
DefaultIconRenderer implements IconRenderer { @Override public String render(String iconName, IconSet iconSet) throws IconException { return render(iconName, iconSet, iconSet.getRenderWiki()); }  @Override String render(String iconName, IconSet iconSet); @Override String renderHTML(String iconName, IconSet iconSet); @Override String render(String iconName, IconSet iconSet, String renderer); @Override void use(IconSet iconSet);  }### Answer:
@Test public void render() throws Exception { IconSet iconSet = new IconSet("default"); iconSet.setRenderWiki("image:$icon.png"); iconSet.addIcon("test", new Icon("blabla")); when(velocityRenderer.render("#set($icon = \"blabla\")\nimage:$icon.png")).thenReturn("image:blabla.png"); String result = iconRenderer.render("test", iconSet); assertEquals("image:blabla.png", result); verify(linkExtension, never()).use(any()); verify(skinExtension, never()).use(any()); verify(jsExtension, never()).use(any()); }
@Test public void renderNonExistentIcon() throws Exception { IconSet iconSet = new IconSet("default"); String result = iconRenderer.render("non-existent-icon", iconSet); assertEquals("", result); }
@Test public void renderWithException() throws Exception { IconSet iconSet = new IconSet("default"); iconSet.setRenderWiki("image:$icon.png"); iconSet.addIcon("test", new Icon("blabla")); IconException exception = new IconException("exception", null); when(velocityRenderer.render(any())).thenThrow(exception); IconException caughtException = null; try { iconRenderer.render("test", iconSet); } catch (IconException e) { caughtException = e; } assertNotNull(caughtException); assertEquals(exception, caughtException); }
@Test public void renderIcon() throws Exception { IconSet iconSet = new IconSet("iconSet"); iconSet.addIcon("test", new Icon("hello")); when(velocityRenderer.render("#set($icon = \"hello\")\nfa fa-$icon")).thenReturn("fa fa-hello"); String renderedIcon1 = iconRenderer.render("test", iconSet, "fa fa-$icon"); String renderedIcon2 = iconRenderer.render("none", iconSet, "fa fa-$icon"); String renderedIcon3 = iconRenderer.render("none", null, "fa fa-$icon"); String renderedIcon4 = iconRenderer.render("none", iconSet, null); assertEquals("fa fa-hello", renderedIcon1); assertEquals("", renderedIcon2); assertEquals("", renderedIcon3); assertEquals("", renderedIcon4); }