private BookCopyReservation createTestBookCopyReservation() {
   BookCopyReservation newReservation = new BookCopyReservation();
   newReservation.setBookCopy(createTestBookCopy());
   newReservation.setReservationState(ReservationState.NEW);
   newReservation.setUser(user);
   newReservation.setCreated(new Date(2012, 1, 1));
   return newReservation;
 }
  @Test
  public void testCreateBookCopyReservation() {
    try {
      simulateBeginTransaction();
      bDao.createBookCopyReservation(null);
      simulateEndTransaction();
      System.out.println("Should have thrown NPException");
      assertTrue(false);
    } catch (NullPointerException ex) {
    }
    BookCopyReservation myBCReservation = new BookCopyReservation();
    myBCReservation.setReservationState(null);
    myBCReservation.setBookCopy(createTestBookCopy());
    try {
      simulateBeginTransaction();
      bDao.createBookCopyReservation(myBCReservation);
      simulateEndTransaction();
      System.out.println("Should have thrown IllegalArgumentException, state is null");
      assertTrue(false);
    } catch (IllegalArgumentException ex) {
    }

    myBCReservation.setReservationState(ReservationState.LENT);
    myBCReservation.setBookCopy(null);
    try {
      simulateBeginTransaction();
      bDao.createBookCopyReservation(myBCReservation);
      simulateEndTransaction();
      System.out.println("Should have thrown IllegalArgumentException, book copy is null");
      assertTrue(false);
    } catch (IllegalArgumentException ex) {
    }

    BookCopyReservation result = null;
    try {
      simulateBeginTransaction();
      result = bDao.createBookCopyReservation(testBookCopyReservation1);
      simulateEndTransaction();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    assertNotNull(result.getId());
    assertEquals(testBookCopyReservation1.getBookCopy(), result.getBookCopy());
    assertEquals(testBookCopyReservation1.getReservationState(), result.getReservationState());
  }
  @Test
  public void testUpdateBookCopyReservation() {
    try {
      simulateBeginTransaction();
      bDao.updateBookCopyReservation(null);
      simulateEndTransaction();
      System.out.println("Should have thrown NPException");
      assertTrue(false);
    } catch (NullPointerException ex) {
    }

    BookCopyReservation myBCReservation = new BookCopyReservation();
    myBCReservation.setReservationState(null);
    myBCReservation.setId(Long.MAX_VALUE);
    myBCReservation.setBookCopy(createTestBookCopy());
    try { // reservation state is null
      simulateBeginTransaction();
      bDao.updateBookCopyReservation(myBCReservation);
      simulateEndTransaction();
      System.out.println("Should have thrown IllegalArgumentException, state is null");
      assertTrue(false);
    } catch (IllegalArgumentException ex) {
    }

    myBCReservation.setReservationState(ReservationState.LENT);
    myBCReservation.setBookCopy(null);
    try { // book copy is null
      simulateBeginTransaction();
      bDao.updateBookCopyReservation(myBCReservation);
      simulateEndTransaction();
      System.out.println("Should have thrown IllegalArgumentException, book copy is null");
      assertTrue(false);
    } catch (IllegalArgumentException ex) {
    }

    myBCReservation.setReservationState(ReservationState.READY);
    myBCReservation.setId(null);
    myBCReservation.setBookCopy(createTestBookCopy());
    try { // id is null
      simulateBeginTransaction();
      bDao.updateBookCopyReservation(myBCReservation);
      simulateEndTransaction();
      System.out.println("Should have thrown IllegalArgumentException, book copy is null");
      assertTrue(false);
    } catch (IllegalArgumentException ex) {
    }

    simulateBeginTransaction();
    bDao.createBookCopyReservation(testBookCopyReservation1);
    simulateEndTransaction();
    testBookCopyReservation1.setBookCopy(createTestBookCopy());
    testBookCopyReservation1.setReservationState(ReservationState.RETURNED);
    BookCopyReservation resultOfUpdate = null;
    try {
      simulateBeginTransaction();
      resultOfUpdate = bDao.updateBookCopyReservation(testBookCopyReservation1);
      simulateEndTransaction();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    assertEquals(testBookCopyReservation1.getBookCopy(), resultOfUpdate.getBookCopy());
    assertEquals(
        testBookCopyReservation1.getReservationState(), resultOfUpdate.getReservationState());
  }