Exemple #1
0
 public void tearDown() throws Exception {
   // Delete the loan
   logger.info("Entered tear down for TC18");
   logger.debug("trying to delete the loanID: " + loanId);
   loanService.deleteLoanByLoanID(loanId);
   // delete the book
   logger.debug("trying to delete the BookID: " + bookId);
   bookService.deleteBook(bookId);
   // delete the user
   logger.debug("trying to delete the UserID: " + userId);
   userService.delete(userService.getUserbyUserID(userId));
   // close the session
   session.close();
   logger.info("Exit tear down for TC17");
 }
Exemple #2
0
  public void testDeleteUserWithLoan() throws Exception {
    logger.info("Entered TC18 testDeleteUserWithLoan");
    User user;
    String parameterUserName = "******" + System.currentTimeMillis();
    String IsbnName = "testISBN" + System.currentTimeMillis();
    user = new User("TestFirstName", "TestLastName", parameterUserName, "password", Role.STUDENT);
    String parameterBookName = "MyBook" + System.currentTimeMillis();
    userService.saveOrUpdate(user);
    Book book = new Book(parameterBookName, IsbnName, 2);
    bookService.saveOrUpdate(book);
    session.refresh(book);
    logger.info("User added" + user.getUsername());
    // now create loan for this user
    Calendar now = Calendar.getInstance();
    now.add(Calendar.MINUTE, 5);
    logger.info("Book " + book.getBookid() + " user " + user.getUserId());

    Loan loan = new Loan(user.getUserId(), book.getBookid(), now.getTime(), 0, 10, false);
    loandao.saveOrUpdate(loan);
    loanId = loan.getLoanId();
    bookId = book.getBookid();
    userId = user.getUserId();
    logger.debug("Loan " + loan.getLoanId() + " created for user " + user.getUserId());
    logger.info("Loan created: " + loan.getLoanId());
    logger.info("trying to delete userID: " + user.getUserId());
    WebConversation conversation = new WebConversation();
    WebRequest requestDeleteUser =
        new GetMethodWebRequest(Constant.DELETE_USER_URL + user.getUserId());
    WebResponse responseGetUser = conversation.getResponse(requestDeleteUser);
    WebTable bookListUpdatedTable = responseGetUser.getTableWithID("userListTable");
    TableCell tableUpdatedCell = bookListUpdatedTable.getTableCellWithID(user.getUserId());
    assertEquals(tableUpdatedCell.getText(), user.getUserId());
    logger.info("Exited TC18 testDeleteUserWithLoan");
  }