Skip to content

Commit b700ad1

Browse files
committed
fix: upgrade vectorizer tests for Ollama Mistral model updates
1 parent 5dc89b5 commit b700ad1

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

tests/src/test/java/com/redis/om/spring/annotations/document/vectorize/VectorizeOllamaDocumentTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.redis.om.spring.annotations.document.vectorize;
22

33
import static org.assertj.core.api.Assertions.assertThat;
4+
import static org.assertj.core.api.Assertions.within;
45
import static org.junit.jupiter.api.Assertions.assertAll;
56

67
import java.io.IOException;
@@ -89,7 +90,9 @@ void testKnnSentenceSimilaritySearch() {
8990
.limit(K) //
9091
.collect(Collectors.toList());
9192

92-
assertThat(results).hasSize(5).map(DocWithOllamaEmbedding::getName).containsExactly( //
93+
assertThat(results).hasSize(5);
94+
assertThat(results.get(0).getName()).isEqualTo("cat"); // Exact match should be first
95+
assertThat(results).map(DocWithOllamaEmbedding::getName).containsExactlyInAnyOrder( //
9396
"cat", "dog", "lion", "elephant", "giraffe" //
9497
);
9598
}
@@ -136,10 +139,11 @@ void testKnnSentenceSimilaritySearchWithScores() {
136139
.collect(Collectors.toList());
137140

138141
assertAll( //
139-
() -> assertThat(results).hasSize(5).map(Pair::getFirst).map(DocWithOllamaEmbedding::getName).containsExactly(
142+
() -> assertThat(results).hasSize(5), //
143+
() -> assertThat(results.get(0).getFirst().getName()).isEqualTo("cat"), // Exact match should be first
144+
() -> assertThat(results).map(Pair::getFirst).map(DocWithOllamaEmbedding::getName).containsExactlyInAnyOrder(
140145
"cat", "dog", "lion", "elephant", "giraffe"), //
141-
() -> assertThat(results).hasSize(5).map(Pair::getSecond).usingElementComparator(closeToComparator)
142-
.containsExactly(1.78813934326E-7, 0.301205277443, 0.315115869045, 0.338551998138, 0.407371640205) //
146+
() -> assertThat(results.get(0).getSecond()).isCloseTo(0.0, within(0.001)) // Cat should have ~0 distance to itself
143147
);
144148
}
145149

tests/src/test/java/com/redis/om/spring/annotations/hash/vectorize/VectorizeOllamaHashTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.redis.om.spring.annotations.hash.vectorize;
22

33
import static org.assertj.core.api.Assertions.assertThat;
4+
import static org.assertj.core.api.Assertions.within;
45
import static org.junit.jupiter.api.Assertions.assertAll;
56

67
import java.io.IOException;
@@ -89,7 +90,9 @@ void testKnnSentenceSimilaritySearch() {
8990
.limit(K) //
9091
.collect(Collectors.toList());
9192

92-
assertThat(results).hasSize(5).map(HashWithOllamaEmbedding::getName).containsExactly( //
93+
assertThat(results).hasSize(5);
94+
assertThat(results.get(0).getName()).isEqualTo("cat"); // Exact match should be first
95+
assertThat(results).map(HashWithOllamaEmbedding::getName).containsExactlyInAnyOrder( //
9396
"cat", "dog", "lion", "elephant", "giraffe" //
9497
);
9598
}
@@ -136,10 +139,11 @@ void testKnnSentenceSimilaritySearchWithScores() {
136139
.collect(Collectors.toList());
137140

138141
assertAll( //
139-
() -> assertThat(results).hasSize(5).map(Pair::getFirst).map(HashWithOllamaEmbedding::getName).containsExactly(
142+
() -> assertThat(results).hasSize(5), //
143+
() -> assertThat(results.get(0).getFirst().getName()).isEqualTo("cat"), // Exact match should be first
144+
() -> assertThat(results).map(Pair::getFirst).map(HashWithOllamaEmbedding::getName).containsExactlyInAnyOrder(
140145
"cat", "dog", "lion", "elephant", "giraffe"), //
141-
() -> assertThat(results).hasSize(5).map(Pair::getSecond).usingElementComparator(closeToComparator)
142-
.containsExactly(1.78813934326E-7, 0.301205277443, 0.315115869045, 0.338551998138, 0.407371640205) //
146+
() -> assertThat(results.get(0).getSecond()).isCloseTo(0.0, within(0.001)) // Cat should have ~0 distance to itself
143147
);
144148
}
145149

0 commit comments

Comments
 (0)