@@ -137,6 +137,21 @@ void usesCustomConnectionDetailsWhenDefined() {
137
137
});
138
138
}
139
139
140
+ @ Test
141
+ void objectDirectoryMapperExists () {
142
+ this .contextRunner .withPropertyValues ("spring.ldap.urls:ldap://localhost:389" ).run ((context ) -> {
143
+ assertThat (context ).hasSingleBean (ObjectDirectoryMapper .class );
144
+ ObjectDirectoryMapper objectDirectoryMapper = context .getBean (ObjectDirectoryMapper .class );
145
+ ApplicationConversionService conversionService = assertThat (objectDirectoryMapper )
146
+ .extracting ("converterManager" )
147
+ .extracting ("conversionService" )
148
+ .asInstanceOf (InstanceOfAssertFactories .type (ApplicationConversionService .class ))
149
+ .actual ();
150
+ assertThat (conversionService .canConvert (String .class , Name .class )).isTrue ();
151
+ assertThat (conversionService .canConvert (Name .class , String .class )).isTrue ();
152
+ });
153
+ }
154
+
140
155
@ Test
141
156
void templateExists () {
142
157
this .contextRunner .withPropertyValues ("spring.ldap.urls:ldap://localhost:389" ).run ((context ) -> {
@@ -145,9 +160,23 @@ void templateExists() {
145
160
assertThat (ldapTemplate ).hasFieldOrPropertyWithValue ("ignorePartialResultException" , false );
146
161
assertThat (ldapTemplate ).hasFieldOrPropertyWithValue ("ignoreNameNotFoundException" , false );
147
162
assertThat (ldapTemplate ).hasFieldOrPropertyWithValue ("ignoreSizeLimitExceededException" , true );
163
+ assertThat (ldapTemplate ).extracting ("objectDirectoryMapper" )
164
+ .isSameAs (context .getBean (ObjectDirectoryMapper .class ));
148
165
});
149
166
}
150
167
168
+ @ Test
169
+ void templateCanBeConfiguredWithCustomObjectDirectoryMapper () {
170
+ ObjectDirectoryMapper objectDirectoryMapper = mock (ObjectDirectoryMapper .class );
171
+ this .contextRunner .withPropertyValues ("spring.ldap.urls:ldap://localhost:389" )
172
+ .withBean (ObjectDirectoryMapper .class , () -> objectDirectoryMapper )
173
+ .run ((context ) -> {
174
+ assertThat (context ).hasSingleBean (LdapTemplate .class );
175
+ LdapTemplate ldapTemplate = context .getBean (LdapTemplate .class );
176
+ assertThat (ldapTemplate ).extracting ("objectDirectoryMapper" ).isSameAs (objectDirectoryMapper );
177
+ });
178
+ }
179
+
151
180
@ Test
152
181
void templateConfigurationCanBeCustomized () {
153
182
this .contextRunner
@@ -199,36 +228,6 @@ void contextSourceWithCustomNonUniqueDirContextAuthenticationStrategy() {
199
228
});
200
229
}
201
230
202
- @ Test
203
- void objectDirectoryMapperBeanAutoConfigured () {
204
- this .contextRunner .withPropertyValues ("spring.ldap.urls:ldap://localhost:389" ).run ((context ) -> {
205
- assertThat (context ).hasSingleBean (ObjectDirectoryMapper .class );
206
- assertThat (context ).hasSingleBean (LdapTemplate .class );
207
- ObjectDirectoryMapper objectDirectoryMapper = context .getBean (ObjectDirectoryMapper .class );
208
- LdapTemplate ldapTemplate = context .getBean (LdapTemplate .class );
209
- ApplicationConversionService conversionService = assertThat (objectDirectoryMapper )
210
- .extracting ("converterManager" )
211
- .extracting ("conversionService" )
212
- .asInstanceOf (InstanceOfAssertFactories .type (ApplicationConversionService .class ))
213
- .actual ();
214
- assertThat (conversionService .canConvert (String .class , Name .class )).isTrue ();
215
- assertThat (conversionService .canConvert (Name .class , String .class )).isTrue ();
216
- assertThat (ldapTemplate ).extracting ("objectDirectoryMapper" ).isSameAs (objectDirectoryMapper );
217
- });
218
- }
219
-
220
- @ Test
221
- void customObjectDirectoryMapperBeanCanBeUsed () {
222
- ObjectDirectoryMapper objectDirectoryMapper = mock (ObjectDirectoryMapper .class );
223
- this .contextRunner .withPropertyValues ("spring.ldap.urls:ldap://localhost:389" )
224
- .withBean (ObjectDirectoryMapper .class , () -> objectDirectoryMapper )
225
- .run ((context ) -> {
226
- assertThat (context ).hasSingleBean (LdapTemplate .class );
227
- LdapTemplate ldapTemplate = context .getBean (LdapTemplate .class );
228
- assertThat (ldapTemplate ).extracting ("objectDirectoryMapper" ).isSameAs (objectDirectoryMapper );
229
- });
230
- }
231
-
232
231
@ Configuration (proxyBeanMethods = false )
233
232
static class ConnectionDetailsConfiguration {
234
233
0 commit comments