Package cz.muni.fi.pa165.stis.dto

Examples of cz.muni.fi.pa165.stis.dto.CustomerTO


    private void createReaderData() {
        // ID start from 1 incremented by 1, because of in memory DB
        // ID 1
        EntityManager entityManager = entityManagerFactory.createEntityManager();
        entityManager.getTransaction().begin();
        entityManager.persist(new Reader("Emil", "Slovak", "8.9.1973", "Velke Cierne 23, SR",
                "e.slovak@gmail.com", "0949 123 542", "aaa"));
        // ID 2
        entityManager.persist(new Reader("Karel", "Novak", "7.11.1981", "Grohova 2, Brno, CR",
                "karel.novak@gmail.com", "735 945 248", "ccc"));
        // ID 3
        entityManager.persist(new Reader("Jack", "Black", "6.8.1972", "1234/1 5th Avenue, NY, USA",
                "jack.black@gmail.com", "482 451 354", "ddd"));
        entityManager.getTransaction().commit();
        entityManager.close();
    }
View Full Code Here


    }
  
    public void testInsertBorrowBookStateUpdate() {       
        long currentTime = System.currentTimeMillis();
        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)));
View Full Code Here

      
        List<Book> borrowList2 = new ArrayList<Book>();
        borrowList2.add(entityManager.find(Book.class, 3l));
        borrowList2.add(entityManager.find(Book.class, 4l));
       
        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()));
View Full Code Here

        }       
      
        try {
            emf = Persistence.createEntityManagerFactory("testPU");
            em = emf.createEntityManager();
            readerDAOImpl = new ReaderDAOImpl();
            bookDAOImpl = new BookDAOImpl();
            reservationDAOImpl = new ReservationDAOImpl();
            reservationDAOImpl.setEntityManager(em);
          
            createReaderData();
View Full Code Here

            ex.printStackTrace();
            fail("Exception during database startup.");
        }
        try {
            emf = Persistence.createEntityManagerFactory("testPU");
            readerDAO = new ReaderDAOImpl();
            em = emf.createEntityManager();
            readerDAO.setEntityManager(em);
        } catch (Exception ex) {
            ex.printStackTrace();
            fail("Exception during JPA EntityManager instanciation.");
View Full Code Here

  
    public void testInsertReservationWithIncorrectBorrowAttributes() {
        List<Book> reservationList = new ArrayList<Book>();
        reservationList.add(em.find(Book.class, new Long(1)));
        reservationList.add(em.find(Book.class, new Long(2)));
        Reservation incorrectReservation;
        long currentTime = System.currentTimeMillis();
        long afterMonth = currentTime + 2592000000l;
    }
View Full Code Here

        long afterMonth = currentTime + 2592000000l;
    }
  
    public void testInsertReservationWithIncorrectReaderID() {       
        try {
            reservationDAOImpl.insertReservation(new Reservation(em.find(Reader.class, new Long(-5)),
                                                 em.find(Book.class, new Long(1)), new Date(System.currentTimeMillis())));
            fail("Cannot insert reservation with reader's id lesser than or equals to 0");
        } catch (IllegalArgumentException ex) {
            // OK
        }
View Full Code Here

        }
    }
  
    public void testInsertReservationWithNullReaderID() {       
        try {
            reservationDAOImpl.insertReservation(new Reservation(null, em.find(Book.class, new Long(1)),
                                                 new Date(System.currentTimeMillis())));
            fail("Cannot insert reservation without reader's id");
        } catch (IllegalArgumentException ex) {
            // OK
        }
View Full Code Here

        }
    }
      
    public void testInsertReservationWithIncorrectBookID() { 
        try {
            reservationDAOImpl.insertReservation(new Reservation(em.find(Reader.class, new Long(1)),
                                                 em.find(Book.class, new Long(-5)), new Date(System.currentTimeMillis())));
            fail("Cannot insert reservation with book's id lesser than or equals to 0");
        } catch (IllegalArgumentException ex) {
            // OK
        }
View Full Code Here

        }
    }
      
    public void testInsertReservationWithNullBookID() { 
        try {
            reservationDAOImpl.insertReservation(new Reservation(em.find(Reader.class, new Long(1)),
                                                                 null, new Date(System.currentTimeMillis())));
            fail("Cannot make a reservation for book which is null");
        } catch (IllegalArgumentException ex) {
            // OK
        }
View Full Code Here

TOP

Related Classes of cz.muni.fi.pa165.stis.dto.CustomerTO

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.