Skip to content

DATAKV-330 - Implement CrudRepository.delete(Iterable<ID> ids). #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-keyvalue</artifactId>
<version>2.5.0-SNAPSHOT</version>
<version>2.5.0-DATAKV-330-SNAPSHOT</version>

<name>Spring Data KeyValue</name>

Expand All @@ -17,7 +17,7 @@
</parent>

<properties>
<springdata.commons>2.5.0-SNAPSHOT</springdata.commons>
<springdata.commons>2.4.0-DATACMNS-800-SNAPSHOT</springdata.commons>
<java-module-name>spring.data.keyvalue</java-module-name>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ public void deleteAll(Iterable<? extends T> entities) {
entities.forEach(this::delete);
}

@Override
public void deleteAllById(Iterable<? extends ID> ids) {

Assert.notNull(ids, "The given Iterable of Ids must not be null!");

ids.forEach(this::deleteById);
}

/*
* (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#deleteAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.springframework.data.keyvalue.repository;

import static java.util.Arrays.*;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
Expand Down Expand Up @@ -46,6 +47,7 @@
/**
* @author Christoph Strobl
* @author Eugene Nikiforov
* @author Jens Schauder
*/
@RunWith(MockitoJUnitRunner.class)
public class SimpleKeyValueRepositoryUnitTests {
Expand Down Expand Up @@ -94,7 +96,7 @@ public void multipleSave() {
Foo one = new Foo("one");
Foo two = new Foo("two");

repo.saveAll(Arrays.asList(one, two));
repo.saveAll(asList(one, two));
verify(opsMock, times(1)).insert(eq(one));
verify(opsMock, times(1)).insert(eq(two));
}
Expand All @@ -118,6 +120,15 @@ public void deleteById() {
verify(opsMock, times(1)).delete(eq("one"), eq(Foo.class));
}

@Test // DATAKV-330
public void deleteAllById() {

repo.deleteAllById(asList("one", "two"));

verify(opsMock, times(1)).delete(eq("one"), eq(Foo.class));
verify(opsMock, times(1)).delete(eq("two"), eq(Foo.class));
}

@Test // DATACMNS-525
public void deleteAll() {

Expand All @@ -131,7 +142,7 @@ public void deleteAll() {
public void findAllIds() {

when(opsMock.findById(any(), any(Class.class))).thenReturn(Optional.empty());
repo.findAllById(Arrays.asList("one", "two", "three"));
repo.findAllById(asList("one", "two", "three"));

verify(opsMock, times(3)).findById(anyString(), eq(Foo.class));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
* @author Oliver Gierke
* @author Thomas Darimont
* @author Mark Paluch
* @author Jens Schauder
*/
public abstract class AbstractRepositoryUnitTests<T extends AbstractRepositoryUnitTests.PersonRepository> {

Expand Down