fix(integration-tests): improve the robustness of the test fixture

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
This commit is contained in:
Christian Tzolov
2025-02-11 12:35:13 +01:00
parent 52198ed9d7
commit 011deb04a6

View File

@@ -25,15 +25,13 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class BookService {
private static final Map<Integer, Book> 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<Integer, Book> 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<Book> getBooksByAuthor(Author author) {
return books.values().stream().filter(book -> author.name().equals(book.author())).toList();