Package cz.muni.fi.pa165.library.web_layer.readerPages

Examples of cz.muni.fi.pa165.library.web_layer.readerPages.ShowAllBookReader


        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


        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

        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

        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

        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

        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

        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

        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

  
    private void createReaderData() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
      
        em.persist(new Reader("Anton", "Bernolak", "10.4.1875", "Bernolakovo 453, SR",
                "anton.bernolak@gmail.com", "0903 560 987", "aaa"));
        em.persist(new Reader("Martin", "Skrecok", "5.10.1990", "Jurkovicova 16, SR",
                "martin.skrecok@gmail.com", "903 875 349", "bbb"));
        em.persist(new Reader("Leon", "Powe", "20.5.1950", "Golden Street, Boston, USA",
                "leon.powe@gmail.com", "740 320 853", "ccc"));
      
        em.getTransaction().commit();
        if (em != null) {
            em.close();
View Full Code Here

            }
        } 
    }
   
    private Reader addReader(){
        Reader reader = new Reader();
        reader.setFirstName("Karel");
        reader.setSurname("Novak");
        reader.setAddress("Nove Hrady, Praha");
        reader.setBirthNumber("12.3.2012");
        reader.setTelephoneNumber("+420756362776");
        reader.setEmail("mail@seznam.cz");
        return reader;          
    }
View Full Code Here

TOP

Related Classes of cz.muni.fi.pa165.library.web_layer.readerPages.ShowAllBookReader

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.