Tracer { public static void logError(String message, Throwable cause) { try { getProducer().logError(message, cause); } catch (Throwable ex) { logger.warn("Failed to log error for message: {}, cause: {}", message, cause, ex); } }  static void logError(String message, Throwable cause); static void logError(Throwable cause); static void logEvent(String type, String name); static void logEvent(String type, String name, String status, String nameValuePairs); static Transaction newTransaction(String type, String name);  }
@Test public void testLogError() throws Exception { String someMessage = "someMessage"; Throwable someCause = mock(Throwable.class); Tracer.logError(someMessage, someCause); verify(someProducer, times(1)).logError(someMessage, someCause); }
@Test public void testLogErrorWithException() throws Exception { String someMessage = "someMessage"; Throwable someCause = mock(Throwable.class); doThrow(RuntimeException.class).when(someProducer).logError(someMessage, someCause); Tracer.logError(someMessage, someCause); verify(someProducer, times(1)).logError(someMessage, someCause); }
@Test public void testLogErrorWithOnlyCause() throws Exception { Throwable someCause = mock(Throwable.class); Tracer.logError(someCause); verify(someProducer, times(1)).logError(someCause); }
@Test public void testLogErrorWithOnlyCauseWithException() throws Exception { Throwable someCause = mock(Throwable.class); doThrow(RuntimeException.class).when(someProducer).logError(someCause); Tracer.logError(someCause); verify(someProducer, times(1)).logError(someCause); }