001 package org.cocome.tradingsystem.systests.scenarios; 002 003 /** 004 * This test covers use case 1 (process sale) with exception in step 5.2 (credit 005 * card validation fails) 006 * 007 * @author Christian Pfaller 008 * @author $Author: hummel $ 009 * @version $Revision: 1.1 $ 010 * @lev.rating GREEN Rev: 65 011 */ 012 013 public class ProcessSaleCreditCardFailTest extends ProcessSaleBase { 014 015 /** Number of valid credit card in this test */ 016 private final static int CARD_NUMBER = 99999; 017 018 /** PIN of valid credit card in ths test */ 019 private final static int CARD_PIN = 1234; 020 021 /** 022 * Mony available for the credit card, given in cents Thus 1 Million Euro 023 * should be enough to cover every sale 024 */ 025 private final static int CARD_MONEY = 100000000; 026 027 /** Execute the test scenario. */ 028 public void testScenario() throws Exception { 029 // first, create a valid credit card 030 bank.createCreditCard(CARD_NUMBER, CARD_PIN, CARD_MONEY); 031 032 // execute sales szenario 033 initializeCashDesk(0, 0); 034 startNewSale(); 035 enterAllRemainingProducts(); 036 finishSale(); 037 handlePayment(); 038 updateInventory(); 039 } 040 041 /** 042 * Executes actions for credit card payment. Corresponds to step 5 b. in use 043 * case 1. 044 */ 045 protected void handlePayment() throws Exception { 046 // 5 b. The cashier presses button for credit card payment. 047 cashBox.startCreditCardPayment(); 048 049 // 5 b. i. Cashier pulls credit card through the card reader 050 cashDesk.getCardReader().enterCard(CARD_NUMBER); 051 052 // try to use credit card with wrong pin 053 // provoke card validation failure 054 cashDesk.getCardReader().enterPin(0); 055 056 // credit card validation fails 057 cashDesk.getUserDisplay().waitForUpdate(500); 058 assertTrue("Message for failed credit card validation should be shown", 059 cashDesk.getUserDisplay() 060 .isMessageForCreditCardValidationFailedShown()); 061 062 // do cash payment instead 063 handleCashPayment(); 064 } 065 066 }