### Question:
OidcAuthenticationService implements AuthenticationService { @Override public boolean isSpecified() { return OidcUtil.isOidcAvailable(config, oidcConfiguration) && accessToken != null; } OidcAuthenticationService(final String accessToken);   OidcAuthenticationService(final Config config, final OidcConfiguration oidcConfiguration, final String accessToken); @Override boolean isSpecified(); @Nullable @Override Principal authenticate();  }### Answer:
@Test public void isSpecifiedShouldReturnFalseWhenOidcIsDisabled() { when(configMock.getPropertyAsBoolean(eq(Config.AlpineKey.OIDC_ENABLED))) .thenReturn(false); final OidcAuthenticationService authService = new OidcAuthenticationService(configMock, oidcConfigurationMock, ACCESS_TOKEN); assertThat(authService.isSpecified()).isFalse(); }
@Test public void isSpecifiedShouldReturnFalseWhenAccessTokenIsNull() { when(configMock.getPropertyAsBoolean(eq(Config.AlpineKey.OIDC_ENABLED))) .thenReturn(true); final OidcAuthenticationService authService = new OidcAuthenticationService(configMock, oidcConfigurationMock, null); assertThat(authService.isSpecified()).isFalse(); }
@Test public void isSpecifiedShouldReturnFalseWhenOidcConfigurationIsNull() { when(configMock.getPropertyAsBoolean(eq(Config.AlpineKey.OIDC_ENABLED))) .thenReturn(true); final OidcAuthenticationService authService = new OidcAuthenticationService(configMock, null, ACCESS_TOKEN); assertThat(authService.isSpecified()).isFalse(); }
@Test public void isSpecifiedShouldReturnTrueWhenOidcIsEnabledAndOidcConfigurationIsNotNullAndAccessTokenIsNotNull() { when(configMock.getPropertyAsBoolean(eq(Config.AlpineKey.OIDC_ENABLED))) .thenReturn(true); final OidcAuthenticationService authService = new OidcAuthenticationService(configMock, oidcConfigurationMock, ACCESS_TOKEN); assertThat(authService.isSpecified()).isTrue(); }