Add Stream Support
Closes gh-586
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
* Copyright 2005-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,6 +40,7 @@ import javax.naming.Name;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.SearchControls;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
@@ -112,6 +113,18 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_LdapQuery_AttributesMapper() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = tested.searchForStream(query()
|
||||
.base(BASE_STRING)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper).collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearch_LdapQuery_AttributesMapper_FewerAttributes() {
|
||||
attributesMapper.setExpectedAttributes(new String[] {"cn"});
|
||||
@@ -125,6 +138,19 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_LdapQuery_AttributesMapper_FewerAttributes() {
|
||||
attributesMapper.setExpectedAttributes(new String[] {"cn"});
|
||||
attributesMapper.setExpectedValues(new String[]{"Some Person2"});
|
||||
|
||||
List<Object> list = tested.searchForStream(query()
|
||||
.base(BASE_STRING)
|
||||
.attributes("cn")
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper).collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearch_LdapQuery_AttributesMapper_SearchScope() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
@@ -138,6 +164,19 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_LdapQuery_AttributesMapper_SearchScope() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = tested.searchForStream(query()
|
||||
.base(BASE_STRING)
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper).collect(Collectors.toList());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearch_LdapQuery_AttributesMapper_SearchScope_CorrectBase() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
@@ -151,6 +190,19 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_LdapQuery_AttributesMapper_SearchScope_CorrectBase() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = tested.searchForStream(query()
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper).collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearch_LdapQuery_AttributesMapper_NoBase() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
@@ -162,6 +214,17 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_LdapQuery_AttributesMapper_NoBase() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = tested.searchForStream(query()
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper).collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearch_LdapQuery_AttributesMapper_DifferentBase() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
@@ -174,6 +237,18 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_LdapQuery_AttributesMapper_DifferentBase() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = tested.searchForStream(query()
|
||||
.base("ou=Norway")
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper).collect(Collectors.toList());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearch_SearchScope_AttributesMapper() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
@@ -291,6 +366,17 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_ContextMapper_LdapQuery() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = tested.searchForStream(query()
|
||||
.base(BASE_NAME)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
contextMapper).collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearch_ContextMapper_LdapQuery_NoBase() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
@@ -301,6 +387,16 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_ContextMapper_LdapQuery_NoBase() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = tested.searchForStream(query()
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
contextMapper).collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearch_ContextMapper_LdapQuery_SearchScope() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
@@ -313,6 +409,18 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_ContextMapper_LdapQuery_SearchScope() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = tested.searchForStream(query()
|
||||
.base(BASE_NAME)
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
contextMapper).collect(Collectors.toList());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearch_ContextMapper_LdapQuery_SearchScope_CorrectBase() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
@@ -325,6 +433,18 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_ContextMapper_LdapQuery_SearchScope_CorrectBase() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = tested.searchForStream(query()
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
contextMapper).collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForContext_LdapQuery() {
|
||||
DirContextOperations result = tested.searchForContext(query()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
* Copyright 2005-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,6 +37,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import javax.naming.Name;
|
||||
import javax.naming.directory.SearchControls;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
@@ -109,6 +110,18 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_LdapQuery_AttributesMapper() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = tested.searchForStream(query()
|
||||
.base(BASE_STRING)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper).collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearch_LdapQuery_AttributesMapper_FewerAttributes() {
|
||||
attributesMapper.setExpectedAttributes(new String[] {"cn"});
|
||||
@@ -122,6 +135,19 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_LdapQuery_AttributesMapper_FewerAttributes() {
|
||||
attributesMapper.setExpectedAttributes(new String[] {"cn"});
|
||||
attributesMapper.setExpectedValues(new String[]{"Some Person2"});
|
||||
|
||||
List<Object> list = tested.searchForStream(query()
|
||||
.base(BASE_STRING)
|
||||
.attributes("cn")
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper).collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearch_LdapQuery_AttributesMapper_SearchScope() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
@@ -135,6 +161,19 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_LdapQuery_AttributesMapper_SearchScope() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = tested.searchForStream(query()
|
||||
.base(BASE_STRING)
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper).collect(Collectors.toList());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearch_LdapQuery_AttributesMapper_SearchScope_CorrectBase() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
@@ -148,6 +187,19 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_LdapQuery_AttributesMapper_SearchScope_CorrectBase() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = tested.searchForStream(query()
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper).collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearch_LdapQuery_AttributesMapper_NoBase() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
@@ -159,6 +211,17 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_LdapQuery_AttributesMapper_NoBase() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = tested.searchForStream(query()
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper).collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearch_LdapQuery_AttributesMapper_DifferentBase() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
@@ -171,6 +234,18 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_LdapQuery_AttributesMapper_DifferentBase() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
|
||||
List<Object> list = tested.searchForStream(query()
|
||||
.base("ou=Norway")
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper).collect(Collectors.toList());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearch_SearchScope_AttributesMapper() {
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
@@ -288,6 +363,17 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_ContextMapper_LdapQuery() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = tested.searchForStream(query()
|
||||
.base(BASE_NAME)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
contextMapper).collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearch_ContextMapper_LdapQuery_NoBase() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
@@ -298,6 +384,16 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_ContextMapper_LdapQuery_NoBase() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = tested.searchForStream(query()
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
contextMapper).collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearch_ContextMapper_LdapQuery_SearchScope() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
@@ -310,6 +406,18 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_ContextMapper_LdapQuery_SearchScope() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = tested.searchForStream(query()
|
||||
.base(BASE_NAME)
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
contextMapper).collect(Collectors.toList());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearch_ContextMapper_LdapQuery_SearchScope_CorrectBase() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
@@ -322,6 +430,18 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForStream_ContextMapper_LdapQuery_SearchScope_CorrectBase() {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List<DirContextAdapter> list = tested.searchForStream(query()
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
contextMapper).collect(Collectors.toList());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForContext_LdapQuery() {
|
||||
DirContextOperations result = tested.searchForContext(query()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
* Copyright 2005-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,7 @@ import static org.springframework.ldap.query.LdapQueryBuilder.query;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -88,6 +89,23 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
|
||||
assertThat(person.getEntryUuid()).describedAs("The operational attribute 'entryUUID' was not set").isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindForStreamInCountry() {
|
||||
List<PersonWithDnAnnotations> persons = tested.findForStream(query()
|
||||
.base("ou=Sweden")
|
||||
.where("cn").isPresent(), PersonWithDnAnnotations.class)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
assertThat(persons).hasSize(4);
|
||||
|
||||
PersonWithDnAnnotations person = findPerson(persons, "Some Person3");
|
||||
|
||||
// Automatically calculated
|
||||
assertThat(person.getCompany()).isEqualTo("company1");
|
||||
assertThat(person.getCountry()).isEqualTo("Sweden");
|
||||
assertThat(person.getEntryUuid()).describedAs("The operational attribute 'entryUUID' was not set").isNotEmpty();
|
||||
}
|
||||
|
||||
private PersonWithDnAnnotations findPerson(List<PersonWithDnAnnotations> persons, String cn) {
|
||||
for (PersonWithDnAnnotations person : persons) {
|
||||
if(person.getCommonName().equals(cn)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
* Copyright 2005-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,7 @@ import static org.springframework.ldap.query.LdapQueryBuilder.query;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -93,6 +94,23 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
|
||||
assertThat(person.getEntryUuid()).describedAs("The operational attribute 'entryUUID' was not set").isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindForStream() {
|
||||
List<Person> persons = tested.findForStream(query()
|
||||
.where("cn").is("Some Person3"), Person.class)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
assertThat(persons).hasSize(1);
|
||||
Person person = persons.get(0);
|
||||
|
||||
assertThat(person).isNotNull();
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
assertThat(person.getEntryUuid()).describedAs("The operational attribute 'entryUUID' was not set").isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindInCountry() {
|
||||
List<Person> persons = tested.find(query()
|
||||
@@ -105,6 +123,19 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
|
||||
assertThat(person).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindForStreamInCountry() {
|
||||
List<Person> persons = tested.findForStream(query()
|
||||
.base("ou=Sweden")
|
||||
.where("cn").isPresent(), Person.class)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
assertThat(persons).hasSize(4);
|
||||
Person person = persons.get(0);
|
||||
|
||||
assertThat(person).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindAll() {
|
||||
List<Person> result = tested.findAll(Person.class);
|
||||
|
||||
Reference in New Issue
Block a user