@Test public void testReturnBookNotOnLoan() { testingBook.setState(EBookState.DISPOSED); try { testingBook.returnBook(true); fail("Runtime Exception"); } catch (RuntimeException e) { assertTrue(true); } }
@Test public void testReturnBookNotDamaged() { testingBook.setState(EBookState.ON_LOAN); when(mockLoan.getBook()).thenReturn(testingBook); assertEquals(testingBook.getState(), EBookState.ON_LOAN); testingBook.returnBook(false); assertEquals(testingBook.getState(), EBookState.AVAILABLE); }
@Test public void testReturnBookDamaged() { testingBook.setState(EBookState.ON_LOAN); when(mockLoan.getBook()).thenReturn(testingBook); assertEquals(testingBook.getState(), EBookState.ON_LOAN); testingBook.returnBook(true); assertEquals(testingBook.getState(), EBookState.DAMAGED); }