Skip to content
Merged
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 @@ -45,7 +45,7 @@ private Book convertToBook(StandardEbooksBook standardEbooksBook) {
book.setKoboUrl(standardEbooksBook.kobo());
book.setAzwUrl(standardEbooksBook.azw());
book.setHtmlUrl(standardEbooksBook.html());
book.setProvider(Provider.STANDARD_EBOOK);
book.setProvider(Provider.STANDARD_EBOOKS);
return book;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ink.kindler.metasearch.persistent.entity;

public enum Provider {
STANDARD_EBOOK,
STANDARD_EBOOKS,
GUTENBERG,
GUTENBERG_AUSTRALIA
}
2 changes: 1 addition & 1 deletion src/main/resources/db/seed/R__seed_standard_ebooks.sql

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ void cleanDatabase() {
@Test
void shouldFindBooksByProviderAndAuthorOrTitleLike() {
var books = List.of(
stubBook( "The Adventures of Tom Sawyer", "Mark Twain", Provider.STANDARD_EBOOK),
stubBook( "The Adventures of Tom Sawyer", "Mark Twain", Provider.STANDARD_EBOOKS),
stubBook("Adventures of Huckleberry Finn", "Mark Twain", Provider.GUTENBERG),
stubBook("Mark Zuckerberg", "Mark Zuckerberg", Provider.STANDARD_EBOOK),
stubBook("Nineteen Eighty-Four (1984)", "George Orwell", Provider.STANDARD_EBOOK),
stubBook("The Mark of Zorro", "Johnston McCulley", Provider.STANDARD_EBOOK)
stubBook("Mark Zuckerberg", "Mark Zuckerberg", Provider.STANDARD_EBOOKS),
stubBook("Nineteen Eighty-Four (1984)", "George Orwell", Provider.STANDARD_EBOOKS),
stubBook("The Mark of Zorro", "Johnston McCulley", Provider.STANDARD_EBOOKS)
);
bookRepository.saveAll(books);

var foundBooks = bookRepository.searchBooks(Provider.STANDARD_EBOOK, "mArK", PageRequest.of(0, 10));
var foundBooks = bookRepository.searchBooks(Provider.STANDARD_EBOOKS, "mArK", PageRequest.of(0, 10));

assertThat(foundBooks).hasSize(3);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ class SearchControllerIntegrationTest {
void setUpDatabase() {
bookRepository.deleteAll();
bookRepository.saveAll(List.of(
stubBook("The Adventures of Tom Sawyer", "Mark Twain", Provider.STANDARD_EBOOK),
stubBook("The Adventures of Tom Sawyer", "Mark Twain", Provider.STANDARD_EBOOKS),
stubBook("Adventures of Huckleberry Finn", "Mark Twain", Provider.GUTENBERG),
stubBook("Nineteen Eighty-Four (1984)", "George Orwell", Provider.STANDARD_EBOOK),
stubBook("The Mark of Zorro", "Johnston McCulley", Provider.STANDARD_EBOOK)
stubBook("Nineteen Eighty-Four (1984)", "George Orwell", Provider.STANDARD_EBOOKS),
stubBook("The Mark of Zorro", "Johnston McCulley", Provider.STANDARD_EBOOKS)
));
}

@Test
void shouldSearchBook() {
var endpoint = "http://localhost:%s/v1/books/search?q=mark&provider=STANDARD_EBOOK".formatted(port);
var endpoint = "http://localhost:%s/v1/books/search?q=mark&provider=STANDARD_EBOOKS".formatted(port);
var expectedResponse = List.of(
new BookOverviewResponse(4L, "The Mark of Zorro", "Johnston McCulley", "https://coverimageurl.com"),
new BookOverviewResponse(1L, "The Adventures of Tom Sawyer", "Mark Twain", "https://coverimageurl.com")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ class SearchControllerTest {

@Test
void shouldSearchBookByQuery() throws Exception {
when(searchService.search(Provider.STANDARD_EBOOK, "Mark")).thenReturn(List.of(
when(searchService.search(Provider.STANDARD_EBOOKS, "Mark")).thenReturn(List.of(
stubBookOverview(1L, "The Adventures of Tom Sawyer", "Mark Twain"),
stubBookOverview(2L, "The Mark of Zorro", "Johnston McCulley")
));

mockMvc.perform(get("/v1/books/search")
.queryParam("q", "Mark")
.queryParam("provider", "STANDARD_EBOOK"))
.queryParam("provider", "STANDARD_EBOOKS"))
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().json(BOOK_SEARCH_RESPONSE));
Expand All @@ -80,7 +80,7 @@ void shouldSearchBookByQuery() throws Exception {
void shouldReturnBadRequestIfQuerySizeExceedsOneHundredCharacters() throws Exception {
mockMvc.perform(get("/v1/books/search")
.queryParam("q", QUERY_HUNDRED_FIVE_CHARACTERS)
.queryParam("provider", "STANDARD_EBOOK"))
.queryParam("provider", "STANDARD_EBOOKS"))
.andDo(print())
.andExpect(status().isBadRequest());
}
Expand Down Expand Up @@ -116,7 +116,7 @@ private Book stubBook() {
book.setMobiUrl("https://mobiurl.com");
book.setAzwUrl("https://azwurl.com");
book.setHtmlUrl("https://htmlurl.com");
book.setProvider(Provider.STANDARD_EBOOK);
book.setProvider(Provider.STANDARD_EBOOKS);
return book;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ void shouldPersistBooks() {
void shouldSearchBooksByProviderAndAuthorOrTitle() {
var foundBooks = List.of(mock(BookOverview.class), mock(BookOverview.class));

when(bookRepository.searchBooks(Provider.STANDARD_EBOOK, "Mark", PageRequest.of(0, 50)))
when(bookRepository.searchBooks(Provider.STANDARD_EBOOKS, "Mark", PageRequest.of(0, 50)))
.thenReturn(foundBooks);

var result = bookService.searchBooksByProviderAndTitleOrAuthorMatching(Provider.STANDARD_EBOOK, "Mark");
var result = bookService.searchBooksByProviderAndTitleOrAuthorMatching(Provider.STANDARD_EBOOKS, "Mark");

assertThat(result).isEqualTo(foundBooks);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ void shouldSearchBooksByProviderAndAuthorOrTitle() {
var bookOverViewOne = mock(BookOverview.class);
var bookOverViewTwo = mock(BookOverview.class);

when(bookService.searchBooksByProviderAndTitleOrAuthorMatching(Provider.STANDARD_EBOOK, "Mark"))
when(bookService.searchBooksByProviderAndTitleOrAuthorMatching(Provider.STANDARD_EBOOKS, "Mark"))
.thenReturn(List.of(bookOverViewOne, bookOverViewTwo));

var searchResult = searchService.search(Provider.STANDARD_EBOOK, "Mark");
var searchResult = searchService.search(Provider.STANDARD_EBOOKS, "Mark");

assertThat(searchResult).isEqualTo(List.of(bookOverViewOne, bookOverViewTwo));
}
Expand Down