Examples of Borrow


Examples of cz.muni.fi.pa165.library.backend.Borrow

  
    public void testInsertCorrectBorrow() {
        long currentTime = System.currentTimeMillis();
        EntityManager entityManager = entityManagerFactory.createEntityManager();
       
        Borrow borrow = new Borrow(entityManager.find(Reader.class, 1l), prepareBorrowList(),
                new Date(currentTime), new Date(currentTime + 2592000000l));
        entityManager.close();
       
        em.getTransaction().begin();
        borrowDAO.createBorrow(borrow);
View Full Code Here

Examples of cz.muni.fi.pa165.library.backend.Borrow

    public void testInsertBorrowWithNullReaderID() {
        List<Book> borrowList = prepareBorrowList();
        long currentTime = System.currentTimeMillis();
      
        try {
            borrowDAO.createBorrow(new Borrow(null, borrowList,
                    new Date(currentTime), new Date(currentTime + 2592000000l)));
            fail("Cannot insert borrow without reader's id");
        } catch (IllegalArgumentException ex) {
            // OK
        }
View Full Code Here

Examples of cz.muni.fi.pa165.library.backend.Borrow

    public void testInsertBorrowWithNullBorrowList() {
        long currentTime = System.currentTimeMillis();
        EntityManager entityManager = entityManagerFactory.createEntityManager();
      
        try {
            borrowDAO.createBorrow(new Borrow(entityManager.find(Reader.class, 1l), null, new Date(currentTime), new Date(currentTime + 2592000000l)));
            fail("Cannot insert borrow without borrowed books");
        } catch (IllegalArgumentException ex) {
            // OK
        } finally {
            entityManager.close();
View Full Code Here

Examples of cz.muni.fi.pa165.library.backend.Borrow

    public void testInsertBorrowWithoutBorrowDate() {
        List<Book> borrowList = prepareBorrowList();
        EntityManager entityManager = entityManagerFactory.createEntityManager();
   
        try {
            borrowDAO.createBorrow(new Borrow(entityManager.find(Reader.class, 1l), borrowList, null, new Date(System.currentTimeMillis() + 2592000000l)));
            fail("Cannot insert borrow without borrow date");
        } catch (IllegalArgumentException ex) {
            // OK
        } finally {
            entityManager.close();
View Full Code Here

Examples of cz.muni.fi.pa165.library.backend.Borrow

    public void testInsertBorrowWithoutReturnDate() {
        List<Book> borrowList = prepareBorrowList();
        EntityManager entityManager = entityManagerFactory.createEntityManager();
      
        try {
            borrowDAO.createBorrow(new Borrow(entityManager.find(Reader.class, 1l), borrowList, new Date(System.currentTimeMillis()), null));
            fail("Cannot insert borrow without borrowed books");
        } catch (IllegalArgumentException ex) {
            // OK
        } finally {
            entityManager.close();
View Full Code Here

Examples of cz.muni.fi.pa165.library.backend.Borrow

    public void testInsertBorrowWithEmptyBorrowList() {
        long currentTime = System.currentTimeMillis();
        EntityManager entityManager = entityManagerFactory.createEntityManager();
       
        try {
            borrowDAO.createBorrow(new Borrow(entityManager.find(Reader.class, 1l), new ArrayList<Book>(),
                    new Date(currentTime), new Date(currentTime +  2592000000l)));
            fail("Cannot insert empty borrow list");
        } catch (IllegalArgumentException ex) {
            // OK
        } finally {
View Full Code Here

Examples of cz.muni.fi.pa165.library.backend.Borrow

        for (long id = 1l; id < 8; id++) {
            borrowList.add(entityManager.find(Book.class, id));
        }
       
        try {
            borrowDAO.createBorrow(new Borrow(entityManager.find(Reader.class, 1l), borrowList,
                    new Date(currentTime), new Date(currentTime +  2592000000l)));
            fail("Cannot insert empty borrow list");
        } catch (IllegalArgumentException ex) {
            // OK
        } finally {
View Full Code Here

Examples of cz.muni.fi.pa165.library.backend.Borrow

        EntityManager entityManager = entityManagerFactory.createEntityManager();
        Reader reader = entityManager.find(Reader.class, 1l);
        entityManager.close();
       
        em.getTransaction().begin();
        borrowDAO.createBorrow(new Borrow(reader, prepareBorrowList(),
                new Date(currentTime), new Date(currentTime + 2592000000l)));
        em.getTransaction().commit();
       
        entityManager = entityManagerFactory.createEntityManager();       
        Borrow borrow = entityManager.find(Borrow.class, 1l);
        Book firstBook = entityManager.find(Book.class, 1l);
        Book secondBook = entityManager.find(Book.class, 2l);
        entityManager.close();
  
        assertEquals(Available.BORROWED, firstBook.getAvailability());
View Full Code Here

Examples of cz.muni.fi.pa165.library.backend.Borrow

        List<Book> borrowedBook = new ArrayList<Book>();
        borrowedBook.add(entityManager.find(Book.class, 10l));
        long currentTime = System.currentTimeMillis();
        
        try {
            borrowDAO.createBorrow(new Borrow(entityManager.find(Reader.class, 1l), borrowedBook,
                    new Date(currentTime), new Date(currentTime +  2592000000l)));
            fail("Cannot insert borrow list with borrowed book");
        } catch (IllegalArgumentException ex) {
            // OK
        } finally {
View Full Code Here

Examples of cz.muni.fi.pa165.library.backend.Borrow

        List<Book> borrowedBook = new ArrayList<Book>();
        borrowedBook.add(entityManager.find(Book.class, 8l));
        long currentTime = System.currentTimeMillis();
              
        try {
            borrowDAO.createBorrow(new Borrow(entityManager.find(Reader.class, 2l), borrowedBook,
                    new Date(currentTime), new Date(currentTime +  2592000000l)));
            fail("Cannot insert borrow list with book reserved by another reader");
        } catch (IllegalArgumentException ex) {
            // OK
        } finally {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.