use of edu.umd.cs.findbugs.PluginLoader in project spotbugs by spotbugs.
the class SarifBugReporterTest method testExtensions.
@Test
public void testExtensions() throws PluginException {
PluginLoader pluginLoader = DetectorFactoryCollection.instance().getCorePlugin().getPluginLoader();
Plugin plugin = new Plugin("pluginId", "version", null, pluginLoader, true, false);
DetectorFactoryCollection dfc = new DetectorFactoryCollection(plugin);
try {
DetectorFactoryCollection.resetInstance(dfc);
reporter.finish();
} finally {
DetectorFactoryCollection.resetInstance(null);
}
String json = writer.toString();
JsonObject jsonObject = new Gson().fromJson(json, JsonObject.class);
JsonObject run = jsonObject.getAsJsonArray("runs").get(0).getAsJsonObject();
JsonObject tool = run.getAsJsonObject("tool");
JsonArray extensions = tool.getAsJsonArray("extensions");
assertThat(extensions.size(), is(1));
JsonObject extension = extensions.get(0).getAsJsonObject();
assertThat(extension.get("name").getAsString(), is("pluginId"));
assertThat(extension.get("version").getAsString(), is("version"));
}
Aggregations