Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

/**
Expand Down Expand Up @@ -134,14 +135,8 @@ void builderWithMultipleMissingVariablesShouldThrow() {
.template("Processing {item} with {type} at {level}")
.build();

try {
promptTemplate.render();
Assertions.fail("Expected IllegalStateException was not thrown.");
}
catch (IllegalStateException e) {
assertThat(e.getMessage()).contains("Not all variables were replaced in the template");
assertThat(e.getMessage()).contains("item", "type", "level");
}
assertThatIllegalStateException().isThrownBy(promptTemplate::render)
.withMessageContainingAll("Not all variables were replaced in the template", "item", "type", "level");
}

@Test
Expand All @@ -155,13 +150,8 @@ void builderWithPartialVariablesShouldThrow() {
.variables(variables)
.build();

try {
promptTemplate.render();
Assertions.fail("Expected IllegalStateException was not thrown.");
}
catch (IllegalStateException e) {
assertThat(e.getMessage()).contains("Missing variable names are: [type]");
}
assertThatIllegalStateException().isThrownBy(promptTemplate::render)
.withMessageContaining("Missing variable names are: [type]");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.function.Consumer;
import java.util.stream.Collectors;

import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
Expand Down Expand Up @@ -53,6 +52,7 @@
import org.springframework.context.annotation.Primary;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

/**
* @author Gerrit Meier
Expand Down Expand Up @@ -207,14 +207,10 @@ void searchWithFilters() {
assertThat(results).hasSize(1);
assertThat(results.get(0).getId()).isEqualTo(bgDocument.getId());

try {
vectorStore
.similaritySearch(SearchRequest.from(searchRequest).filterExpression("country == NL").build());
Assert.fail("Invalid filter expression should have been cached!");
}
catch (FilterExpressionTextParser.FilterExpressionParseException e) {
assertThat(e.getMessage()).contains("Line: 1:17, Error: no viable alternative at input 'NL'");
}
assertThatExceptionOfType(FilterExpressionTextParser.FilterExpressionParseException.class)
.isThrownBy(() -> vectorStore
.similaritySearch(SearchRequest.from(searchRequest).filterExpression("country == NL").build()))
.withMessageContaining("Line: 1:17, Error: no viable alternative at input 'NL'");
});
}

Expand Down