Tracer { public static void logEvent(String type, String name) { try { getProducer().logEvent(type, name); } catch (Throwable ex) { logger.warn("Failed to log event for type: {}, name: {}", type, name, 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 testLogEvent() throws Exception { String someType = "someType"; String someName = "someName"; Tracer.logEvent(someType, someName); verify(someProducer, times(1)).logEvent(someType, someName); }
@Test public void testLogEventWithException() throws Exception { String someType = "someType"; String someName = "someName"; doThrow(RuntimeException.class).when(someProducer).logEvent(someType, someName); Tracer.logEvent(someType, someName); verify(someProducer, times(1)).logEvent(someType, someName); }
@Test public void testLogEventWithStatusAndNameValuePairs() throws Exception { String someType = "someType"; String someName = "someName"; String someStatus = "someStatus"; String someNameValuePairs = "someNameValuePairs"; Tracer.logEvent(someType, someName, someStatus, someNameValuePairs); verify(someProducer, times(1)).logEvent(someType, someName, someStatus, someNameValuePairs); }
@Test public void testLogEventWithStatusAndNameValuePairsWithException() throws Exception { String someType = "someType"; String someName = "someName"; String someStatus = "someStatus"; String someNameValuePairs = "someNameValuePairs"; doThrow(RuntimeException.class).when(someProducer).logEvent(someType, someName, someStatus, someNameValuePairs); Tracer.logEvent(someType, someName, someStatus, someNameValuePairs); verify(someProducer, times(1)).logEvent(someType, someName, someStatus, someNameValuePairs); }