LdapIdentityProviderConfigValidator extends BaseIdentityProviderValidator { @Override public void validate(IdentityProvider<? extends AbstractIdentityProviderDefinition> provider) { super.validate(provider); if (!LDAP.equals(provider.getOriginKey())) { throw new IllegalArgumentException(String.format("LDAP provider originKey must be set to '%s'", LDAP)); } }  @Override void validate(IdentityProvider<? extends AbstractIdentityProviderDefinition> provider); @Override void validate(AbstractIdentityProviderDefinition definition);  }
@Test public void null_identity_provider() { exception.expect(IllegalArgumentException.class); exception.expectMessage("Provider cannot be null"); validator.validate((IdentityProvider<AbstractIdentityProviderDefinition>) null); }
@Test public void invalid_ldap_origin() { IdentityProvider<LdapIdentityProviderDefinition> ldap = new IdentityProvider<>(); ldap.setType(LDAP); ldap.setOriginKey("other"); exception.expect(IllegalArgumentException.class); exception.expectMessage(String.format("LDAP provider originKey must be set to '%s'", LDAP)); validator.validate(ldap); }
@Test public void valid_ldap_origin() { IdentityProvider<LdapIdentityProviderDefinition> ldap = new IdentityProvider<>(); ldap.setType(LDAP); ldap.setOriginKey(LDAP); doNothing().when(validator).validate(any(AbstractIdentityProviderDefinition.class)); validator.validate(ldap); verify(validator, times(1)).validate((AbstractIdentityProviderDefinition) isNull()); }