### Question:
DefaultQuoteService implements QuoteService { @Override public Optional<String> extract(XDOM xdom, String anchorId) { List<Block> blockList = xdom.getBlocks(new ExactAnchorBlockMatcher(anchorId), DESCENDANT); Optional<Block> firstBlock; if (blockList.size() == 1) { firstBlock = Optional.of(blockList.get(0)); } else { firstBlock = Optional.empty(); } return firstBlock .map(new RenderFunction()) .map(it -> StringUtils.abbreviate(it, "...", 200)); }  @Override Optional<String> extract(XDOM xdom, String anchorId);  }### Answer:
@Test void extractNoMentionFound() { Optional<String> actual = this.quoteService.extract(new XDOM(emptyList()), "anchorId"); verify(this.renderer, never()).render(any(Block.class), any(WikiPrinter.class)); assertFalse(actual.isPresent()); }
@Test void extractOneMention() { Map<String, String> parameters = new HashMap<>(); parameters.put("anchor", "anchorId"); MacroBlock mentionMacro = new MacroBlock("mention", parameters, false); ParagraphBlock paragraphBlock = new ParagraphBlock(asList(new RawBlock("hello", Syntax.XWIKI_2_1), mentionMacro)); XDOM xdom = new XDOM(singletonList(paragraphBlock)); Optional<String> actual = this.quoteService.extract(xdom, "anchorId"); verify(this.renderer).render(eq(paragraphBlock), any(WikiPrinter.class)); assertTrue(actual.isPresent()); }