CoCoME System Tests

org.cocome.tradingsystem.systests.scenarios
Class ProcessSaleBase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.cocome.tradingsystem.systests.scenarios.TestScenarioBase
              extended by org.cocome.tradingsystem.systests.scenarios.ProcessSaleBase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
ManageExpressCheckoutBase, ProcessSaleCashTest, ProcessSaleConcurrentTest, ProcessSaleCreditCardFailTest, ProcessSaleCreditCardTest, ProcessSaleInvalidItemIdTest, ProductExchangeAmongStoresTest

public class ProcessSaleBase
extends TestScenarioBase

This abstract class holds basic operations needed for a purchase and its variants as described in use case 1.

Version:
$Rev: 64 $
Author:
Benjamin Hummel, Christian Pfaller, $Author: hummel $

Nested Class Summary
 
Nested classes/interfaces inherited from class org.cocome.tradingsystem.systests.scenarios.TestScenarioBase
TestScenarioBase.StoreWrapper
 
Field Summary
protected  ICashBox cashBox
          The cash box used for this sale
protected  ICashDesk cashDesk
          The cash desk used for this sale
protected  int currentlySold
          The number of items currently sold.
protected  int[] expectedAmounts
          Array which holds the expected remaining amount of a product in the store
private static int NUM_SOLD_ITEMS
          The number of items sold for this test case.
protected  int priceSum
          Holds the sum to pay
protected  IProduct[] products
          The list of products which where bought
protected  IStorePC store
          The store used for this sale
 
Fields inherited from class org.cocome.tradingsystem.systests.scenarios.TestScenarioBase
bank, enterprise, productGenerator, seedRng, stores, testDriver
 
Constructor Summary
ProcessSaleBase()
           
 
Method Summary
protected  void enterAllRemainingProducts()
          Executes actions for entering products in the cashbox.
protected  void enterProducts(int howMany)
          Executes actions for entering products in the cashbox.
protected  void finishSale()
          Executes actions for finishing sale (after entering all products in cashbox, before payment).
protected  void handleCashPayment()
          Executs actions of handling cash payment.
protected  void initializeCashDesk(int storeIndex, int cashDeskIndex)
          Executes actions for initializing cash desk when a customer arrives there.
 void purchase()
          Executes a standard purchase process at a cash desk with no exceptions.
protected  void setUp()
          Setup only a single store with two cash desks.
protected  void startNewSale()
          Executes actions for starting a new sale with a default number of items.
protected  void startNewSale(int how_many_items)
          Executes actions for starting a new sale.
protected  void updateInventory()
          Executes actions after reciept of payment.
 
Methods inherited from class org.cocome.tradingsystem.systests.scenarios.TestScenarioBase
copySetup, createStore, tearDown
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NUM_SOLD_ITEMS

private static final int NUM_SOLD_ITEMS
The number of items sold for this test case.

See Also:
Constant Field Values

currentlySold

protected int currentlySold
The number of items currently sold.


store

protected IStorePC store
The store used for this sale


cashDesk

protected ICashDesk cashDesk
The cash desk used for this sale


cashBox

protected ICashBox cashBox
The cash box used for this sale


expectedAmounts

protected int[] expectedAmounts
Array which holds the expected remaining amount of a product in the store


products

protected IProduct[] products
The list of products which where bought


priceSum

protected int priceSum
Holds the sum to pay

Constructor Detail

ProcessSaleBase

public ProcessSaleBase()
Method Detail

setUp

protected void setUp()
              throws java.lang.Exception
Setup only a single store with two cash desks.

Overrides:
setUp in class TestScenarioBase
Throws:
java.lang.Exception

purchase

public void purchase()
              throws java.lang.Exception
Executes a standard purchase process at a cash desk with no exceptions. Payment will be by cash.

Throws:
java.lang.Exception

initializeCashDesk

protected void initializeCashDesk(int storeIndex,
                                  int cashDeskIndex)
                           throws java.lang.Exception
Executes actions for initializing cash desk when a customer arrives there. Corresponds to step 1 of use case 1.

Parameters:
storeIndex - the index of the store used.
cashDeskIndex - the index of the cash desk in the store.
Throws:
java.lang.Exception

startNewSale

protected void startNewSale()
                     throws java.lang.Exception
Executes actions for starting a new sale with a default number of items. Corresponds to step 2 of use case 1.

Throws:
java.lang.Exception

startNewSale

protected void startNewSale(int how_many_items)
                     throws java.lang.Exception
Executes actions for starting a new sale. Corresponds to step 2 of use case 1.

Parameters:
how_many_items - the number of items the sale should contain in total
Throws:
java.lang.Exception

enterAllRemainingProducts

protected void enterAllRemainingProducts()
                                  throws java.lang.Exception,
                                         java.util.concurrent.TimeoutException
Executes actions for entering products in the cashbox. This is done by using the bar code scanner. Correspondes to steps 3 and 4 of use case 1. This method enters all remaining products at once.

Throws:
java.lang.Exception
java.util.concurrent.TimeoutException

enterProducts

protected void enterProducts(int howMany)
                      throws java.lang.Exception,
                             java.util.concurrent.TimeoutException
Executes actions for entering products in the cashbox. This is done by using the bar code scanner. Correspondes to steps 3 and 4 of use case 1.

Parameters:
howMany - the number of products to be sold next.
Throws:
java.lang.Exception
java.util.concurrent.TimeoutException

finishSale

protected void finishSale()
                   throws java.lang.Exception
Executes actions for finishing sale (after entering all products in cashbox, before payment). Corresponds to step 5 of use case 1.

Throws:
java.lang.Exception

handleCashPayment

protected void handleCashPayment()
                          throws java.lang.Exception
Executs actions of handling cash payment. Corresponds to step 5 a. of use case 1.

Throws:
java.lang.Exception

updateInventory

protected void updateInventory()
                        throws java.lang.Exception
Executes actions after reciept of payment. Corresponds to steps 6, 7 and 8 of use case 1.

Throws:
java.lang.Exception

CoCoME System Tests

CoCoME System Tests - 0.1