### Question:
PlainTextBlockFilter implements BlockFilter { @Override public List<Block> filter(Block block) { if (VALID_PLAINTEXT_BLOCKS.contains(block.getClass())) { return Collections.singletonList(block); } if (LinkBlock.class.isAssignableFrom(block.getClass()) && block.getChildren().isEmpty()) { ResourceReference reference = ((LinkBlock) block).getReference(); return filterLinkBlock(reference); } return Collections.emptyList(); } PlainTextBlockFilter(Parser plainTextParser, LinkLabelGenerator linkLabelGenerator); @Override List<Block> filter(Block block);  }### Answer:
@Test public void filterWord() { WordBlock wordBlock = new WordBlock("text"); List<Block> result = filter.filter(wordBlock); assertIterableEquals(Collections.singletonList(wordBlock), result); }
@Test public void filterHeader() { List<Block> headerContent = new ArrayList<Block>(); headerContent.add(new WordBlock("header")); HeaderBlock headerBlock = new HeaderBlock(headerContent, HeaderLevel.LEVEL1); List<Block> result = filter.filter(headerBlock); assertIterableEquals(Collections.emptyList(), result); }
@Test public void filterLinkWithLabel() { Block labelBlock = new WordBlock("label"); ResourceReference reference = new ResourceReference("file name.txt", ResourceType.ATTACHMENT); LinkBlock labeledLink = new LinkBlock(Collections.singletonList(labelBlock), reference, false); List<Block> result = filter.filter(labeledLink); assertIterableEquals(Collections.emptyList(), result); }
@Test public void filterLinkWithoutLabel() { ResourceReference reference = new ResourceReference("file name.txt", ResourceType.ATTACHMENT); LinkBlock emptyLink = new LinkBlock(Collections.emptyList(), reference, false); List<Block> result = filter.filter(emptyLink); assertIterableEquals(Collections.singletonList(new WordBlock("file name.txt")), result); }
@Test public void filterEmptyLink() { ResourceReference reference = new ResourceReference("", ResourceType.ATTACHMENT); LinkBlock emptyLink = new LinkBlock(Collections.emptyList(), reference, false); List<Block> result = filter.filter(emptyLink); assertIterableEquals(Collections.emptyList(), result); }