@Test
 public void testLoansConfirmedOneBookBorrowed() {
   // Initialise, swipe card, scan book, scans complete, loansConfirmed,
   // then it should pass and be in the desired state. For this one test,
   // we will ensure that it is in the desired states as it moves through.
   controlClass_.initialise();
   controlClass_.cardSwiped(1); // Member ID = 1.
   assertEquals(EBorrowState.SCANNING_BOOKS, controlClass_.getState());
   controlClass_.bookScanned(10); // An available book.
   assertEquals(EBorrowState.SCANNING_BOOKS, controlClass_.getState());
   controlClass_.scansCompleted();
   assertEquals(EBorrowState.CONFIRMING_LOANS, controlClass_.getState());
   controlClass_.loansConfirmed();
   assertEquals(EBorrowState.COMPLETED, controlClass_.getState());
 }
 @Test(expected = RuntimeException.class)
 public void testLoansConfirmedWrongState() {
   // Essentially, loansConfirmed cannot be called before it is in state
   // CONFIRMING_LOANS so simply call loansConfirmed before anything else.
   assertTrue(!controlClass_.getState().equals(EBorrowState.CONFIRMING_LOANS));
   controlClass_.loansConfirmed();
 }
 @Test
 public void testInitialise() {
   // A quick test of the initialise method. We know that if the method
   // call worked successfully that the state will be INITIALIZED.
   controlClass_.initialise();
   assertTrue(controlClass_.getState().equals(EBorrowState.INITIALIZED));
 }
 @Test
 public void testCardSwipedDoesNotExist() {
   // Test to see that passing in an ID for a non-existent member does not
   // lead to a change in state. State should remain INITIALIZED.
   controlClass_.initialise();
   controlClass_.cardSwiped(10); // Member ID = 10, but doesn't exist.
   assertTrue(memberDao_.getMemberByID(10) == null);
   assertEquals(EBorrowState.INITIALIZED, controlClass_.getState());
 }
 @Test
 public void testCardSwipedUnrestricted() {
   // We will test swipe card with a member who exists and is not restricted.
   // This test will be with a 'clean' member (no overdue loans or fines, etc).
   // The state should then become SCANNING_BOOKS.
   controlClass_.initialise();
   controlClass_.cardSwiped(1); // Member ID = 1.
   assertEquals(EBorrowState.SCANNING_BOOKS, controlClass_.getState());
 }
 @Test
 public void testCardSwipedRestricted3() {
   // We will test swipe card with a member who exists but is restricted.
   // This test will be with a member who has reached the fine limit.
   // The state should still then become BORROWING_RESTRICTED.
   controlClass_.initialise();
   controlClass_.cardSwiped(3); // Member ID = 3.
   assertTrue(memberDao_.getMemberByID(3).hasReachedFineLimit());
   assertEquals(EBorrowState.BORROWING_RESTRICTED, controlClass_.getState());
 }
 @Test
 public void testCardSwipedRestricted() {
   // We will test swipe card with a member who exists but is restricted.
   // This test will be with a member who has overdue loans.
   // The state should still then become BORROWING_RESTRICTED.
   controlClass_.initialise();
   controlClass_.cardSwiped(2); // Member ID = 2.
   assertTrue(memberDao_.getMemberByID(2).hasOverDueLoans());
   assertEquals(EBorrowState.BORROWING_RESTRICTED, controlClass_.getState());
 }
 @Test
 public void testCardSwipedUnrestricted3() {
   // We will test swipe card with a member who exists and is not restricted.
   // This test will be with a member who has loans, but not overdue.
   // The state should still then become SCANNING_BOOKS.
   controlClass_.initialise();
   controlClass_.cardSwiped(6); // Member ID = 6.
   assertTrue(loanDao_.findLoansByBorrower(memberDao_.getMemberByID(6)).size() > 0);
   assertEquals(EBorrowState.SCANNING_BOOKS, controlClass_.getState());
 }
 @Test
 public void testCardSwipedUnrestricted2() {
   // We will test swipe card with a member who exists and is not restricted.
   // This test will be with a member who has fines payable.
   // The state should still then become SCANNING_BOOKS.
   controlClass_.initialise();
   controlClass_.cardSwiped(5); // Member ID = 5.
   assertTrue(memberDao_.getMemberByID(5).hasFinesPayable());
   assertEquals(EBorrowState.SCANNING_BOOKS, controlClass_.getState());
 }
 @Test
 public void testLoansConfirmedLoanListCreated() {
   // We will set up a loan with a member who has no outstanding loans and
   // then check that the loan was correctly confirmed/committed.
   controlClass_.initialise();
   controlClass_.cardSwiped(1); // Member ID = 1.
   controlClass_.bookScanned(10); // An available book.
   controlClass_.scansCompleted();
   controlClass_.loansConfirmed();
   List<ILoan> loanList = loanDao_.listLoans();
   assertEquals(EBorrowState.COMPLETED, controlClass_.getState());
   // We know from the setUpTestData method that there are 9 loans, so now
   // that we have committed this most recent loan, there should be 10.
   assertEquals(10, loanList.size());
 }