Skip to content

Commit e477ee9

Browse files
committed
test: tests for QBE with findAll by Id with and without Metamodel usage
1 parent 8dcaded commit e477ee9

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

redis-om-spring/src/test/java/com/redis/om/spring/annotations/document/RedisDocumentQueryByExampleTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,30 @@ void testFindOneByExampleWithMultipleFields() {
154154
assertThat(doc1.getTag()).contains("noticias");
155155
}
156156

157+
@Test
158+
void testFindAllByExampleById() {
159+
MyDoc template = new MyDoc();
160+
template.setId(id1);
161+
162+
Example<MyDoc> example = Example.of(template);
163+
164+
Iterable<MyDoc> docs = repository.findAll(example);
165+
assertThat(docs).hasSize(1);
166+
assertThat(docs.iterator().next()).extracting(MyDoc::getTitle).isEqualTo("hello world");
167+
}
168+
169+
@Test
170+
void testFindAllByExampleByIdWithExampleMatcher() {
171+
MyDoc template = new MyDoc();
172+
template.setId(id1);
173+
174+
Example<MyDoc> example = Example.of(template, ExampleMatcher.matching().withIgnoreCase(false));
175+
176+
Iterable<MyDoc> docs = repository.findAll(example);
177+
assertThat(docs).hasSize(1);
178+
assertThat(docs.iterator().next()).extracting(MyDoc::getTitle).isEqualTo("hello world");
179+
}
180+
157181
@Test
158182
void testFindAllByWithPageableAndSortAsc() {
159183
Pageable pageRequest = PageRequest.of(0, 2,

redis-om-spring/src/test/java/com/redis/om/spring/annotations/hash/RedisHashQueryByExampleTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,30 @@ void testFindById() {
9999
assertThat(maybeDoc1.get().getTitle()).isEqualTo("hello world");
100100
}
101101

102+
@Test
103+
void testFindAllByExampleById() {
104+
MyHash template = new MyHash();
105+
template.setId(id1);
106+
107+
Example<MyHash> example = Example.of(template);
108+
109+
Iterable<MyHash> hashes = repository.findAll(example);
110+
assertThat(hashes).hasSize(1);
111+
assertThat(hashes.iterator().next()).extracting(MyHash::getTitle).isEqualTo("hello world");
112+
}
113+
114+
@Test
115+
void testFindAllByExampleByIdWithExampleMatcher() {
116+
MyHash template = new MyHash();
117+
template.setId(id1);
118+
119+
Example<MyHash> example = Example.of(template, ExampleMatcher.matching().withIgnoreCase(false));
120+
121+
Iterable<MyHash> hashes = repository.findAll(example);
122+
assertThat(hashes).hasSize(1);
123+
assertThat(hashes.iterator().next()).extracting(MyHash::getTitle).isEqualTo("hello world");
124+
}
125+
102126
@Test
103127
void testFindByTextIndexedProperty() {
104128
MyHash template = new MyHash();

0 commit comments

Comments
 (0)