001 package org.cocome.tradingsystem.systests.scenarios;
002
003 /**
004 * This test covers use case 1 (ProcessSale) for credit card payment without any
005 * exceptions.
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 ProcessSaleCreditCardTest 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 /** Executes 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 handleCreditCardPayment();
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 handleCreditCardPayment() 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 // 5 b. ii. Customer enters PIN
053 cashDesk.getCardReader().enterPin(CARD_PIN);
054
055 cashDesk.getUserDisplay().waitForUpdate(500);
056 assertTrue(
057 "Message for successful credit card payment should be shown",
058 cashDesk.getUserDisplay()
059 .isMessageForCreditCardPaymentSuccessfulShown());
060
061 }
062
063 }