Fix ldap-odm unit tests

This commit is contained in:
Moritz Halbritter
2022-10-26 14:31:06 +02:00
parent 11f3c6afe4
commit f4af3bddc1
2 changed files with 7 additions and 4 deletions

View File

@@ -4,11 +4,13 @@ import java.util.List;
import javax.naming.ldap.LdapName;
import org.springframework.aot.hint.annotation.RegisterReflectionForBinding;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.support.LdapNameBuilder;
import org.springframework.stereotype.Repository;
@Repository
@RegisterReflectionForBinding(Person.class)
public class OdmPersonDaoImpl implements PersonDao {
private final LdapTemplate ldapTemplate;

View File

@@ -9,22 +9,23 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.ldap.DataLdapTest;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.context.annotation.Import;
import static org.assertj.core.api.Assertions.assertThat;
@DataLdapTest
@Import(OdmPersonDaoImpl.class)
class DataLdapTests {
@Autowired
private LdapTemplate ldapTemplate;
private PersonDao personDao;
@Test
void saveAndLoad() throws InvalidNameException {
Person person = getPerson();
this.ldapTemplate.create(person);
this.personDao.create(person);
List<Person> persons = this.ldapTemplate.findAll(Person.class);
List<Person> persons = this.personDao.findAll();
assertThat(persons).contains(person);
}