DATAES-937 - Repository queries with IN filters fail with empty input list.

Original PR: #525
This commit is contained in:
Peter-Josef Meisch
2020-09-24 22:14:56 +02:00
committed by GitHub
parent 8d4c305732
commit 7117e5d70d
3 changed files with 32 additions and 10 deletions

View File

@@ -23,12 +23,14 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
@@ -249,7 +251,7 @@ class QueryKeywordsTests {
products.forEach(product -> assertThat(product.name).isEqualTo("Sugar"));
}
@Test
@Test // DATAES-239
void shouldSearchForNullValues() {
final List<Product> products = repository.findByName(null);
@@ -257,7 +259,7 @@ class QueryKeywordsTests {
assertThat(products.get(0).getId()).isEqualTo("6");
}
@Test
@Test // DATAES-239
void shouldDeleteWithNullValues() {
repository.deleteByName(null);
@@ -265,6 +267,24 @@ class QueryKeywordsTests {
assertThat(count).isEqualTo(5);
}
@Test // DATAES-937
@DisplayName("should return empty list on findById with empty input list")
void shouldReturnEmptyListOnFindByIdWithEmptyInputList() {
Iterable<Product> products = repository.findAllById(new ArrayList<>());
assertThat(products).isEmpty();
}
@Test // DATAES-937
@DisplayName("should return empty list on derived method with empty input list")
void shouldReturnEmptyListOnDerivedMethodWithEmptyInputList() {
Iterable<Product> products = repository.findAllByNameIn(new ArrayList<>());
assertThat(products).isEmpty();
}
/**
* @author Mohsin Husen
* @author Artur Konczak
@@ -344,6 +364,8 @@ class QueryKeywordsTests {
List<Product> findTop2ByName(String name);
void deleteByName(@Nullable String name);
List<Product> findAllByNameIn(List<String> names);
}
}