nz.ac.waikato.modeljunit.examples.ecinema
Class ECinema

java.lang.Object
  extended by nz.ac.waikato.modeljunit.examples.ecinema.ECinema
All Implemented Interfaces:
FsmModel

public class ECinema
extends java.lang.Object
implements FsmModel

A model of a simple eCinema. That is, a web-based system for selecting and buying movie tickets. For simplicity, Movie objects and Ticket objects are just modelled as strings. Note that missing usernames and passwords are modelled as empty strings ("").

Author:
marku LOG: 3 Sep 2007: 3 hours writing model Found several guard errors due to ModelJUnit warnings NullPtr exception -> 2-3 mistakes in changing states Infinite resets -> found that showtimes[1] was not init properly State Graph showed it was not reaching displayTickets state. (took a couple of hours to realise that registration was not resetting the state to "welcome"!)

Nested Class Summary
static class ECinema.State
          Each of these states models a separate web page.
 
Field Summary
 java.util.Map<java.lang.String,User> allUsers
          This maps each username to the User object.
 User currentUser
           
 java.lang.String message
          This is the most recent message that has been output.
 Showtime[] showtimes
           
 ECinema.State state
           
 
Constructor Summary
ECinema()
           
 
Method Summary
 void back()
           
 boolean backGuard()
           
 void buyTicket(Showtime shtime)
          Buy one ticket for current user, from the given shtime.
 boolean buyTicketGrd(Showtime shtime)
           
 void buyTicketShow1()
           
 boolean buyTicketShow1Guard()
           
 void buyTicketShow2()
           
 boolean buyTicketShow2Guard()
           
 void close()
           
 boolean closeGuard()
           
protected  java.util.Set<java.lang.String> currUsersTickets(Showtime shtime)
          the current user's tickets for the given show time.
 void deleteAllTickets(Showtime shtime)
           
 boolean deleteAllTicketsGrd(Showtime shtime)
           
 void deleteAllTicketsShow1()
           
 boolean deleteAllTicketsShow1Guard()
           
 void deleteAllTicketsShow2()
           
 boolean deleteAllTicketsShow2Guard()
           
 void deleteTicket(Showtime shtime)
           
 boolean deleteTicketGrd(Showtime shtime)
           
 void deleteTicketShow1()
           
 boolean deleteTicketShow1Guard()
           
 void deleteTicketShow2()
           
 boolean deleteTicketShow2Guard()
           
 void displayTickets()
           
 boolean displayTicketsGuard()
           
 java.lang.Object getState()
          Return the current state of the FSM model.
 void gotoRegister()
           
 boolean gotoRegisterGuard()
           
 void login(java.lang.String userName, java.lang.String userPassword)
           
 void loginAmandineEmpty()
           
 boolean loginAmandineEmptyGuard()
           
 void loginAmandineOk()
           
 boolean loginAmandineOkGuard()
           
 void loginEmpty()
           
 boolean loginEmptyGuard()
           
 void loginEricBad()
           
 boolean loginEricBadGuard()
           
 void loginEricOk()
           
 boolean loginEricOkGuard()
           
 boolean loginGrd()
           
 void logout()
           
 boolean logoutGuard()
           
static void main(java.lang.String[] args)
           
 void reg(java.lang.String userName, java.lang.String userPassword)
           
 boolean regGuard(java.lang.String userName)
           
 void registerAmandine()
           
 boolean registerAmandineGuard()
           
 void registerEmpty()
           
 boolean registerEmptyGuard()
           
 void registerEric()
           
 boolean registerEricGuard()
           
 void reset(boolean testing)
          Reset the model to its initial state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

state

public ECinema.State state

message

public java.lang.String message
This is the most recent message that has been output.


currentUser

public User currentUser

allUsers

public java.util.Map<java.lang.String,User> allUsers
This maps each username to the User object.


showtimes

public Showtime[] showtimes
Constructor Detail

ECinema

public ECinema()
Method Detail

getState

public java.lang.Object getState()
Description copied from interface: FsmModel
Return the current state of the FSM model. The objects returned by this method define the states (the nodes) of the finite state machine. The objects that are returned must have a correct implementation of the equals method, since this is used to decide whether two states are the same or not. It is common to return a string, but other kinds of objects can be used if desired (in which case, their toString() method will be used to get a printable form of each FSM state).

Advanced Feature: This method can be used to define equivalence classes over the states, if you want to reduce the number of states to keep the FSM small. For example, if you have a integer state variable I that can have a huge number of possible values, you could define your getState() method to return new Integer(I % 10). This would reduce the FSM to just 10 states, where FSM state 0 represents all the states where I=0 or I=10 or I=20 etc., and FSM state 1 represents all the states where I=1 or I=11 or I=21 etc.

Specified by:
getState in interface FsmModel
Returns:
An object that represents the current state.

reset

public void reset(boolean testing)
Description copied from interface: FsmModel
Reset the model to its initial state. If the testing parameter is true, then this reset and all the following actions should affect the SUT.

Specified by:
reset in interface FsmModel
Parameters:
testing - true means the SUT should be reset too.

loginEmptyGuard

public boolean loginEmptyGuard()

loginEricOkGuard

public boolean loginEricOkGuard()

loginEricBadGuard

public boolean loginEricBadGuard()

loginAmandineOkGuard

public boolean loginAmandineOkGuard()

loginAmandineEmptyGuard

public boolean loginAmandineEmptyGuard()

loginEmpty

public void loginEmpty()

loginEricOk

public void loginEricOk()

loginEricBad

public void loginEricBad()

loginAmandineOk

public void loginAmandineOk()

loginAmandineEmpty

public void loginAmandineEmpty()

loginGrd

public boolean loginGrd()

login

public void login(java.lang.String userName,
                  java.lang.String userPassword)

logoutGuard

public boolean logoutGuard()

logout

public void logout()

buyTicketShow1Guard

public boolean buyTicketShow1Guard()

buyTicketShow2Guard

public boolean buyTicketShow2Guard()

buyTicketShow1

public void buyTicketShow1()

buyTicketShow2

public void buyTicketShow2()

buyTicketGrd

public boolean buyTicketGrd(Showtime shtime)

buyTicket

public void buyTicket(Showtime shtime)
Buy one ticket for current user, from the given shtime.


deleteTicketShow1Guard

public boolean deleteTicketShow1Guard()

deleteTicketShow2Guard

public boolean deleteTicketShow2Guard()

deleteTicketShow1

public void deleteTicketShow1()

deleteTicketShow2

public void deleteTicketShow2()

deleteTicketGrd

public boolean deleteTicketGrd(Showtime shtime)

deleteTicket

public void deleteTicket(Showtime shtime)

deleteAllTicketsShow1Guard

public boolean deleteAllTicketsShow1Guard()

deleteAllTicketsShow2Guard

public boolean deleteAllTicketsShow2Guard()

deleteAllTicketsShow1

public void deleteAllTicketsShow1()

deleteAllTicketsShow2

public void deleteAllTicketsShow2()

deleteAllTicketsGrd

public boolean deleteAllTicketsGrd(Showtime shtime)

deleteAllTickets

public void deleteAllTickets(Showtime shtime)

gotoRegisterGuard

public boolean gotoRegisterGuard()

gotoRegister

public void gotoRegister()

registerAmandineGuard

public boolean registerAmandineGuard()

registerEricGuard

public boolean registerEricGuard()

registerEmptyGuard

public boolean registerEmptyGuard()

registerAmandine

public void registerAmandine()

registerEric

public void registerEric()

registerEmpty

public void registerEmpty()

regGuard

public boolean regGuard(java.lang.String userName)

reg

public void reg(java.lang.String userName,
                java.lang.String userPassword)

displayTicketsGuard

public boolean displayTicketsGuard()

displayTickets

public void displayTickets()

backGuard

public boolean backGuard()

back

public void back()

closeGuard

public boolean closeGuard()

close

public void close()

currUsersTickets

protected java.util.Set<java.lang.String> currUsersTickets(Showtime shtime)
the current user's tickets for the given show time.


main

public static void main(java.lang.String[] args)
                 throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException


Copyright © 2009 ModelJUnit Project. All Rights Reserved.