KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > store > retailproconvert > RetailProOrderArchiveTest


1 /*
2  * Created on Oct 12, 2004
3  */

4 package com.openedit.store.retailproconvert;
5
6 import org.openedit.money.Fraction;
7 import org.openedit.money.Money;
8
9 import com.openedit.store.Cart;
10 import com.openedit.store.CreditCardType;
11 import com.openedit.store.CreditPaymentMethod;
12 import com.openedit.store.PaymentMethod;
13 import com.openedit.store.ShippingMethod;
14 import com.openedit.store.Store;
15 import com.openedit.store.StoreException;
16 import com.openedit.store.StoreTestCase;
17 import com.openedit.store.customer.Address;
18 import com.openedit.store.customer.Customer;
19 import com.openedit.store.shipping.FixedCostShippingMethod;
20
21 /**
22  * @author Matthew Avery, mavery@einnovation.com
23  */

24 public class RetailProOrderArchiveTest extends StoreTestCase
25 {
26
27     public RetailProOrderArchiveTest( String JavaDoc name )
28     {
29         super( name );
30     }
31
32     public void testOrderArchive() throws Exception JavaDoc
33     {
34         RetailProOrderArchive archiver = new RetailProOrderArchive();
35         Store store = getStore();
36
37         archiver.exportNewOrder( getFixture().createPageRequest(), store, createOrder() );
38
39         archiver.archiveOrderData( store );
40     }
41     
42     public void testNextOrderNumber() throws Exception JavaDoc
43     {
44         RetailProOrderArchive archiver = new RetailProOrderArchive();
45         String JavaDoc orderNumber = getStore().getOrderGenerator().nextOrderNumber( getStore() );
46         assertEquals( 10, orderNumber.length() );
47         String JavaDoc nextOrderNumber = getStore().getOrderGenerator().nextOrderNumber( getStore() );
48         System.out.println( orderNumber + ", " + nextOrderNumber );
49         assertFalse( nextOrderNumber.equals( orderNumber ) );
50     }
51     
52     
53     protected Cart createCart() throws StoreException
54     {
55         Cart cart = new Cart();
56         
57         cart.addItem( createCheapToyCartItem() );
58         cart.setCustomer( createCustomer() );
59         cart.setShippingMethod( createShippingMethod() );
60         return cart;
61     }
62     
63     protected PaymentMethod createPaymentMethod()
64     {
65         CreditPaymentMethod paymentMethod = new CreditPaymentMethod();
66         CreditCardType type = new CreditCardType();
67         type.setName( "Mastercard" );
68         paymentMethod.setCreditCardType( type );
69         paymentMethod.setCardNumber( "5555444455554444" );
70         paymentMethod.setExpirationMonth( 12 );
71         paymentMethod.setExpirationYear( 2004 );
72         return paymentMethod;
73     }
74     
75     protected ShippingMethod createShippingMethod()
76     {
77         FixedCostShippingMethod method = new FixedCostShippingMethod();
78         method.setCost( new Money(6.50) );
79         method.setDescription( "UPS ground" );
80         method.setId("UPS1");
81         return method;
82     }
83     protected Customer createCustomer()
84     {
85         Customer customer = new Customer();
86         Address address = customer.getBillingAddress();
87         address.setAddress1( "1234 Progammer Way");
88         address.setAddress2( "Suite 100" );
89         address.setCity("Cincinnati");
90         address.setState("Ohio");
91         customer.setFirstName("Joe");
92         customer.setLastName( "Schmoe");
93         customer.setEmail( "joe.schmoe@company.com");
94         address.setCountry("USA");
95         customer.setUserName( "Joe" );
96         customer.setTaxRate( new Fraction( 0.055 ) );
97         return customer;
98     }
99 }
100
Popular Tags