InMemoryBookService implements BookService { @Override public Optional<Book> find(String isbn) { return Optional.ofNullable(books.get(isbn)); }  @Override @PreAuthorize("isAuthenticated()") Iterable<Book> findAll(); @Override @PreAuthorize("hasAuthority('USER')") Book create(Book book); @Override @PreAuthorize("hasAuthority('ADMIN') or @accessChecker.hasLocalAccess(authentication)") void remove(Book book); @Override Optional<Book> find(String isbn);  }
@Test public void shouldReturnEmptyOptionalWhenNotFound() { assertThat(service.find("1234")).isEmpty(); }