Search in sources :

Example 1 with Template

use of org.springframework.boot.autoconfigure.ldap.LdapProperties.Template in project spring-boot by spring-projects.

the class LdapAutoConfiguration method ldapTemplate.

@Bean
@ConditionalOnMissingBean(LdapOperations.class)
public LdapTemplate ldapTemplate(LdapProperties properties, ContextSource contextSource) {
    Template template = properties.getTemplate();
    PropertyMapper propertyMapper = PropertyMapper.get().alwaysApplyingWhenNonNull();
    LdapTemplate ldapTemplate = new LdapTemplate(contextSource);
    propertyMapper.from(template.isIgnorePartialResultException()).to(ldapTemplate::setIgnorePartialResultException);
    propertyMapper.from(template.isIgnoreNameNotFoundException()).to(ldapTemplate::setIgnoreNameNotFoundException);
    propertyMapper.from(template.isIgnoreSizeLimitExceededException()).to(ldapTemplate::setIgnoreSizeLimitExceededException);
    return ldapTemplate;
}
Also used : PropertyMapper(org.springframework.boot.context.properties.PropertyMapper) LdapTemplate(org.springframework.ldap.core.LdapTemplate) LdapTemplate(org.springframework.ldap.core.LdapTemplate) Template(org.springframework.boot.autoconfigure.ldap.LdapProperties.Template) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with Template

use of org.springframework.boot.autoconfigure.ldap.LdapProperties.Template in project spring-boot by spring-projects.

the class LdapPropertiesTests method ldapTemplatePropertiesUseConsistentLdapTemplateDefaultValues.

@Test
void ldapTemplatePropertiesUseConsistentLdapTemplateDefaultValues() {
    Template templateProperties = new LdapProperties().getTemplate();
    LdapTemplate ldapTemplate = new LdapTemplate();
    assertThat(ldapTemplate).hasFieldOrPropertyWithValue("ignorePartialResultException", templateProperties.isIgnorePartialResultException());
    assertThat(ldapTemplate).hasFieldOrPropertyWithValue("ignoreNameNotFoundException", templateProperties.isIgnoreNameNotFoundException());
    assertThat(ldapTemplate).hasFieldOrPropertyWithValue("ignoreSizeLimitExceededException", templateProperties.isIgnoreSizeLimitExceededException());
}
Also used : LdapTemplate(org.springframework.ldap.core.LdapTemplate) Template(org.springframework.boot.autoconfigure.ldap.LdapProperties.Template) LdapTemplate(org.springframework.ldap.core.LdapTemplate) Test(org.junit.jupiter.api.Test)

Aggregations

Template (org.springframework.boot.autoconfigure.ldap.LdapProperties.Template)2 LdapTemplate (org.springframework.ldap.core.LdapTemplate)2 Test (org.junit.jupiter.api.Test)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 PropertyMapper (org.springframework.boot.context.properties.PropertyMapper)1 Bean (org.springframework.context.annotation.Bean)1