### Question:
YamlPluginOutputConverter implements PluginOutputConverter { @Override public String convert(List<Plugin> plugins) { ObjectMapper mapper = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER)) .setSerializationInclusion(JsonInclude.Include.NON_NULL); try { return mapper.writeValueAsString(mapToOutputFormat(plugins)); } catch (JsonProcessingException e) { e.printStackTrace(); return "Error converting to yaml"; } }  @Override String convert(List<Plugin> plugins);  }### Answer:
@Test public void convert() { List<Plugin> originalPlugins = singletonList(plugin("mailer", "1.31")); List<Plugin> latestVersionsOfPlugins = pm.getLatestVersionsOfPlugins(originalPlugins); String converted = new YamlPluginOutputConverter().convert(latestVersionsOfPlugins); assertThat(converted) .isEqualTo("plugins:\n" + "- artifactId: \"mailer\"\n" + " source:\n" + " version: \"1.32\"\n"); }
@Test public void convertIncrementals() { List<Plugin> originalPlugins = singletonList(plugin("workflow-support", "2.19-rc289.d09828a05a74", "org.jenkins-ci.plugins.workflow")); List<Plugin> latestVersionsOfPlugins = pm.getLatestVersionsOfPlugins(originalPlugins); String converted = new YamlPluginOutputConverter().convert(latestVersionsOfPlugins); assertThat(converted) .isEqualTo("plugins:\n" + "- artifactId: \"workflow-support\"\n" + " groupId: \"org.jenkins-ci.plugins.workflow\"\n" + " source:\n" + " version: \"2.19-rc289.d09828a05a74\"\n"); }
@Test public void convertUrl() { List<Plugin> originalPlugins = singletonList(pluginWithUrl("script-security", "http: List<Plugin> latestVersionsOfPlugins = pm.getLatestVersionsOfPlugins(originalPlugins); String converted = new YamlPluginOutputConverter().convert(latestVersionsOfPlugins); assertThat(converted) .isEqualTo("plugins:\n" + "- artifactId: \"script-security\"\n" + " source:\n" + " version: \"latest\"\n" + " url: \"http: }
@Test public void convertNoUpdates() { List<Plugin> originalPlugins = singletonList(plugin("mailer", "1.32")); List<Plugin> latestVersionsOfPlugins = pm.getLatestVersionsOfPlugins(originalPlugins); String converted = new YamlPluginOutputConverter().convert(latestVersionsOfPlugins); assertThat(converted) .isEqualTo("plugins:\n" + "- artifactId: \"mailer\"\n" + " source:\n" + " version: \"1.32\"\n"); }