Coverage Report - org.mule.samples.voipservice.to.CreditCardTO
 
Classes in this File Line Coverage Branch Coverage Complexity
CreditCardTO
0%
0/43
0%
0/6
1.364
 
 1  
 /*
 2  
  * $Id: CreditCardTO.java 7963 2007-08-21 08:53:15Z 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  
 public class CreditCardTO implements Serializable, Cloneable
 20  
 {
 21  
     /**
 22  
      * Serial version
 23  
      */
 24  
     private static final long serialVersionUID = 7743847846905485620L;
 25  
 
 26  
     private String cardNumber;
 27  
     private String validTill;
 28  
     private String cardType;
 29  
 
 30  
     public static final String VISA = "Visa";
 31  
     public static final String MASTER_CARD = "Master Card";
 32  
     public static final String AMEX = "Amex";
 33  
 
 34  
     private static final List CREDIT_CARDS;
 35  
 
 36  
     static
 37  
     {
 38  0
         CREDIT_CARDS = new ArrayList();
 39  
 
 40  0
         CREDIT_CARDS.add(new CreditCardTO("1111-2222-3333-4444", "01-JAN-2006", VISA));
 41  0
         CREDIT_CARDS.add(new CreditCardTO("2222-3333-4444-5555", "01-FEB-2006", MASTER_CARD));
 42  0
         CREDIT_CARDS.add(new CreditCardTO("3333-4444-5555-6666", "01-MAR-2006", VISA));
 43  0
         CREDIT_CARDS.add(new CreditCardTO("4444-5555-6666-7777", "01-APR-2006", VISA));
 44  0
         CREDIT_CARDS.add(new CreditCardTO("5555-6666-7777-8888", "01-JAN-2007", MASTER_CARD));
 45  0
         CREDIT_CARDS.add(new CreditCardTO("6666-7777-8888-9999", "01-FEB-2007", MASTER_CARD));
 46  0
         CREDIT_CARDS.add(new CreditCardTO("7777-8888-9999-1111", "01-MAR-2007", VISA));
 47  0
         CREDIT_CARDS.add(new CreditCardTO("8888-9999-1111-2222", "01-APR-2007", MASTER_CARD));
 48  0
         CREDIT_CARDS.add(new CreditCardTO("9999-1111-2222-3333", "01-JAN-2008", VISA));
 49  0
         CREDIT_CARDS.add(new CreditCardTO("9999-1111-2222-4444", "01-FEB-2008", VISA));
 50  0
     }
 51  
 
 52  
     public CreditCardTO()
 53  
     {
 54  0
         super();
 55  0
     }
 56  
 
 57  
     public CreditCardTO(String cardNumber, String validTill, String cardType)
 58  0
     {
 59  0
         this.cardNumber = cardNumber;
 60  0
         this.validTill = validTill;
 61  0
         this.cardType = cardType;
 62  0
     }
 63  
 
 64  
     public void setCardNumber(String cardNumber)
 65  
     {
 66  0
         this.cardNumber = cardNumber;
 67  0
     }
 68  
 
 69  
     public String getCardNumber()
 70  
     {
 71  0
         return cardNumber;
 72  
     }
 73  
 
 74  
     public void setValidTill(String validTill)
 75  
     {
 76  0
         this.validTill = validTill;
 77  0
     }
 78  
 
 79  
     public String getValidTill()
 80  
     {
 81  0
         return validTill;
 82  
     }
 83  
 
 84  
     public void setCardType(String cardType)
 85  
     {
 86  0
         this.cardType = cardType;
 87  0
     }
 88  
 
 89  
     public String getCardType()
 90  
     {
 91  0
         return cardType;
 92  
     }
 93  
 
 94  
     public Object clone()
 95  
     {
 96  0
         Object clone = null;
 97  
         try
 98  
         {
 99  0
             clone = super.clone();
 100  
         }
 101  0
         catch (CloneNotSupportedException cloneNotSupportedException)
 102  
         {
 103  
             // too bad
 104  0
         }
 105  0
         return clone;
 106  
     }
 107  
 
 108  
     public String toString()
 109  
     {
 110  0
         StringBuffer stringBuffer = new StringBuffer();
 111  0
         if (this.cardNumber != null)
 112  
         {
 113  0
             stringBuffer.append(LocaleMessage.getCardNumberCaption(cardNumber));
 114  
         }
 115  0
         if (this.validTill != null)
 116  
         {
 117  0
             stringBuffer.append(LocaleMessage.getValidTillCaption(validTill));
 118  
         }
 119  0
         if (this.cardType != null)
 120  
         {
 121  0
             stringBuffer.append(LocaleMessage.getCardTypeCaption(cardType));
 122  
         }
 123  0
         return stringBuffer.toString();
 124  
     }
 125  
 
 126  
     public static CreditCardTO getRandomCreditCard()
 127  
     {
 128  
 
 129  0
         int index = new Double(Math.random() * 10).intValue();
 130  0
         return (CreditCardTO)((CreditCardTO)CREDIT_CARDS.get(index)).clone();
 131  
     }
 132  
 
 133  
 }