### Question:
PlainTextChainingRenderer extends AbstractChainingPrintRenderer { @Override public void endLink(ResourceReference reference, boolean freestanding, Map<String, String> parameters) { if (getEmptyBlockState().isCurrentContainerBlockEmpty()) { ResourceType resourceType = reference.getType(); if ((ResourceType.DOCUMENT.equals(resourceType) || ResourceType.SPACE.equals(resourceType) || ResourceType.PAGE.equals(resourceType)) && this.linkLabelGenerator != null) { getPrinter().print(this.linkLabelGenerator.generate(reference)); } else { getPrinter().print(reference.getReference()); } } } PlainTextChainingRenderer(ListenerChain listenerChain);  PlainTextChainingRenderer(LinkLabelGenerator linkLabelGenerator, ListenerChain listenerChain); @Override void beginParagraph(Map<String, String> parameters); @Override void onNewLine(); @Override void endLink(ResourceReference reference, boolean freestanding, Map<String, String> parameters); @Override void beginHeader(HeaderLevel level, String id, Map<String, String> parameters); @Override void onWord(String word); @Override void beginList(ListType type, Map<String, String> parameters); @Override void beginListItem(); @Override void beginListItem(Map<String, String> parameters); @Override void onSpace(); @Override void onSpecialSymbol(char symbol); @Override void onHorizontalLine(Map<String, String> parameters); @Override void onEmptyLines(int count); @Override void onVerbatim(String content, boolean inline, Map<String, String> parameters); @Override void beginDefinitionList(Map<String, String> parameters); @Override void beginDefinitionTerm(); @Override void beginDefinitionDescription(); @Override void beginQuotationLine(); @Override void beginTable(Map<String, String> parameters); @Override void beginTableCell(Map<String, String> parameters); @Override void beginTableHeadCell(Map<String, String> parameters); @Override void beginTableRow(Map<String, String> parameters); @Override void onImage(ResourceReference reference, boolean freestanding, Map<String, String> parameters); @Override void onRawText(String text, Syntax syntax);  }### Answer:
@Test public void testBeginLinkWhenLinkLabelGeneratorIsNull() throws Exception { DefaultWikiPrinter printer = new DefaultWikiPrinter(); this.renderer.setPrinter(printer); DocumentResourceReference reference = new DocumentResourceReference("reference"); reference.setAnchor("anchor"); reference.setQueryString("param=value"); this.renderer.beginLink(reference, false, Collections.<String, String>emptyMap()); this.renderer.endLink(reference, false, Collections.<String, String>emptyMap()); Assert.assertEquals("reference", printer.toString()); }
@Test public void testBeginLinkWhenExternalLink() throws Exception { DefaultWikiPrinter printer = new DefaultWikiPrinter(); this.renderer.setPrinter(printer); ResourceReference reference = new ResourceReference("http: this.renderer.beginLink(reference, false, Collections.<String, String>emptyMap()); this.renderer.endLink(reference, false, Collections.<String, String>emptyMap()); Assert.assertEquals("http: }