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

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


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

    }
  
    public void testFindReservationByID() {     
        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, 1l),
                em.find(Book.class, new Long(9)), new Date(System.currentTimeMillis()));
        em.persist(reservation1);
        em.persist(reservation2);
      
        em.getTransaction().commit();
      
        reservation1.setReservationID(new Long(1));
        reservation2.setReservationID(new Long(2));
      
        assertEquals(reservation1, reservationDAOImpl.findReservationByID(new Long(1)));
        assertEquals(reservation2, reservationDAOImpl.findReservationByID(new Long(2)));
      
        if (em != null) {
View Full Code Here

    }
  
    public void testFindReservationsByReader() {     
        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

    }
  
    public void testFindReservationByBook() {     
        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

    }
  
    public void testDeleteReservation() {
        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

        try {
            emf = Persistence.createEntityManagerFactory("testPU");
            em = emf.createEntityManager();
            readerDAOImpl = new ReaderDAOImpl();
            bookDAOImpl = new BookDAOImpl();
            reservationDAOImpl = new ReservationDAOImpl();
            reservationDAOImpl.setEntityManager(em);
          
            createReaderData();
            createBookData();
            book = new Book("Da Vinciho kod", "Dan Brown", Genre.DRAMA, "2005", "USA",
View Full Code Here

    public ShowBorrowReader(final PageParameters parameters) {
  super(parameters);
        BorrowService borrowService = (BorrowService) ApplicationContextProvider.getApplicationContext().getBean("borrowService");
        RepeatingView repeating = new RepeatingView("repeating");
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        AuthenticatedSession session = ((AuthenticatedSession)Session.get());
        for (BorrowTO borrow : borrowService.findBorrowsByReader(session.getReader())) {
            for (BookTO book: borrow.getTitlesTO()){
                AbstractItem item = new AbstractItem(repeating.newChildId());
                item.add(new Label("title", book.getTitle()));     
                item.add(new Label("author", book.getAuthor()));
                item.add(new Label("borrowdate", dateFormat.format(borrow.getBorrowDate())));
View Full Code Here

            if (list.contains(book)){
                Link link = new Link("edit"){
                      @Override
                      public void onClick() {
                          ReservationService reservationService = (ReservationService) ApplicationContextProvider.getApplicationContext().getBean("reservationService");
                          AuthenticatedSession session = ((AuthenticatedSession)Session.get());
                          ReaderTO reader = session.getReader();
                          BookTO book2 = bookService.findBookById(book.getId());
                          java.util.Date date = new java.util.Date();
                          if (reader != null && book != null){
                              ReservationTO reservation = new ReservationTO(reader, book2,new Timestamp(date.getTime()));
                              reservationService.insertReservation(reservation);
View Full Code Here

TOP

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

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.