SurveyManager implements SurveyValidator.OnSurveyValidatedListener, WootricApiCallback, LifecycleObserver, OnSurveyFinishedListener { void showSurvey() { handler.postDelayed(surveyRunner, currentEvent.getSettings().getTimeDelayInMillis()); if (currentEvent.getSurveyCallback() != null) { currentEvent.getSurveyCallback().onSurveyWillShow(); } } private  SurveyManager(); static SurveyManager getSharedInstance(); @Override void onSurveyValidated(Settings surveyServerSettings); @Override void onSurveyNotNeeded(); @Override void onRegisteredEvents(ArrayList<String> registeredEvents); @Override void onAuthenticateSuccess(String accessToken); @Override void onGetEndUserIdSuccess(long endUserId); @Override void onEndUserNotFound(); @Override void onCreateEndUserSuccess(long endUserId); @Override void onApiError(Exception error); WootricEvent getCurrentEvent(); int eventQueueCount(); @OnLifecycleEvent(Lifecycle.Event.ON_STOP) void onBackground(); @Override void onSurveyFinished(); public Runnable surveyRunner; }
@Test public void showSurvey() throws Exception { SurveyManager surveyManager = spy(SurveyManager.getSharedInstance()); surveyManager.start(TEST_FRAGMENT_ACTIVITY, wootricApiClient, testUser(), testEndUser(), new Settings(), preferencesUtils, surveyCallback, surveyValidator); doNothing().when(surveyManager).showSurvey(); EndUser receivedEndUser = new EndUser(); receivedEndUser.setId(1); surveyManager.onCreateEndUserSuccess(receivedEndUser.getId()); assertThat(surveyManager.getCurrentEvent().getEndUser().getId()).isEqualTo(receivedEndUser.getId()); verify(surveyManager, times(1)).showSurvey(); }