UDPLoggingService extends ServiceImpl implements CrashReportingService, LoggingService { protected void sendLogEvent(String component, String message, Callback<Object> callback){ String syslogMessage = String.format(Locale.US, "<22>%s %s %s:%s", getSysLogFormattedDate(), utils.getApplicationName(context), component, message ); sendDataOverUDP(syslogMessage, callback); } UDPLoggingService(Context context); @Override void enable(String url); @Override boolean isEnabled(); void logEvent(StoredException storedException, Callback<Object> callback); void logEvent(String log);  }
@Test @SuppressWarnings("unchecked") public void testSendLogEvent() { UDPLoggingService mockUDUdpLoggingService = mock(UDPLoggingService.class); mockUDUdpLoggingService.utils = UnitTestUtils.mockUtils(); Callback mockCallback= mock(Callback.class); when(mockUDUdpLoggingService.getSysLogFormattedDate()).thenReturn("Jan 01 23:59:59"); doCallRealMethod().when(mockUDUdpLoggingService).sendLogEvent(anyString(), anyString(), any(Callback.class)); mockUDUdpLoggingService.sendLogEvent("test_component", "test_message", mockCallback); verify(mockUDUdpLoggingService).sendDataOverUDP(("<22>Jan 01 23:59:59 UnitTesting Application test_component:test_message"), mockCallback); }