### Question:
MapboxTelemetry implements FullQueueCallback, ServiceTaskCallback { public boolean updateAccessToken(String accessToken) { if (isAccessTokenValid(accessToken) && updateTelemetryClient(accessToken)) { sAccessToken.set(accessToken); return true; } return false; } MapboxTelemetry(Context context, String accessToken, String userAgent);   MapboxTelemetry(Context context, String accessToken, String userAgent, EventsQueue queue,
                  TelemetryClient telemetryClient, Callback httpCallback, SchedulerFlusher schedulerFlusher,
                  Clock clock, TelemetryEnabler telemetryEnabler, ExecutorService executorService); @Override // Callback is dispatched on background thread void onFullQueue(List<Event> fullQueue); @Override void onTaskRemoved(); boolean push(Event event); boolean enable(); boolean disable(); boolean updateSessionIdRotationInterval(SessionInterval interval); void updateDebugLoggingEnabled(boolean isDebugLoggingEnabled); void updateUserAgent(String userAgent); boolean updateAccessToken(String accessToken); boolean addTelemetryListener(TelemetryListener listener); boolean removeTelemetryListener(TelemetryListener listener); boolean addAttachmentListener(AttachmentListener listener); boolean removeAttachmentListener(AttachmentListener listener); @SuppressWarnings("WeakerAccess") @Deprecated synchronized boolean setBaseUrl(String eventsHost); boolean isCnRegion(); synchronized void setCnRegion(boolean setCnRegion);  }### Answer:
@Test public void checksAccessTokenUpdated() throws Exception { TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class); MapboxTelemetry theMapboxTelemetry = obtainMapboxTelemetryWith(mockedTelemetryClient); String anotherValidAccessToken = "anotherValidAccessToken"; boolean updatedAccessToken = theMapboxTelemetry.updateAccessToken(anotherValidAccessToken); verify(mockedTelemetryClient, times(1)).updateAccessToken(eq(anotherValidAccessToken)); assertTrue(updatedAccessToken); }
@Test public void checksAccessTokenNotUpdatedWhenAccessTokenNull() throws Exception { TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class); MapboxTelemetry theMapboxTelemetry = obtainMapboxTelemetryWith(mockedTelemetryClient); String nullAccessToken = null; boolean updatedAccessToken = theMapboxTelemetry.updateAccessToken(nullAccessToken); assertFalse(updatedAccessToken); }
@Test public void checksAccessTokenNotUpdatedWhenAccessTokenEmpty() throws Exception { TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class); MapboxTelemetry theMapboxTelemetry = obtainMapboxTelemetryWith(mockedTelemetryClient); String emptyAccessToken = ""; boolean updatedAccessToken = theMapboxTelemetry.updateAccessToken(emptyAccessToken); assertFalse(updatedAccessToken); }
@Test public void checksAccessTokenNotUpdatedWhenTelemetryClientNull() throws Exception { TelemetryClient nullTelemetryClient = null; MapboxTelemetry theMapboxTelemetry = obtainMapboxTelemetryWith(nullTelemetryClient); String anotherValidAccessToken = "anotherValidAccessToken"; boolean updatedAccessToken = theMapboxTelemetry.updateAccessToken(anotherValidAccessToken); assertFalse(updatedAccessToken); }