@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()); }
@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)); }
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)); } }
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)); }  }
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); }
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);  }