@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()