Skip to content

Commit 011deb0

Browse files
committed
fix(integration-tests): improve the robustness of the test fixture
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
1 parent 52198ed commit 011deb0

File tree

1 file changed

+7
-9
lines changed
  • spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/domain

1 file changed

+7
-9
lines changed

spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/domain/BookService.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,13 @@
2525
*/
2626
public class BookService {
2727

28-
private static final Map<Integer, Book> books = new ConcurrentHashMap<>();
29-
30-
static {
31-
books.put(1, new Book("His Dark Materials", "Philip Pullman"));
32-
books.put(2, new Book("Narnia", "C.S. Lewis"));
33-
books.put(3, new Book("The Hobbit", "J.R.R. Tolkien"));
34-
books.put(4, new Book("The Lord of The Rings", "J.R.R. Tolkien"));
35-
books.put(5, new Book("The Silmarillion", "J.R.R. Tolkien"));
36-
}
28+
private static final ConcurrentHashMap<Integer, Book> books = new ConcurrentHashMap<>(Map
29+
.of( // @formatter:off
30+
1, new Book("His Dark Materials", "Philip Pullman"),
31+
2, new Book("Narnia", "C.S. Lewis"),
32+
3, new Book("The Hobbit", "J.R.R. Tolkien"),
33+
4, new Book("The Lord of The Rings", "J.R.R. Tolkien"),
34+
5, new Book("The Silmarillion", "J.R.R. Tolkien"))); // @formatter:on
3735

3836
public List<Book> getBooksByAuthor(Author author) {
3937
return books.values().stream().filter(book -> author.name().equals(book.author())).toList();

0 commit comments

Comments
 (0)