PagerDuty extends ServiceImpl implements CrashReportingService { public void logEvent(StoredException storedException, Callback<Object> callback) { PagerDutyEvent pagerDutyEvent = createEvent(storedException); createService().createEvent(pagerDutyEvent, callback); } PagerDuty(Context context); void enable(String apiKey); boolean isEnabled(); @Override ServiceType getServiceType(); void logEvent(StoredException storedException, Callback<Object> callback);  }
@Test @SuppressWarnings("unchecked") public void testLogEvent() { PagerDuty.PagerDutyService mockPagerDutyService = mock(PagerDuty.PagerDutyService.class); Callback mockCallback = mock(Callback.class); PagerDuty pagerDuty = new PagerDuty(null); pagerDuty.apiKey = "unit_test_api_key"; pagerDuty.pagerDutyService = mockPagerDutyService; StoredException storedException = new StoredException(ServiceType.MIXPANEL, "test message", "test threadName", "test\nstack\ntrace"); pagerDuty.logEvent(storedException, mockCallback); ArgumentCaptor<PagerDuty.PagerDutyEvent> eventArgumentCaptor = ArgumentCaptor.forClass(PagerDuty.PagerDutyEvent.class); verify(mockPagerDutyService).createEvent(eventArgumentCaptor.capture(), eq(mockCallback)); assertEquals("unit_test_api_key", eventArgumentCaptor.getValue().service_key); assertEquals("trigger", eventArgumentCaptor.getValue().event_type); assertEquals("test message", eventArgumentCaptor.getValue().incident_key); assertEquals("test\nstack\ntrace", eventArgumentCaptor.getValue().description); }