Examples of Borrow


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.getTransaction().begin();
        entityManager.persist(borrow1);
        entityManager.persist(borrow2);
View Full Code Here

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();
        entityManager.persist(borrow1);
        entityManager.getTransaction().commit();
        entityManager.getTransaction().begin();
        entityManager.persist(borrow2);
        entityManager.getTransaction().commit();
        entityManager.close();
      
        borrow1.setBorrowID(1l);
        borrow2.setBorrowID(2l);
      
        assertEquals(borrow1, borrowDAO.findBorrowById(1l));
        assertEquals(borrow2, borrowDAO.findBorrowById(2l))
    }
View Full Code Here

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

        Reader reader1 = entityManager.find(Reader.class, 1l);
        Reader reader2 = entityManager.find(Reader.class, 2l);
        entityManager.close();
       
        // ID 1
        Borrow borrow1 = new Borrow(reader1, borrowList1,
                new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis()));
        // ID 2
        Borrow borrow2 = new Borrow(reader2, borrowList2,
                new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis()));
       
        entityManager = entityManagerFactory.createEntityManager();
        entityManager.getTransaction().begin();
        entityManager.persist(borrow1);
        entityManager.persist(borrow2);
        entityManager.getTransaction().commit();
        entityManager.close();
      
        borrow1.setBorrowID(1l);
        borrow2.setBorrowID(2l);
      
        em.getTransaction().begin();
        assertEquals(borrow1, borrowDAO.findBorrowsByReader(reader1).get(0));
        assertEquals(borrow2, borrowDAO.findBorrowsByReader(reader2).get(0));
        em.getTransaction().commit();
View Full Code Here

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

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

      
        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

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

      
        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

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

        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

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

        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

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

      
        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

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

      
        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
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.