YamlFileCommentInstrumenter { public String addCommentsToYamlString(@NotNull final String yamlString) { finalFileContents = new StringBuilder(); lastYamlPath = new StringBuilder(); lastNodeDepth = 0; final String[] yamlLines = splitStringByLines(yamlString); for (String line : yamlLines) { String instrumentedLine = instrumentLine(line); finalFileContents.append(instrumentedLine); } return finalFileContents.toString(); } YamlFileCommentInstrumenter(@NotNull final YamlCommentMap commentMap, final int indentLength); static YamlFileCommentInstrumenter createCommentInstrumenter(final int indentLength); void setCommentsForPath(@NotNull final String path, @NotNull final String... comments); void saveCommentsToFile(@NotNull final File yamlFile); String addCommentsToYamlString(@NotNull final String yamlString);  }
@Test public void testNoComments() throws Exception { YamlFileCommentInstrumenter commentInstrumenter = new YamlFileCommentInstrumenter(YamlCommentMap.getYamlCommentMap(INDENT_LENGTH, '.'), INDENT_LENGTH); String instrumentedContents = commentInstrumenter.addCommentsToYamlString(TEST_CONTENTS_1); assertEquals(TEST_CONTENTS_1, instrumentedContents); }