DATALDAP-35 - Adapt to API changes in repository interfaces.
Related ticket: DATACMNS-944
This commit is contained in:
committed by
Oliver Gierke
parent
f566508dee
commit
4733f7e6e2
@@ -44,6 +44,7 @@ import org.springframework.util.Assert;
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @author Eddu Melendez
|
||||
* @author Mark Paluch
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
public class LdapRepositoryFactory extends RepositoryFactorySupport {
|
||||
|
||||
@@ -67,7 +68,7 @@ public class LdapRepositoryFactory extends RepositoryFactorySupport {
|
||||
* @see org.springframework.data.repository.core.support.RepositoryFactorySupport#getEntityInformation(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
public <T, ID extends Serializable> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
|
||||
public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @author Mark Paluch
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
public class SimpleLdapRepository<T> implements LdapRepository<T> {
|
||||
|
||||
@@ -112,10 +113,10 @@ public class SimpleLdapRepository<T> implements LdapRepository<T> {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.CrudRepository#save(java.lang.Iterable)
|
||||
* @see org.springframework.data.repository.CrudRepository#saveAll(java.lang.Iterable)
|
||||
*/
|
||||
@Override
|
||||
public <S extends T> Iterable<S> save(Iterable<S> entities) {
|
||||
public <S extends T> Iterable<S> saveAll(Iterable<S> entities) {
|
||||
|
||||
return StreamSupport.stream(entities.spliterator(), false) //
|
||||
.map(this::save) //
|
||||
@@ -123,10 +124,10 @@ public class SimpleLdapRepository<T> implements LdapRepository<T> {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.CrudRepository#findOne(java.io.Serializable)
|
||||
* @see org.springframework.data.repository.CrudRepository#findById(java.io.Serializable)
|
||||
*/
|
||||
@Override
|
||||
public Optional<T> findOne(Name name) {
|
||||
public Optional<T> findById(Name name) {
|
||||
|
||||
Assert.notNull(name, "Id must not be null");
|
||||
|
||||
@@ -163,14 +164,14 @@ public class SimpleLdapRepository<T> implements LdapRepository<T> {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.CrudRepository#exists(java.io.Serializable)
|
||||
* @see org.springframework.data.repository.CrudRepository#existsById(java.io.Serializable)
|
||||
*/
|
||||
@Override
|
||||
public boolean exists(Name name) {
|
||||
public boolean existsById(Name name) {
|
||||
|
||||
Assert.notNull(name, "Id must not be null");
|
||||
|
||||
return findOne(name) != null;
|
||||
return findById(name) != null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -182,22 +183,22 @@ public class SimpleLdapRepository<T> implements LdapRepository<T> {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.CrudRepository#findAll(java.lang.Iterable)
|
||||
* @see org.springframework.data.repository.CrudRepository#findAllById(java.lang.Iterable)
|
||||
*/
|
||||
@Override
|
||||
public List<T> findAll(final Iterable<Name> names) {
|
||||
public List<T> findAllById(final Iterable<Name> names) {
|
||||
|
||||
return StreamSupport.stream(names.spliterator(), false) //
|
||||
.map(this::findOne) //
|
||||
.map(this::findById) //
|
||||
.flatMap(Optionals::toStream) //
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.CrudRepository#delete(java.io.Serializable)
|
||||
* @see org.springframework.data.repository.CrudRepository#deleteById(java.io.Serializable)
|
||||
*/
|
||||
@Override
|
||||
public void delete(Name name) {
|
||||
public void deleteById(Name name) {
|
||||
|
||||
Assert.notNull(name, "Id must not be null");
|
||||
|
||||
@@ -216,10 +217,10 @@ public class SimpleLdapRepository<T> implements LdapRepository<T> {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.CrudRepository#delete(java.lang.Iterable)
|
||||
* @see org.springframework.data.repository.CrudRepository#deleteAll(java.lang.Iterable)
|
||||
*/
|
||||
@Override
|
||||
public void delete(Iterable<? extends T> entities) {
|
||||
public void deleteAll(Iterable<? extends T> entities) {
|
||||
entities.forEach(this::delete);
|
||||
}
|
||||
|
||||
@@ -228,6 +229,6 @@ public class SimpleLdapRepository<T> implements LdapRepository<T> {
|
||||
*/
|
||||
@Override
|
||||
public void deleteAll() {
|
||||
delete(findAll());
|
||||
deleteAll(findAll());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ import org.springframework.ldap.support.LdapUtils;
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @author Mark Paluch
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SimpleLdapRepositoryTests {
|
||||
@@ -163,7 +164,7 @@ public class SimpleLdapRepositoryTests {
|
||||
|
||||
when(ldapOperationsMock.findByDn(expectedName, Object.class)).thenReturn(expectedResult);
|
||||
|
||||
Optional<Object> actualResult = tested.findOne(expectedName);
|
||||
Optional<Object> actualResult = tested.findById(expectedName);
|
||||
|
||||
assertThat(actualResult).contains(expectedResult);
|
||||
}
|
||||
@@ -175,7 +176,7 @@ public class SimpleLdapRepositoryTests {
|
||||
|
||||
when(ldapOperationsMock.findByDn(expectedName, Object.class)).thenThrow(new NameNotFoundException(""));
|
||||
|
||||
Optional<Object> actualResult = tested.findOne(expectedName);
|
||||
Optional<Object> actualResult = tested.findById(expectedName);
|
||||
|
||||
assertThat(actualResult).isNotPresent();
|
||||
}
|
||||
@@ -187,7 +188,7 @@ public class SimpleLdapRepositoryTests {
|
||||
|
||||
when(ldapOperationsMock.findByDn(expectedName, Object.class)).thenReturn(null);
|
||||
|
||||
Optional<Object> actualResult = tested.findOne(expectedName);
|
||||
Optional<Object> actualResult = tested.findById(expectedName);
|
||||
|
||||
assertThat(actualResult).isNotPresent();
|
||||
}
|
||||
@@ -204,7 +205,7 @@ public class SimpleLdapRepositoryTests {
|
||||
when(ldapOperationsMock.findByDn(expectedName1, Object.class)).thenReturn(expectedResult1);
|
||||
when(ldapOperationsMock.findByDn(expectedName2, Object.class)).thenReturn(expectedResult2);
|
||||
|
||||
Iterable<Object> actualResult = tested.findAll(Arrays.asList(expectedName1, expectedName2));
|
||||
Iterable<Object> actualResult = tested.findAllById(Arrays.asList(expectedName1, expectedName2));
|
||||
|
||||
Iterator<Object> iterator = actualResult.iterator();
|
||||
assertThat(iterator.next()).isSameAs(expectedResult1);
|
||||
@@ -224,7 +225,7 @@ public class SimpleLdapRepositoryTests {
|
||||
when(ldapOperationsMock.findByDn(expectedName1, Object.class)).thenReturn(null);
|
||||
when(ldapOperationsMock.findByDn(expectedName2, Object.class)).thenReturn(expectedResult2);
|
||||
|
||||
Iterable<Object> actualResult = tested.findAll(Arrays.asList(expectedName1, expectedName2));
|
||||
Iterable<Object> actualResult = tested.findAllById(Arrays.asList(expectedName1, expectedName2));
|
||||
|
||||
Iterator<Object> iterator = actualResult.iterator();
|
||||
assertThat(iterator.next()).isSameAs(expectedResult2);
|
||||
|
||||
Reference in New Issue
Block a user