CommentMapper implements Commentable { @Override public String getComment(final String path, final CommentType type) { final KeyTree.Node node = this.getNode(path); if (node == null) { return null; } String comment = type == CommentType.BLOCK ? node.getComment() : node.getSideComment(); if (comment != null) { comment = comment.replaceAll("[ \\t]*#+[ \\t]*", "").trim(); } return comment; } CommentMapper(final YamlConfigurationOptions options); @Override void setComment(final String path, String comment, final CommentType type); @Override String getComment(final String path, final CommentType type);  }
@Test void getComment() { final YamlConfiguration configuration = new YamlConfiguration(); final YamlConfigurationOptions options = new TestYamlConfigurationOptions(configuration); final CommentMapper mapper = new CommentMapper(options); MatcherAssert.assertThat( "There is a comment on test path", mapper.getComment("test"), new IsNull<>() ); mapper.setComment("test", "test_comment"); MatcherAssert.assertThat( "There is a comment on test path", mapper.getComment("test"), new IsNot<>(new IsNull<>()) ); }