### Question:
SamlibOperation { public void makeBookReadFlip(final Book book, final BookGuiState bState, final AuthorGuiState aState) { mThread = new Thread() { @Override public void run() { super.run(); runBookReadFlip(book, bState, aState); } }; mThread.start(); } SamlibOperation(AuthorController sql, AbstractSettings settingsHelper, HttpClientController httpClientController, GuiEventBus guiEventBus); void makeBookReadFlip(final Book book, final BookGuiState bState, final AuthorGuiState aState); void makeGroupReadFlip(final GroupBook groupBook, final BookGuiState bState, final AuthorGuiState aState); void makeAuthorRead(final Author author, final AuthorGuiState state); void makeAuthorDel(final Author author, final AuthorGuiState state); void makeAuthorAdd(final ArrayList<String> urls, final AuthorGuiState state); void makeUpdateTags(final AuthorGuiState state); void makeGroupReload(final GroupBook groupBook, final BookGuiState state); void makeBookReload(final Book book, final BookGuiState state); void makeAuthorReload(final Author author, final AuthorGuiState state); static final long SLEEP_INTERVAL_SECONDS; static final int SLEEP_DELAY_MIN; static final int SLEEP_DELAY_MAX; }### Answer:
@Test(timeout = TIMEOUT) public void testMakeBookReadFlip() throws Exception { ArrayList<String> urls = new ArrayList<>(); urls.add(AUTHOR_URL); mSamlibOperation.runAuthorAdd(urls, authorGuiState); List<Author> aa = authorController.getAll(); assertEquals(1, aa.size()); Author author = aa.get(0); Book book = authorController.getBookController().getAll(author, bookOrder).get(10); Log.i(DEBUG_TAG, "testMakeBookReadFlip: test gor book " + book.getTitle() + " - " + book.getUri()); guiEventBus.getObservable().subscribe(guiUpdateObject -> { if (guiUpdateObject.isBook()) { mBook = (Book) guiUpdateObject.getObject(); synchronized (monitor) { monitor.notifyAll(); } } }); mSamlibOperation.makeBookReadFlip(book, new BookGuiState(author.getId(), bookOrder), authorGuiState); synchronized (monitor) { try { monitor.wait(); } catch (InterruptedException e) { Log.e(DEBUG_TAG, "testMakeBookReadFlip: interrupted", e); } } author = authorController.getById(author.getId()); assertTrue(mBook.isIsNew()); assertTrue(author.isIsNew()); assertEquals(1, mBook.getGroupBook().getNewNumber()); guiEventBus.getObservable().subscribe(guiUpdateObject -> { if (guiUpdateObject.isBook()) { mBook = (Book) guiUpdateObject.getObject(); synchronized (monitor) { monitor.notifyAll(); } } }); mSamlibOperation.makeBookReadFlip(book, new BookGuiState(author.getId(), bookOrder), authorGuiState); synchronized (monitor) { try { monitor.wait(); } catch (InterruptedException e) { Log.e(DEBUG_TAG, "testMakeBookReadFlip: interrupted", e); } } author = authorController.getById(author.getId()); assertFalse(mBook.isIsNew()); assertFalse(author.isIsNew()); assertEquals(0, mBook.getGroupBook().getNewNumber()); }