Package cz.muni.fi.pa165.library.backend

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


        List<Book> borrowList2 = new ArrayList<Book>();
        borrowList2.add(entityManager.find(Book.class, 3l));
        borrowList2.add(entityManager.find(Book.class, 4l));
      
        // ID 1
        Borrow borrow1 = new Borrow(entityManager.find(Reader.class, 1l), borrowList1,
                new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis()));
        // ID 2
        Borrow borrow2 = new Borrow(entityManager.find(Reader.class, 2l), borrowList2,
                new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis()));
        entityManager.close();
       
        entityManager = entityManagerFactory.createEntityManager();
        entityManager.getTransaction().begin();
View Full Code Here


      
        Date firstTime = new Date(System.currentTimeMillis());
        Date afterMonth = new Date(firstTime.getTime() + 2592000000l);
      
        // ID 1
        Borrow borrow1 = new Borrow(entityManager.find(Reader.class, 1l), borrowList1, firstTime, firstTime);
      
        entityManager.getTransaction().begin();
        entityManager.persist(borrow1);
        entityManager.getTransaction().commit();
        entityManager.close();
      
        EntityManager entityManager2 = entityManagerFactory.createEntityManager();
        Borrow borrow2 = entityManager2.find(Borrow.class, 1l);
        borrowDAO.updateExpirationDate(borrow2, afterMonth);
        assertEquals(afterMonth, entityManager2.find(Borrow.class, 1l).getExpirationDate())
        entityManager2.close();
    }
View Full Code Here

      
        Date firstTime = new Date(System.currentTimeMillis());
        Date afterMonth = new Date(firstTime.getTime() + 2592000000l);
      
        // ID 1
        Borrow borrow1 = new Borrow(entityManager.find(Reader.class, 1l), borrowList1, firstTime, firstTime);
        entityManager.close();
      
        try {
            borrowDAO.updateExpirationDate(borrow1, null);
            fail("Date cannot be null");
View Full Code Here

        borrowList.add(book2);
        book1.setAvailability(Available.BORROWED);
        book2.setAvailability(Available.BORROWED);
      
        // Borrow with ID 1
        Borrow borrow = new Borrow(entityManager.find(Reader.class, 1l), borrowList,
                new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis()));
        entityManager.close();
       
        entityManager = entityManagerFactory.createEntityManager();
        entityManager.getTransaction().begin();
        entityManager.persist(borrow);
        // because of lazy loading of collections in hibernate
        borrow.getTitles().get(0).getId();
        entityManager.getTransaction().commit();
        entityManager.close();
      
        List<Book> returnList = new ArrayList<Book>();
        returnList.add(book1);
        em.getTransaction().begin();
        borrowDAO.returnBooks(borrow, returnList);
        em.getTransaction().commit();
       
        entityManager = entityManagerFactory.createEntityManager();
        Borrow testBorrow = entityManager.find(Borrow.class, 1l)
        assertFalse("Borrow list should not contain book with id 1", testBorrow.getTitles().contains(book1));         
        entityManager.close();
    }
View Full Code Here

        borrowList.add(book2);
      
        List<Book> returnList = new ArrayList<Book>();
        returnList.add(book3);
      
        Borrow borrow = new Borrow(entityManager.find(Reader.class, 1l), borrowList,
                new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis()));
      
        entityManager.getTransaction().begin();
        // Borrow with ID 1
        entityManager.persist(borrow);
        entityManager.getTransaction().commit();
        borrow.getTitles().get(0).getId();
        entityManager.close();
      
        try {
            borrowDAO.returnBooks(borrow, returnList);
            fail("cannot return unborrowed book");
View Full Code Here

      
        Date firstTime = new Date(System.currentTimeMillis());
        Date afterMonth = new Date(firstTime.getTime() + 2592000000l);
      
        // ID 1
        Borrow borrow1 = new Borrow(entityManager.find(Reader.class, 1l), borrowList1, firstTime, firstTime);
        entityManager.close();
      
        try {
            borrowDAO.returnBooks(borrow1, null);
            fail("Return book list cannot be null");
View Full Code Here

      
        Date firstTime = new Date(System.currentTimeMillis());
        Date afterMonth = new Date(firstTime.getTime() + 2592000000l);
      
        // ID 1
        Borrow borrow1 = new Borrow(entityManager.find(Reader.class, 1l), borrowList1, firstTime, afterMonth);
        entityManager.close();
    
        try {
            borrowDAO.returnBooks(borrow1, returnList);
            fail("Return book list cannot be empty");
View Full Code Here

        borrowList1.add(book2);
      
        List<Book> borrowAnotherBooks = new ArrayList<Book>();
        borrowAnotherBooks.add(book3);
      
        Borrow borrow = new Borrow(entityManager.find(Reader.class, 1l),borrowList1,
                new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis()));
        entityManager.close();
       
        entityManager = entityManagerFactory.createEntityManager();
        entityManager.getTransaction().begin();
        entityManager.persist(borrow);
        entityManager.getTransaction().commit();
        borrow.getTitles().get(0).getId();
        entityManager.close();
      
        em.getTransaction().begin();
        borrowDAO.borrowBooks(borrow, borrowAnotherBooks);
        em.getTransaction().commit();
View Full Code Here

      
        Date firstTime = new Date(System.currentTimeMillis());
        Date afterMonth = new Date(firstTime.getTime() + 2592000000l);
      
        // ID 1
        Borrow borrow1 = new Borrow(entityManager.find(Reader.class, 1l), borrowList1, firstTime, firstTime);
        entityManager.close();

        try {
            borrowDAO.borrowBooks(borrow1, null);
            fail("Borrow list cannot be null");
View Full Code Here

        borrowAnotherBooks.add(book4);
        borrowAnotherBooks.add(book5);
        borrowAnotherBooks.add(book6);
        borrowAnotherBooks.add(book7);
      
        Borrow borrow = new Borrow(entityManager.find(Reader.class, 1l),borrowList1,
                new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis()));
      
        entityManager.getTransaction().begin();
        entityManager.persist(borrow);
        entityManager.getTransaction().commit();
        borrow.getTitles().get(0).getId();
        entityManager.close();
      
        try {
            borrowDAO.borrowBooks(borrow, borrowAnotherBooks);
            fail("Cannot borrow more books than allowed count");
View Full Code Here

TOP

Related Classes of cz.muni.fi.pa165.library.backend.Borrow

Copyright © 2018 www.massapicom. 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.