public class HolidayBooking
extends java.lang.Object
HolidayBooking.xml
specification. It mimics a simple SAP application built in OpenUI5 and
deployed on the SAP HANA cloud. This application offers three UI states,
in which the user could view booked holidays, book more days, or delete
existing days. The user could book up to five days holiday. The system
should refuse booking duplicate days and disallow more than the five days
in total.
This uses the State Pattern (a Design Pattern from Gamma, et al.) for its implementation. All requests are delegated to an abstract State, which has concrete subclasses ViewDays, BookDays and DeleteDays, which respond to certain requests in different ways.
Indexing in the specification language runs from 1..n; this is preserved in the selected row, but converted to 0..n-1 when accessing the underlying Java Lists. It demonstrates the facility to return multiple values as the response to a request. This is translated into returning an Object[] array in Java clients. In the same way that an error case always returns an unbound output with a null value, multiple unbound results are returned as an array of nulls.
Suggestions are given for how to modify the source code to seed faults deliberately, which will be detected during testing.
Constructor and Description |
---|
HolidayBooking()
Creates a HolidayBooking.
|
Modifier and Type | Method and Description |
---|---|
void |
back()
Mimics clicking on the "Back" button in either of the states
BookDays or DeleteDays to return to the ViewDays state.
|
void |
bookDays()
Mimics clicking on the "BookDays" button to move from the ViewDays
state to the BookDays state, in which more holidays may be booked.
|
void |
choose(int firstDay,
int lastDay)
Mimics clicking on a pair of days on the calendar, to indicate
selecting a short period of holiday, where the selected range
includes both days.
|
java.lang.Object[] |
delete()
Mimics clicking on the "Delete" button to delete the currently
selected row in the list of booked holidays.
|
java.lang.String |
getScenario()
Returns the last scenario that was enacted.
|
java.lang.String |
getState()
Returns the last state that was entered.
|
java.lang.Object[] |
save()
Mimics clicking on the "Save" button to record the selected range
of days as holiday.
|
void |
select(int row)
Allows selection of one booked holiday period, stored in a list.
|
public HolidayBooking()
public java.lang.String getScenario()
public java.lang.String getState()
public void bookDays()
public void select(int row)
row
- the row selected in the UI (indexing is 1..n).public void back()
public void choose(int firstDay, int lastDay)
firstDay
- the starting day (inclusive).lastDay
- the ending day (inclusive).public java.lang.Object[] save()
public java.lang.Object[] delete()