### Question:
WebAuthnCredentialProvider implements CredentialProvider, CredentialInputValidator, CredentialInputUpdater { @Override public boolean isConfiguredFor(RealmModel realm, UserModel user, String credentialType) { if (!supportsCredentialType(credentialType)) return false; return !session.userCredentialManager().getStoredCredentialsByType(realm, user, credentialType).isEmpty(); } WebAuthnCredentialProvider(KeycloakSession session); @Override boolean updateCredential(RealmModel realm, UserModel user, CredentialInput input); @Override void disableCredentialType(RealmModel realm, UserModel user, String credentialType); @Override Set<String> getDisableableCredentialTypes(RealmModel realm, UserModel user); @Override boolean supportsCredentialType(String credentialType); @Override boolean isConfiguredFor(RealmModel realm, UserModel user, String credentialType); @Override boolean isValid(RealmModel realm, UserModel user, CredentialInput input);  }### Answer:
@Test public void test_isConfiguredFor() { when(session.userCredentialManager() .getStoredCredentialsByType(any(RealmModel.class), any(UserModel.class), anyString()) .isEmpty()) .thenReturn(false); try { provider.isConfiguredFor(mock(RealmModel.class), mock(UserModel.class), WebAuthnCredentialModel.WEBAUTHN_CREDENTIAL_TYPE); } catch (Exception e) { Assert.fail(e.getMessage()); } }
@Test public void test_isConfiguredFor_empty() { when(session.userCredentialManager() .getStoredCredentialsByType(any(RealmModel.class), any(UserModel.class), anyString()) .isEmpty()) .thenReturn(true); try { provider.isConfiguredFor(mock(RealmModel.class), mock(UserModel.class), WebAuthnCredentialModel.WEBAUTHN_CREDENTIAL_TYPE); } catch (Exception e) { Assert.fail(e.getMessage()); } }
@Test public void test_isConfiguredFor_unknown_type() { try { provider.isConfiguredFor(mock(RealmModel.class), mock(UserModel.class), "unknown"); } catch (Exception e) { Assert.fail(e.getMessage()); } }