Package cz.muni.fi.pa165.ddtroops.serviceinterfaces

Examples of cz.muni.fi.pa165.ddtroops.serviceinterfaces.RaceService


        }       
      
        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

        }
    }
    
    public void testInsertReservationWithIncorrectReservationDate() {
        try {
            reservationDAOImpl.insertReservation(new Reservation(em.find(Reader.class, new Long(1)), em.find(Book.class, new Long(1)), null));
            fail("Cannot make a reservation without specifying a reservation date");
        } catch (IllegalArgumentException ex) {
            // OK
        }
      
View Full Code Here

      
    }
  
    public void testInsertCorrectReservation() { 
        em.getTransaction().begin();       
        Reservation reservation = new Reservation(em.find(Reader.class, new Long(1)),
                                   em.find(Book.class, new Long(8)), new Date(System.currentTimeMillis()));     
        em.persist(reservation);
        em.getTransaction().commit();
      
        assertNotNull(reservationDAOImpl.findReservationByID(reservation.getReservationID()));
      
        if (em != null) {
            em.close();
        }       
    }
View Full Code Here

        }       
    }
  
    public void testFindAllReservations() {
        em.getTransaction().begin();       
        Reservation reservation1 = new Reservation(em.find(Reader.class, new Long(1)),
                                   em.find(Book.class, new Long(8)), new Date(System.currentTimeMillis()));
        Reservation reservation2 = new Reservation(em.find(Reader.class, new Long(1)),
                em.find(Book.class, new Long(9)), new Date(System.currentTimeMillis()));
        em.persist(reservation1);
        em.persist(reservation2);       
        em.getTransaction().commit();
      
View Full Code Here

TOP

Related Classes of cz.muni.fi.pa165.ddtroops.serviceinterfaces.RaceService

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.