Graphite extends ServiceImpl implements EventTrackingService { void sendUdpData(String graphiteEvent) { Socket socket = null; try { socket = sendDataOverSocket(graphiteEvent); } catch (IOException ex) { utils.logIssue("Error sending graphite event [" + graphiteEvent + "] to [" + host + ":" + port + "].", ex); } finally { closeSocket(socket); } } Graphite(Context context); @Override void enable(String url); @Override boolean isEnabled(); @Override ServiceType getServiceType(); @Override void logEvent(Context context, String event);  }
@Test public void testSendUdpData() throws IOException { Graphite graphite = mock(Graphite.class); doCallRealMethod().when(graphite).sendUdpData(anyString()); graphite.sendUdpData("test_event_string"); verify(graphite).sendDataOverSocket(eq("test_event_string")); }