@Test public void testErrorNotification() { reporter.logError("Unexpected Error"); reporter.finish(); String json = writer.toString(); JSONObject jsonObject = new JSONObject(json); JSONObject run = jsonObject.getJSONArray("runs").getJSONObject(0); JSONArray toolExecutionNotifications = run.getJSONArray("invocations") .getJSONObject(0) .getJSONArray("toolExecutionNotifications"); assertThat(toolExecutionNotifications.length(), is(1)); JSONObject notification = toolExecutionNotifications.getJSONObject(0); assertThat(notification.getJSONObject("descriptor").getString("id"), is("spotbugs-error-0")); assertThat(notification.getJSONObject("message").getString("text"), is("Unexpected Error")); assertFalse(notification.has("exception")); }
@Override public void finish() { try { JSONWriter jsonWriter = new JSONWriter(outputStream); jsonWriter.object(); jsonWriter.key("version").value("2.1.0").key("$schema").value( "https: processRuns(jsonWriter); jsonWriter.endObject(); getBugCollection().bugsPopulated(); } finally { outputStream.close(); } }
SarifBugReporter extends BugCollectionBugReporter { @Override public void finish() { try { JSONWriter jsonWriter = new JSONWriter(outputStream); jsonWriter.object(); jsonWriter.key("version").value("2.1.0").key("$schema").value( "https: processRuns(jsonWriter); jsonWriter.endObject(); getBugCollection().bugsPopulated(); } finally { outputStream.close(); } } }
SarifBugReporter extends BugCollectionBugReporter { @Override public void finish() { try { JSONWriter jsonWriter = new JSONWriter(outputStream); jsonWriter.object(); jsonWriter.key("version").value("2.1.0").key("$schema").value( "https: processRuns(jsonWriter); jsonWriter.endObject(); getBugCollection().bugsPopulated(); } finally { outputStream.close(); } } SarifBugReporter(Project project); }
SarifBugReporter extends BugCollectionBugReporter { @Override public void finish() { try { JSONWriter jsonWriter = new JSONWriter(outputStream); jsonWriter.object(); jsonWriter.key("version").value("2.1.0").key("$schema").value( "https: processRuns(jsonWriter); jsonWriter.endObject(); getBugCollection().bugsPopulated(); } finally { outputStream.close(); } } SarifBugReporter(Project project); @Override void finish(); }
SarifBugReporter extends BugCollectionBugReporter { @Override public void finish() { try { JSONWriter jsonWriter = new JSONWriter(outputStream); jsonWriter.object(); jsonWriter.key("version").value("2.1.0").key("$schema").value( "https: processRuns(jsonWriter); jsonWriter.endObject(); getBugCollection().bugsPopulated(); } finally { outputStream.close(); } } SarifBugReporter(Project project); @Override void finish();  }