FoamEvent { public void track(Activity activity, String event){ if(activity != null) { track(activity.getApplication(), activity, event); } }  void track(Activity activity, String event); void track(android.app.Service service, String event);  }
@Test public void testTrack() { FoamEvent foamEvent = new FoamEvent(); Context mockContext = mock(Context.class); FoamMain mockFoamMain = mock(FoamMain.class); MockApplication mockApplication = new MockApplication(mockFoamMain); foamEvent.track(mockApplication, mockContext, "unit_testing_event"); verify(mockFoamMain).logEvent(eq(mockContext), eq("unit_testing_event")); }