@Test public void testWarnsUserIfNoBooksAreAvailable() { when(library.numberOfBooksInLibrary()).thenReturn(0); checkoutBookMenuOperation.execute(library, console); verify(console).printMessage("There are no books available for checkout"); }
private Library buildMockLibraryWithSetBookAmounts( int numberOfBooksAvailable, int numberOfBooksCheckedOut) { library = mock(Library.class); when(library.numberOfBooksInLibrary()).thenReturn(numberOfBooksAvailable); when(library.numberOfBooksCheckedOut()).thenReturn(numberOfBooksCheckedOut); for (int i = 0; i < numberOfBooksAvailable; i++) { when(library.bookIsAvailable(i)).thenReturn(true); } for (int i = 0; i < numberOfBooksCheckedOut; i++) { when(library.bookIsCheckedOut(i)).thenReturn(true); } return library; }