TrackHelper { public static TrackHelper track() { return new TrackHelper(); } private  TrackHelper(); private  TrackHelper(@Nullable TrackMe baseTrackMe); static TrackHelper track(); static TrackHelper track(@Nullable TrackMe base); Screen screen(String path); Screen screen(Activity activity); EventBuilder event(String category, String action); Goal goal(int idGoal); Outlink outlink(URL url); Search search(String keyword); Download download(DownloadTracker downloadTracker); Download download(); ContentImpression impression(String contentName); ContentInteraction interaction(String contentName, String contentInteraction); CartUpdate cartUpdate(int grandTotal); Order order(String orderId, int grandTotal); Exception exception(Throwable throwable); UncaughtExceptions uncaughtExceptions(); @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) AppTracking screens(Application app); Dimension dimension(int id, String value); @Deprecated VisitVariables visitVariables(int id, String name, String value); @Deprecated VisitVariables visitVariables(CustomVariables customVariables);  }
@Test public void testBaseEvent_track_safely() { final TrackHelper.BaseEvent badTrackMe = new TrackHelper.BaseEvent(null) { @Override public TrackMe build() { throw new IllegalArgumentException(); } }; assertThat(badTrackMe.safelyWith(mTracker), is(false)); assertThat(badTrackMe.safelyWith(mMatomoApplication), is(false)); verify(mTracker, never()).track(any(TrackMe.class)); final TrackHelper.BaseEvent goodTrackMe = new TrackHelper.BaseEvent(null) { @Override public TrackMe build() { return new TrackMe(); } }; assertThat(goodTrackMe.safelyWith(mTracker), is(true)); verify(mTracker, times(1)).track(any(TrackMe.class)); assertThat(goodTrackMe.safelyWith(mMatomoApplication), is(true)); verify(mTracker, times(2)).track(any(TrackMe.class)); }