Exemple #1
0
  @Test
  public void repair() {

    testingBook.setState(EBookState.DAMAGED);

    assertEquals(testingBook.getState(), EBookState.DAMAGED);
    testingBook.repair();
  }
Exemple #2
0
  @Test
  public void testLose() {

    testingBook.setState(EBookState.LOST);

    when(mockLoan.getBook()).thenReturn(testingBook);

    assertEquals(testingBook.getState(), EBookState.LOST);
  }
Exemple #3
0
 @Test
 public void testBookIdIsNegative() {
   try {
     Book idIsNegative = new Book("Bob Jones", "Subject", null, -4);
     idIsNegative.getID();
     fail("Illegal Argument Exception");
   } catch (IllegalArgumentException e) {
     assertTrue(true);
   }
 }
Exemple #4
0
 @Test
 public void testCallNumberIsEmpty() {
   try {
     Book callNumberIsEmpty = new Book("Bob Jones", "Subject", "", 4);
     callNumberIsEmpty.getCallNumber();
     fail("Illegal Argument Exception");
   } catch (IllegalArgumentException e) {
     assertTrue(true);
   }
 }
Exemple #5
0
 @Test
 public void testGetTitleIsEmpty() {
   try {
     Book titleEmpty = new Book("Bob Jones", "", "123456", 4);
     titleEmpty.getTitle();
     fail("Illegal Argument Exception");
   } catch (IllegalArgumentException e) {
     assertTrue(true);
   }
 }
Exemple #6
0
 @Test
 public void testGetAuthorIsEmpty() {
   try {
     Book authorEmpty = new Book("", "Subject", "123456", 4);
     authorEmpty.getAuthor();
     fail("Illegal Argument Exception");
   } catch (IllegalArgumentException e) {
     assertTrue(true);
   }
 }
Exemple #7
0
 @Test
 public void testBookIdIsZero() {
   try {
     Book idIsZero = new Book("Bob Jones", "Subject", "123456", 0);
     idIsZero.getID();
     fail("Illegal Argument Exception");
   } catch (IllegalArgumentException e) {
     assertTrue(true);
   }
 }
Exemple #8
0
 @Test
 public void testRepairBookNotDamaged() {
   testingBook.setState(EBookState.ON_LOAN);
   try {
     testingBook.repair();
     fail("Runtime Exception");
   } catch (RuntimeException e) {
     assertTrue(true);
   }
 }
Exemple #9
0
  @Test
  public void testGetLoan() {

    testingBook.setState(EBookState.ON_LOAN);

    when(mockLoan.getBook()).thenReturn(testingBook);
    when(mockLoan.isOverDue()).thenReturn(false);

    assertEquals(testingBook.getState(), EBookState.ON_LOAN);
  }
Exemple #10
0
 @Test
 public void testDisposeBookDamaged() {
   testingBook.setState(EBookState.DAMAGED);
   try {
     testingBook.dispose();
     fail("Runtime Exception");
   } catch (RuntimeException e) {
     assertTrue(true);
   }
 }
Exemple #11
0
 @Test
 public void testDisposeBookLost() {
   testingBook.setState(EBookState.LOST);
   try {
     testingBook.dispose();
     fail("Runtime Exception");
   } catch (RuntimeException e) {
     assertTrue(true);
   }
 }
Exemple #12
0
 @Test
 public void testDisposeBookAvailable() {
   testingBook.setState(EBookState.AVAILABLE);
   try {
     testingBook.dispose();
     fail("Runtime Exception");
   } catch (RuntimeException e) {
     assertTrue(true);
   }
 }
Exemple #13
0
 @Test
 public void testLostBookNotOnLoan() {
   testingBook.setState(EBookState.LOST);
   try {
     testingBook.lose();
     fail("Runtime Exception");
   } catch (RuntimeException e) {
     assertTrue(true);
   }
 }
Exemple #14
0
 @Test
 public void testReturnBookNotOnLoan() {
   testingBook.setState(EBookState.DISPOSED);
   try {
     testingBook.returnBook(true);
     fail("Runtime Exception");
   } catch (RuntimeException e) {
     assertTrue(true);
   }
 }
Exemple #15
0
  @Test
  public void testBorrowNotAvailable() {
    ILoan loan = null;

    testingBook.setState(EBookState.AVAILABLE);
    try {
      testingBook.borrow(loan);
      fail("Runtime Exception");
    } catch (RuntimeException e) {
      assertTrue(true);
    }
  }
Exemple #16
0
  @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);
  }
Exemple #17
0
  @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);
  }
Exemple #18
0
 @Test
 public void testGetID() {
   assertEquals(1, BookTesting.getID());
 }
Exemple #19
0
 @Test
 public void testGetCallNumber() {
   assertEquals("callNumber", BookTesting.getCallNumber());
 }
Exemple #20
0
 @Test
 public void testGetTitle() {
   assertEquals("title", BookTesting.getTitle());
 }
Exemple #21
0
 @Test
 public void testGetAuthor() {
   assertEquals("author", BookTesting.getAuthor());
 }
Exemple #22
0
  @Test
  public void dispose() {
    testingBook.setState(EBookState.DISPOSED);

    assertEquals(testingBook.getState(), EBookState.DISPOSED);
  }