Coverage Report - org.mule.samples.voipservice.to.CreditCardTO
 
Classes in this File Line Coverage Branch Coverage Complexity
CreditCardTO
0%
0/43
0%
0/3
1.364
 
 1  
 /*
 2  
  * $Id: CreditCardTO.java 7976 2007-08-21 14:26:13Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.samples.voipservice.to;
 12  
 
 13  
 import org.mule.samples.voipservice.LocaleMessage;
 14  
 
 15  
 import java.io.Serializable;
 16  
 import java.util.ArrayList;
 17  
 import java.util.List;
 18  
 
 19  
 /**
 20  
  * @author Binildas Christudas
 21  
  */
 22  
 public class CreditCardTO implements Serializable, Cloneable
 23  
 {
 24  
     /**
 25  
      * Serial version
 26  
      */
 27  
     private static final long serialVersionUID = 7743847846905485620L;
 28  
 
 29  
     private String cardNumber;
 30  
     private String validTill;
 31  
     private String cardType;
 32  
 
 33  
     public static final String VISA = "Visa";
 34  
     public static final String MASTER_CARD = "Master Card";
 35  
     public static final String AMEX = "Amex";
 36  
 
 37  
     private static final List CREDIT_CARDS;
 38  
 
 39  
     static
 40  
     {
 41  0
         CREDIT_CARDS = new ArrayList();
 42  
 
 43  0
         CREDIT_CARDS.add(new CreditCardTO("1111-2222-3333-4444", "01-JAN-2006", VISA));
 44  0
         CREDIT_CARDS.add(new CreditCardTO("2222-3333-4444-5555", "01-FEB-2006", MASTER_CARD));
 45  0
         CREDIT_CARDS.add(new CreditCardTO("3333-4444-5555-6666", "01-MAR-2006", VISA));
 46  0
         CREDIT_CARDS.add(new CreditCardTO("4444-5555-6666-7777", "01-APR-2006", VISA));
 47  0
         CREDIT_CARDS.add(new CreditCardTO("5555-6666-7777-8888", "01-JAN-2007", MASTER_CARD));
 48  0
         CREDIT_CARDS.add(new CreditCardTO("6666-7777-8888-9999", "01-FEB-2007", MASTER_CARD));
 49  0
         CREDIT_CARDS.add(new CreditCardTO("7777-8888-9999-1111", "01-MAR-2007", VISA));
 50  0
         CREDIT_CARDS.add(new CreditCardTO("8888-9999-1111-2222", "01-APR-2007", MASTER_CARD));
 51  0
         CREDIT_CARDS.add(new CreditCardTO("9999-1111-2222-3333", "01-JAN-2008", VISA));
 52  0
         CREDIT_CARDS.add(new CreditCardTO("9999-1111-2222-4444", "01-FEB-2008", VISA));
 53  0
     }
 54  
 
 55  
     public CreditCardTO()
 56  
     {
 57  0
         super();
 58  0
     }
 59  
 
 60  
     public CreditCardTO(String cardNumber, String validTill, String cardType)
 61  0
     {
 62  0
         this.cardNumber = cardNumber;
 63  0
         this.validTill = validTill;
 64  0
         this.cardType = cardType;
 65  0
     }
 66  
 
 67  
     public void setCardNumber(String cardNumber)
 68  
     {
 69  0
         this.cardNumber = cardNumber;
 70  0
     }
 71  
 
 72  
     public String getCardNumber()
 73  
     {
 74  0
         return cardNumber;
 75  
     }
 76  
 
 77  
     public void setValidTill(String validTill)
 78  
     {
 79  0
         this.validTill = validTill;
 80  0
     }
 81  
 
 82  
     public String getValidTill()
 83  
     {
 84  0
         return validTill;
 85  
     }
 86  
 
 87  
     public void setCardType(String cardType)
 88  
     {
 89  0
         this.cardType = cardType;
 90  0
     }
 91  
 
 92  
     public String getCardType()
 93  
     {
 94  0
         return cardType;
 95  
     }
 96  
 
 97  
     public Object clone()
 98  
     {
 99  0
         Object clone = null;
 100  
         try
 101  
         {
 102  0
             clone = super.clone();
 103  
         }
 104  0
         catch (CloneNotSupportedException cloneNotSupportedException)
 105  
         {
 106  
             // too bad
 107  0
         }
 108  0
         return clone;
 109  
     }
 110  
 
 111  
     public String toString()
 112  
     {
 113  0
         StringBuffer stringBuffer = new StringBuffer();
 114  0
         if (this.cardNumber != null)
 115  
         {
 116  0
             stringBuffer.append(LocaleMessage.getCardNumberCaption(cardNumber));
 117  
         }
 118  0
         if (this.validTill != null)
 119  
         {
 120  0
             stringBuffer.append(LocaleMessage.getValidTillCaption(validTill));
 121  
         }
 122  0
         if (this.cardType != null)
 123  
         {
 124  0
             stringBuffer.append(LocaleMessage.getCardTypeCaption(cardType));
 125  
         }
 126  0
         return stringBuffer.toString();
 127  
     }
 128  
 
 129  
     public static CreditCardTO getRandomCreditCard()
 130  
     {
 131  
 
 132  0
         int index = new Double(Math.random() * 10).intValue();
 133  0
         return (CreditCardTO)((CreditCardTO)CREDIT_CARDS.get(index)).clone();
 134  
     }
 135  
 
 136  
 }