RapidFtrApplication extends Application { public boolean cleanSyncTask() { boolean syncInProgress = (syncTask != null || asyncTaskWithDialog != null); if (syncTask != null) { syncTask.cancel(false); NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(SynchronisationAsyncTask.NOTIFICATION_ID); syncTask = null; } if (asyncTaskWithDialog != null) { asyncTaskWithDialog.cancel(); asyncTaskWithDialog = null; } return syncInProgress; } RapidFtrApplication();  RapidFtrApplication(Injector injector); T getBean(Class<T> type); SharedPreferences getSharedPreferences(); @Override void onCreate(); void setCurrentUser(User user); User getUserFromSharedPreference(); boolean isLoggedIn(); static String getDefaultLocale(); boolean cleanSyncTask(); boolean isOnline(); void showNotification(int notificationId, String title, String statusText); void showProgressNotification(int notificationId, String title,
                                         String text, int max, int progress, boolean indeterminate); void cancelNotification(int notificationId); String getLanguageOfCurrentUser(); static final String SHARED_PREFERENCES_FILE; static final String APP_IDENTIFIER; static final String CURRENT_USER_PREF; static final String SERVER_URL_PREF; static final String LAST_CHILD_SYNC; static final String LAST_ENQUIRY_SYNC; static final String LAST_POTENTIAL_MATCH_SYNC; static final String DEFAULT_LANGUAGE; }
@Test public void shouldCleanAsyncTask() { AsyncTaskWithDialog mockAsyncTaskWithDialog = mock(AsyncTaskWithDialog.class); SynchronisationAsyncTask mockSyncTask = mock(SynchronisationAsyncTask.class); NotificationManager mockNotification = mock(NotificationManager.class); application.setAsyncTaskWithDialog(mockAsyncTaskWithDialog); application.setSyncTask(mockSyncTask); doReturn(mockNotification).when(application).getSystemService(Context.NOTIFICATION_SERVICE); assertTrue(application.cleanSyncTask()); verify(mockAsyncTaskWithDialog).cancel(); verify(mockSyncTask).cancel(false); verify(mockNotification).cancel(SynchronisationAsyncTask.NOTIFICATION_ID); }