Skip to content

Commit

Permalink
Fix another Neo4jEmbeddingStoreTest error (#441)
Browse files Browse the repository at this point in the history
See here:
https://github.com/langchain4j/langchain4j/actions/runs/7396118145/job/20120618008?pr=396

The fix made [here](#368)
it is not enough,
because the test property is not always populated, see
[here](https://github.com/langchain4j/langchain4j/blob/main/langchain4j-neo4j/src/main/java/dev/langchain4j/store/embedding/neo4j/Neo4jEmbeddingUtils.java#L71).

Therefore, I put an if-else on the iterator where needed
  • Loading branch information
vga91 committed Jan 3, 2024
1 parent 50f32ba commit df66836
Showing 1 changed file with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,13 @@ void should_add_multiple_embeddings() {

checkEntitiesCreated(relevant.size(),
iterator -> {
checkDefaultProps(firstEmbedding, firstMatch, iterator.next());
checkDefaultProps(secondEmbedding, secondMatch, iterator.next());
iterator.forEachRemaining(node -> {
if (node.get(DEFAULT_ID_PROP).asString().equals(firstMatch.embeddingId())) {
checkDefaultProps(firstEmbedding, firstMatch, node);
} else {
checkDefaultProps(secondEmbedding, secondMatch, node);
}
});
});
}

Expand Down Expand Up @@ -289,12 +294,17 @@ void should_add_multiple_embeddings_with_segments() {
assertThat(secondMatch.embedding()).isEqualTo(secondEmbedding);
assertThat(secondMatch.embedded()).isEqualTo(secondSegment);

checkEntitiesCreated(relevant.size(),
checkEntitiesCreated(relevant.size(),
iterator -> {
List<String> otherProps = Collections.singletonList(DEFAULT_TEXT_PROP);
checkDefaultProps(firstEmbedding, firstMatch, iterator.next(), otherProps);
checkDefaultProps(secondEmbedding, secondMatch, iterator.next(), otherProps);
});
List<String> otherProps = Collections.singletonList(DEFAULT_TEXT_PROP);
iterator.forEachRemaining(node -> {
if (node.get(DEFAULT_ID_PROP).asString().equals(firstMatch.embeddingId())) {
checkDefaultProps(firstEmbedding, firstMatch, node, otherProps);
} else {
checkDefaultProps(secondEmbedding, secondMatch, node, otherProps);
}
});
});
}

@Test
Expand Down Expand Up @@ -345,8 +355,13 @@ void should_find_with_min_score() {

checkEntitiesCreated(relevant.size(),
iterator -> {
checkDefaultProps(firstEmbedding, firstMatch, iterator.next());
checkDefaultProps(secondEmbedding, secondMatch, iterator.next());
iterator.forEachRemaining(node -> {
if (node.get(DEFAULT_ID_PROP).asString().equals(firstMatch.embeddingId())) {
checkDefaultProps(firstEmbedding, firstMatch, node);
} else {
checkDefaultProps(secondEmbedding, secondMatch, node);
}
});
});
}

Expand Down

0 comments on commit df66836

Please sign in to comment.