I am writing ldap query to search username from email and the method is this
final ContainerCriteria query = ldapQuery(email);
var attr = (AttributesMapper<String>) attrs -> attrs
.get("uid")
.get()
.toString()
LdapQueryBuilder
.query()
.where("objectclass")
.is("person")
.and("mail")
.is(email);
ldapTemplate.search(query, attr);
I need to unit test this method but since there is no equals method on AttributesMapper and ContainerCriteria I
@Test
public void shouldReturnUsername() {
final List<String> user = Arrays.asList("shahg");
final ContainerCriteria containerCriteria = LdapQueryBuilder
.query()
.where("objectclass")
.is("person")
.and("mail")
.is("[email protected]");
var attr = (AttributesMapper<String>) attrs -> attrs
.get("uid")
.get()
.toString()
when(dapTemplate
.search(containerCriteria, (AttributesMapper<String>) attrs -> attrs
.get("uid")
.get()
.toString()));
ldapService.getUsername("[email protected]");
}
Even though everything is same, test fails. I tried with ArgumentMatcher as well but the same result.