From 011deb04a6581b8924b3e6fef7ad8e342c57f054 Mon Sep 17 00:00:00 2001 From: Christian Tzolov Date: Tue, 11 Feb 2025 12:35:13 +0100 Subject: [PATCH] fix(integration-tests): improve the robustness of the test fixture Signed-off-by: Christian Tzolov --- .../tests/tool/domain/BookService.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/domain/BookService.java b/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/domain/BookService.java index 240a31343..c19ae634b 100644 --- a/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/domain/BookService.java +++ b/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/domain/BookService.java @@ -25,15 +25,13 @@ import java.util.concurrent.ConcurrentHashMap; */ public class BookService { - private static final Map books = new ConcurrentHashMap<>(); - - static { - books.put(1, new Book("His Dark Materials", "Philip Pullman")); - books.put(2, new Book("Narnia", "C.S. Lewis")); - books.put(3, new Book("The Hobbit", "J.R.R. Tolkien")); - books.put(4, new Book("The Lord of The Rings", "J.R.R. Tolkien")); - books.put(5, new Book("The Silmarillion", "J.R.R. Tolkien")); - } + private static final ConcurrentHashMap books = new ConcurrentHashMap<>(Map + .of( // @formatter:off + 1, new Book("His Dark Materials", "Philip Pullman"), + 2, new Book("Narnia", "C.S. Lewis"), + 3, new Book("The Hobbit", "J.R.R. Tolkien"), + 4, new Book("The Lord of The Rings", "J.R.R. Tolkien"), + 5, new Book("The Silmarillion", "J.R.R. Tolkien"))); // @formatter:on public List getBooksByAuthor(Author author) { return books.values().stream().filter(book -> author.name().equals(book.author())).toList();