Tracklytics implements AspectListener { public void trackEvent(String eventName) { trackEvent(new Event(eventName, null, null, null, superAttributes)); } private  Tracklytics(EventSubscriber eventSubscriber); static Tracklytics init(EventSubscriber eventSubscriber); void trackEvent(String eventName); void trackEvent(String eventName, Map<String, Object> attributes); void setEventLogListener(EventLogListener logger); void addSuperAttribute(String key, Object value); void removeSuperAttribute(String key); @Override void onAspectEventTriggered(TrackEvent trackEvent, Map<String, Object> attributes); @Override void onAspectSuperAttributeAdded(String key, Object value); @Override void onAspectSuperAttributeRemoved(String key);  }
@Test public void trackWithoutAnnotation() { Map<String, Object> attributes = new HashMap<>(); attributes.put("key", "value"); tracklytics.trackEvent("event_name", attributes); verify(eventSubscriber).onEventTracked(eventCaptor.capture()); assertThat(eventCaptor.getValue().name).isEqualTo("event_name"); assertThat(eventCaptor.getValue().attributes).containsExactly("key", "value"); }
@Test public void trackWithEvent() { tracklytics.trackEvent("event_name"); verify(eventSubscriber).onEventTracked(eventCaptor.capture()); assertThat(eventCaptor.getValue().name).isEqualTo("event_name"); assertThat(eventCaptor.getValue().attributes).isNull(); }