Package net.sourceforge.myreserve.ejb

Examples of net.sourceforge.myreserve.ejb.Hotel


    @Test
    public void testCreateHotel() throws Exception
    {
        // create hotel
        em.getTransaction().begin();
        Hotel h1 = new Hotel("Test Hotel 1");
        em.persist(h1);
        em.getTransaction().commit();
        Hotel h = (Hotel) em.find(Hotel.class, h1.getHotelId());
        Assert.assertNotNull(h);

        // remove hotel
        em.getTransaction().begin();
        h = (Hotel) em.find(Hotel.class, h1.getHotelId());
View Full Code Here


    @Test
    public void testCreateReservation() throws Exception
    {
        // create hotel
        em.getTransaction().begin();
        Hotel h2 = new Hotel("Test Hotel 2");
        em.persist(h2);
        em.getTransaction().commit();

        // create reservation
        em.getTransaction().begin();
        Date now = new Date();
        Integer nights = new Integer(3);
        Integer guests = new Integer(2);
        Reservation r1 = new Reservation(guests, now, nights, "A", "Guest");
        Hotel h = em.find(Hotel.class, h2.getHotelId());
        r1.setHotel(h);
        em.persist(r1);
        em.getTransaction().commit();
        Reservation r = (Reservation) em.find(Reservation.class, r1.getReservationId());
        Assert.assertNotNull(r);
View Full Code Here

            (Collection<Hotel>)em.createNativeQuery(query, Hotel.class ).getResultList();
        Assert.assertEquals(0, hotelCol.size());

        // add hotels
        em.getTransaction().begin();
        Hotel h3 = new Hotel("Test Hotel 3");
        em.persist(h3);
        em.getTransaction().commit();
        em.getTransaction().begin();
        Hotel h4 = new Hotel("Test Hotel 4");
        em.persist(h4);
        em.getTransaction().commit();

        // check number of hotels
        hotelCol = (Collection<Hotel>)em.createNativeQuery(query, Hotel.class ).getResultList();
        Assert.assertEquals(2, hotelCol.size());

        // remove hotels
        em.getTransaction().begin();
        Hotel h = (Hotel) em.find(Hotel.class, h3.getHotelId());
        em.remove(h);
        em.getTransaction().commit();
        em.getTransaction().begin();
        h = (Hotel) em.find(Hotel.class, h4.getHotelId());
        em.remove(h);
View Full Code Here

            SimpleDateFormat format =
              new SimpleDateFormat("MM/dd/yy");
            this.arrivalDate = format.format(res.getArrivalDate());
            this.numGuests = res.getNumGuests();
            this.numNights = res.getNumNights();
            Hotel h = res.getHotel();
            this.hotelId = h.getHotelId();
            this.hotelName = h.getName();
            return "retrieve_reservation_success";
        } else {
            return "retrieve_reservation_error";
        }
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.myreserve.ejb.Hotel

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.