use of com.aidanwhiteley.books.domain.googlebooks.BookSearchResult in project books by aidanwhiteley.
the class GoogleBooksDaoSycTest method findByTitle.
@Test
public void findByTitle() {
BookSearchResult result = theDao.searchGoogBooksByTitle("Design Patterns");
assertNotNull(result);
assertTrue("Should have found result items", result.getItems().size() > 0);
assertTrue("Should have found a book id", result.getItems().get(0).getId().length() > 0);
assertTrue("Should have found a title", result.getItems().get(0).getVolumeInfo().getTitle().length() > 0);
}
use of com.aidanwhiteley.books.domain.googlebooks.BookSearchResult in project books by aidanwhiteley.
the class GoogleBooksDaoSyncTest method findByTitle.
@Test
void findByTitle() {
BookSearchResult result = theDao.searchGoogBooksByTitle("Design Patterns");
assertNotNull(result);
assertEquals(NUMBER_OF_BOOKS_IN_SEARCH_RESULTS, result.getItems().size());
assertTrue(result.getItems().get(0).getId().length() > 0, "Should have found a book id");
assertTrue(result.getItems().get(0).getVolumeInfo().getTitle().length() > 0, "Should have found a title");
}
use of com.aidanwhiteley.books.domain.googlebooks.BookSearchResult in project books by aidanwhiteley.
the class GoogleBooksDaoSync method searchGoogBooksByTitle.
public BookSearchResult searchGoogBooksByTitle(String title) {
String encodedTitle;
encodedTitle = URLEncoder.encode(title, StandardCharsets.UTF_8);
googleBooksRestTemplate.getMessageConverters().add(0, new StringHttpMessageConverter(StandardCharsets.UTF_8));
final String searchString = googleBooksApiConfig.getSearchUrl() + encodedTitle + "&" + googleBooksApiConfig.getCountryCode() + "&" + googleBooksApiConfig.getMaxResults();
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Google Books API called with API called: {}", searchString);
}
BookSearchResult result = googleBooksRestTemplate.getForObject(searchString, BookSearchResult.class);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Result of Google Books API call: {}", result);
}
return result;
}
Aggregations