001    package org.cocome.tradingsystem.systests.scenarios;
002    
003    /**
004     * This is an abstract base class for specifiying test scenarios which should be
005     * executed in the express sales mode. It provides methods for putting the
006     * system to express mode and verify express mode.
007     * 
008     * @author Christian Pfaller
009     * @author $Author: hummel $
010     * @version $Rev: 64 $
011     * @levd.rating GREEN Rev: 64
012     */
013    public abstract class ManageExpressCheckoutBase extends ProcessSaleBase {
014    
015            /** The maximum number of items allowed in an express sale. */
016            public static int MAXIMUM_ITEMS_AT_EXPRESS_SALE = 8;
017    
018            /**
019             * Executes the test scenario.
020             * 
021             * @throws Exception
022             */
023            public abstract void testScenario() throws Exception;
024    
025            /**
026             * Executes some express sales to put cash desk in express mode.
027             */
028            protected void putCashDeskInExpressMode() throws Exception {
029    
030                    // 1. The system records a certain amount of express sales
031                    // (since the are executed in a row timing shouldn't worth considering)
032                    for (int s = 0; s < cashDesk
033                                    .getNumberOfExpressSalesForExpressModeSwitch(); s++) {
034                            performExpressSale();
035                    }
036            }
037    
038            /**
039             * Executes actions to check notification of express mode.
040             */
041            protected void checkNotificationOfExpressMode() throws Exception {
042                    // 2. The system notifies the cashier, that it will swith to express
043                    // mode
044                    cashDesk.getUserDisplay().waitForUpdate(500);
045                    assertTrue("Message for express mode should be shown.", cashDesk
046                                    .getUserDisplay().isMessageForExpressModeShown());
047            }
048    
049            /**
050             * Executes actions to check the Lights display is switched on correctly.
051             */
052            protected void checkExpressModeLightsOn() throws Exception {
053                    // 3. The system switches the cash desks express light and no credit
054                    // card light on
055                    cashDesk.getLightsDisplay().waitForUpdate(500);
056                    assertTrue("Express light should be on.", cashDesk.getLightsDisplay()
057                                    .isExpressModeLightOn());
058                    assertTrue("'No credit card' light should be on.", cashDesk
059                                    .getLightsDisplay().isNoCreditCardLightOn());
060            }
061    
062            /**
063             * The methods performs a single sale with the maximum possible number of
064             * items for a express sale.
065             */
066            private void performExpressSale() throws Exception {
067    
068                    // The cashier starts new sale by pressing a button at the cash
069                    // box.
070                    startNewSale(MAXIMUM_ITEMS_AT_EXPRESS_SALE);
071    
072                    // Purchase goods
073                    enterProducts(MAXIMUM_ITEMS_AT_EXPRESS_SALE);
074    
075                    // The cashier indicates the end of entering items by pressing
076                    // the SaleFinished-button at the cash box.
077                    finishSale();
078    
079                    // customer pays cash
080                    handleCashPayment();
081    
082                    // update inventroy, print printout
083                    updateInventory();
084            }
085    }