Examples of HotelBookingAction


Examples of org.jboss.seam.example.booking.HotelBookingAction

      EntityManagerFactory emf = Persistence.createEntityManagerFactory("bookingDatabase");
      final EntityManager em = emf.createEntityManager();
     
      Hotel hotel =  em.getReference(Hotel.class, 1l);
     
      HotelBooking hb = new HotelBookingAction();
     
      setField(hb, "em", em);
      //setField(hb, "hotelSearch", hs);
      setField(hb, "user", em.getReference(User.class, "gavin"));
      setField(hb, "facesMessages", new FacesMessages());
      setField(hb, "events", new Events() { @Override public void raiseEvent(String type, Object... params) { assert "bookingConfirmed".equals(type); } } );
      setField(hb, "log", Logging.getLog(HotelBookingAction.class));
     
      assert hb.selectHotel(hotel).equals("hotel");

      User user = em.getReference(User.class, "gavin");
      assert user!=null;
      assert hb.bookHotel().equals("book");
     
      Booking booking = (Booking) getField(hb, "booking");
      assert booking!=null;
      assert booking.getHotel()!=null;
      assert booking.getUser()!=null;
     
      booking.setCreditCard("1234123412341234");
      booking.setCreditCardName("GAVIN A KING");
     
      assert hb.setBookingDetails().equals("confirm");

      getUserTransaction().begin();
      assert hb.confirm().equals("confirmed");
      getUserTransaction().commit();
     
      em.close();
   }
View Full Code Here

Examples of org.jboss.seam.example.hibernate.HotelBookingAction

     
      String id = new FacesRequest("/main.xhtml") {
        
         @Override
         protected void invokeApplication() throws Exception {
            HotelBookingAction hotelBooking = (HotelBookingAction) getInstance("hotelBooking");
            DataModel hotels = (DataModel) Contexts.getSessionContext().get("hotels");
            assert hotels.getRowCount()==1;
            hotelBooking.selectHotel( (Hotel) hotels.getRowData() );
         }

         @Override
         protected void renderResponse()
         {
View Full Code Here

Examples of org.jboss.seam.example.hibernate.HotelBookingAction

         @Override
         protected void invokeApplication()
         {
            //getRequest().getParameterMap().put("hotelId", "2");
             HotelBookingAction hotelBooking = (HotelBookingAction) Contexts.getConversationContext().get("hotelBooking");
            String outcome = hotelBooking.selectHotel();
            assert "selected".equals( outcome );
         }

         @Override
         protected void renderResponse()
         {
            Hotel hotel = (Hotel) Contexts.getConversationContext().get("hotel");
            assert hotel.getCity().equals("NY");
            assert hotel.getZip().equals("10011");
            assert Manager.instance().isLongRunningConversation();
         }
        
      }.run();
     
      new Script(id) {

         @Override
         protected void invokeApplication()
         {
             HotelBookingAction hotelBooking = (HotelBookingAction) Contexts.getConversationContext().get("hotelBooking");
            String outcome = hotelBooking.bookHotel();
            assert "book".equals( outcome );
         }

         @Override
         protected void renderResponse()
         {
            Booking booking = (Booking) Contexts.getConversationContext().get("booking");
            assert booking.getUser()!=null;
            assert booking.getHotel()!=null;
            assert booking.getHotel()==Contexts.getConversationContext().get("hotel");
            assert booking.getUser()==Contexts.getSessionContext().get("user");
            assert Manager.instance().isLongRunningConversation();
         }
        
      }.run();
           
      new Script(id) {
        
         @Override @SuppressWarnings("deprecation")
         protected void updateModelValues() throws Exception
         {
            Booking booking = (Booking) Contexts.getConversationContext().get("booking");
            booking.setCreditCard("1234567891021234");
            Date now = new Date();
            booking.setCheckinDate(now);
            booking.setCheckoutDate(now);
         }

         @Override
         protected void invokeApplication()
         {
             HotelBookingAction hotelBooking = (HotelBookingAction) Contexts.getConversationContext().get("hotelBooking");
            String outcome = hotelBooking.setBookingDetails();
            assert outcome==null;
         }

         @Override
         protected void renderResponse()
         {
            Iterator messages = FacesContext.getCurrentInstance().getMessages();
            assert messages.hasNext();
            assert ( (FacesMessage) messages.next() ).getSummary().equals("Check out date must be later than check in date");
            assert !messages.hasNext();
            assert Manager.instance().isLongRunningConversation();
         }
        
      }.run();
     
      new Script(id) {
        
         @Override @SuppressWarnings("deprecation")
         protected void updateModelValues() throws Exception
         {
            Booking booking = (Booking) Contexts.getConversationContext().get("booking");
            Calendar cal = Calendar.getInstance();
            cal.add(Calendar.DAY_OF_MONTH, 2);
            booking.setCheckoutDate( cal.getTime() );
         }

         @Override
         protected void invokeApplication()
         {
             HotelBookingAction hotelBooking = (HotelBookingAction) Contexts.getConversationContext().get("hotelBooking");
            String outcome = hotelBooking.setBookingDetails();
            assert "confirm".equals( outcome );
         }

         @Override
         protected void renderResponse()
         {
            assert Manager.instance().isLongRunningConversation();
         }
        
      }.run();
     
      new Script(id) {
       
         @Override
         protected void invokeApplication()
         {
             HotelBookingAction hotelBooking = (HotelBookingAction) Contexts.getConversationContext().get("hotelBooking");
            String outcome = hotelBooking.confirm();
            assert "confirmed".equals( outcome );
         }

         @Override
         protected void renderResponse()
View Full Code Here

Examples of org.jboss.seam.example.jpa.HotelBookingAction

     
      String id = new FacesRequest("/main.xhtml") {
        
         @Override
         protected void invokeApplication() throws Exception {
            HotelBookingAction hotelBooking = (HotelBookingAction) getInstance("hotelBooking");
            DataModel hotels = (DataModel) Contexts.getSessionContext().get("hotels");
            assert hotels.getRowCount()==1;
            hotelBooking.selectHotel( (Hotel) hotels.getRowData() );
         }

         @Override
         protected void renderResponse()
         {
View Full Code Here

Examples of org.jboss.seam.example.spring.HotelBookingAction

    String id = new FacesRequest("/main.xhtml") {

      @Override
      protected void invokeApplication() throws Exception {
        HotelBookingAction hotelBooking = (HotelBookingAction) getInstance("hotelBooking");
        DataModel hotels = (DataModel) Contexts.getSessionContext().get("hotels");
        hotels.setRowIndex(0);
        hotelBooking.selectHotel((Hotel) hotels.getRowData());
      }

    }.run();

    id = new FacesRequest("/hotel.xhtml", id) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.