AnalyticsTransmissionTarget { public static synchronized void addAuthenticationProvider(final AuthenticationProvider authenticationProvider) { if (authenticationProvider == null) { AppCenterLog.error(LOG_TAG, "Authentication provider may not be null."); return; } if (authenticationProvider.getType() == null) { AppCenterLog.error(LOG_TAG, "Authentication provider type may not be null."); return; } if (authenticationProvider.getTicketKey() == null) { AppCenterLog.error(LOG_TAG, "Authentication ticket key may not be null."); return; } if (authenticationProvider.getTokenProvider() == null) { AppCenterLog.error(LOG_TAG, "Authentication token provider may not be null."); return; } if (AppCenter.isConfigured()) { Analytics.getInstance().postCommandEvenIfDisabled(new Runnable() { @Override public void run() { updateProvider(authenticationProvider); } }); } else { updateProvider(authenticationProvider); } } AnalyticsTransmissionTarget(@NonNull String transmissionTargetToken, final AnalyticsTransmissionTarget parentTarget); static synchronized void addAuthenticationProvider(final AuthenticationProvider authenticationProvider); void trackEvent(String name); void trackEvent(String name, Map<String, String> properties); void trackEvent(String name, Map<String, String> properties, int flags); void trackEvent(String name, EventProperties properties); void trackEvent(String name, EventProperties properties, int flags); synchronized AnalyticsTransmissionTarget getTransmissionTarget(String transmissionTargetToken); AppCenterFuture<Boolean> isEnabledAsync(); AppCenterFuture<Void> setEnabledAsync(final boolean enabled); void pause(); void resume(); PropertyConfigurator getPropertyConfigurator();  }
@Test public void addAuthenticationProvider() { AnalyticsTransmissionTarget.addAuthenticationProvider(null); assertNull(AnalyticsTransmissionTarget.sAuthenticationProvider); AuthenticationProvider authenticationProvider = mock(AuthenticationProvider.class); AnalyticsTransmissionTarget.addAuthenticationProvider(authenticationProvider); assertNull(AnalyticsTransmissionTarget.sAuthenticationProvider); verify(authenticationProvider, never()).acquireTokenAsync(); when(authenticationProvider.getType()).thenReturn(AuthenticationProvider.Type.MSA_COMPACT); AnalyticsTransmissionTarget.addAuthenticationProvider(authenticationProvider); assertNull(AnalyticsTransmissionTarget.sAuthenticationProvider); verify(authenticationProvider, never()).acquireTokenAsync(); when(authenticationProvider.getTicketKey()).thenReturn("key1"); AnalyticsTransmissionTarget.addAuthenticationProvider(authenticationProvider); assertNull(AnalyticsTransmissionTarget.sAuthenticationProvider); verify(authenticationProvider, never()).acquireTokenAsync(); when(authenticationProvider.getTokenProvider()).thenReturn(mock(AuthenticationProvider.TokenProvider.class)); AnalyticsTransmissionTarget.addAuthenticationProvider(authenticationProvider); assertEquals(authenticationProvider, AnalyticsTransmissionTarget.sAuthenticationProvider); verify(authenticationProvider).acquireTokenAsync(); AnalyticsTransmissionTarget.addAuthenticationProvider(null); AuthenticationProvider authenticationProvider2 = mock(AuthenticationProvider.class); when(authenticationProvider2.getType()).thenReturn(AuthenticationProvider.Type.MSA_COMPACT); when(authenticationProvider2.getTicketKey()).thenReturn("key2"); AnalyticsTransmissionTarget.addAuthenticationProvider(authenticationProvider2); assertEquals(authenticationProvider, AnalyticsTransmissionTarget.sAuthenticationProvider); verify(authenticationProvider2, never()).acquireTokenAsync(); when(authenticationProvider2.getTokenProvider()).thenReturn(mock(AuthenticationProvider.TokenProvider.class)); AnalyticsTransmissionTarget.addAuthenticationProvider(authenticationProvider2); assertEquals(authenticationProvider2, AnalyticsTransmissionTarget.sAuthenticationProvider); verify(authenticationProvider2).acquireTokenAsync(); }