CoredumpGatherer { public static JSONObject gatherCoredumpMetrics(FileWrapper fileWrapper) { int coredumps = getNumberOfCoredumps(fileWrapper); JSONObject packet = new JSONObject(); try { packet.put("status_code", coredumps == 0 ? 0 : 1); packet.put("status_msg", coredumps == 0 ? "OK" : String.format("Found %d coredump(s)", coredumps)); packet.put("timestamp", Instant.now().getEpochSecond()); packet.put("application", "system-coredumps-processing"); } catch (JSONException e) {} return packet; }  static JSONObject gatherCoredumpMetrics(FileWrapper fileWrapper);  }
@Test public void finds_one_coredump() throws JSONException { JSONObject packet = CoredumpGatherer.gatherCoredumpMetrics(new MockFileWrapper()); assertEquals("system-coredumps-processing", packet.getString("application")); assertEquals(1, packet.getInt("status_code")); assertEquals("Found 1 coredump(s)", packet.getString("status_msg")); }