@Given("a library with only a single unborrowed book with <isbn>") public void createSingleBook(@Named("isbn") String isbn) throws SQLException { emptyLibrary(); database.execute( "INSERT INTO book(id,title,author,edition,isbn,year_of_publication) VALUES " + "(0, 'Title', 'Author', '1', '" + isbn + "', 2011)"); }
@Given("a user <user> has borrowed books <isbns>") public void createListOfBorrowedBooks(@Named("user") String user, @Named("isbns") String isbns) throws SQLException { List<String> isbnList = getListOfItems(isbns); for (String isbn : isbnList) { database.execute( "INSERT INTO book(title,author,edition,isbn,year_of_publication) VALUES " + "('Title', 'Author', '1', '" + isbn + "', 2011)"); String bookId = database.getResult("SELECT LAST_INSERT_ID()"); database.execute( "INSERT INTO borrowing(borrow_date, borrower_email_address) VALUES " + "(CURDATE(), '" + user + "')"); String borrowingId = database.getResult("SELECT LAST_INSERT_ID()"); database.execute( "UPDATE book SET current_borrowing_id = " + borrowingId + " WHERE id = " + bookId); } }