Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The Ordering model demonstrates the use of Alf as the action language within an executable model using State Machines. It includes the following diagrams:

  • Order Classes  – A Class diagram of an an Order consisting  consisting of multiple multiple OrderLineItems, placed  placed by a Customer, which  which may be paid using a CreditCard.
  • Order_Behavior  – A State Machine diagram of the active Behavior of an an Order.
  • CreditCardCharge_Behavior  – A State Machine diagram of the active Behavior of a CreditCardCharge (this is just a stub for testing purposes).
  • Customer_Behavior  – A State Machine diagram of the active Behavior of a Customer (this is just a stub for testing purposes).
  • Test – A Class diagram of a simple simple Test Class  Class with a classifier behavior that acts as a test driver.

Alf is used to define the behavior of all Operations in the the Order Classes model model, entry Behaviors in all the state machines and the classifier behavior for for Test. To  To view any of the Alf code, open the the Alf editor window  window (select select Windows > Alf) and then select the desired Operation, entry Behavior or Activity. The Alf code will appear in the window.


To run the test

  • Select Simulation > Run on the class Test.
  • Set the Animation speed to maximum (even if it looks like it is already at maximum, make sure the slider is all the way to the right).
  • Click on the Start Image Removed button.
  • When the run pauses, select Order_Behavior in the Sessions tab.
  • Select SubmitCharge under Trigger.
  • Select CreditCardCharge_Behavior in the Sessions tab (this State Machine should be in the State Verifying at this point).
  • Select either ChargeApproved or ChargeDenied under Trigger.
  • Select Order_Behavior in the Sessions tab.
  • If ChargeDenied, then Order_Behavior should be in State Payment Not Approved. Select either SubmitCharge or OrderCancelled under Trigger. If SubmitCharge, go back to step 7.
  • , do either of the following


    • Press the start button on the main toolbar. 
    • Right-click OrderingSimConfig and select Simulation > Run
    If ChargeApproved, then Order_Behavior should be in State Awaiting Delivery. Select OrderDelivered under Trigger
    • .