01: /*
02: * Created on Oct 12, 2004
03: */
04: package com.openedit.store.retailproconvert;
05:
06: import org.openedit.money.Fraction;
07: import org.openedit.money.Money;
08: import org.openedit.store.Cart;
09: import org.openedit.store.CreditCardType;
10: import org.openedit.store.CreditPaymentMethod;
11: import org.openedit.store.PaymentMethod;
12: import org.openedit.store.ShippingMethod;
13: import org.openedit.store.Store;
14: import org.openedit.store.StoreException;
15: import org.openedit.store.StoreTestCase;
16: import org.openedit.store.customer.Address;
17: import org.openedit.store.customer.Customer;
18: import org.openedit.store.retailproconvert.RetailProOrderArchive;
19: import org.openedit.store.shipping.FixedCostShippingMethod;
20:
21: /**
22: * @author Matthew Avery, mavery@einnovation.com
23: */
24: public class RetailProOrderArchiveTest extends StoreTestCase {
25:
26: public RetailProOrderArchiveTest(String name) {
27: super (name);
28: }
29:
30: public void testOrderArchive() throws Exception {
31: RetailProOrderArchive archiver = new RetailProOrderArchive();
32: Store store = getStore();
33:
34: archiver.exportNewOrder(getFixture().createPageRequest(),
35: store, createOrder());
36:
37: archiver.archiveOrderData(store);
38: }
39:
40: public void testNextOrderNumber() throws Exception {
41: RetailProOrderArchive archiver = new RetailProOrderArchive();
42: String orderNumber = getStore().getOrderGenerator()
43: .nextOrderNumber(getStore());
44: assertEquals(10, orderNumber.length());
45: String nextOrderNumber = getStore().getOrderGenerator()
46: .nextOrderNumber(getStore());
47: //System.out.println( orderNumber + ", " + nextOrderNumber );
48: assertFalse(nextOrderNumber.equals(orderNumber));
49: }
50:
51: protected Cart createCart() throws StoreException {
52: Cart cart = new Cart();
53:
54: cart.addItem(createCheapToyCartItem());
55: cart.setCustomer(createCustomer());
56: cart.setShippingMethod(createShippingMethod());
57: return cart;
58: }
59:
60: protected PaymentMethod createPaymentMethod() {
61: CreditPaymentMethod paymentMethod = new CreditPaymentMethod();
62: CreditCardType type = new CreditCardType();
63: type.setName("Mastercard");
64: paymentMethod.setCreditCardType(type);
65: paymentMethod.setCardNumber("5555444455554444");
66: paymentMethod.setExpirationMonth(12);
67: paymentMethod.setExpirationYear(2004);
68: return paymentMethod;
69: }
70:
71: protected ShippingMethod createShippingMethod() {
72: FixedCostShippingMethod method = new FixedCostShippingMethod();
73: method.setCost(new Money(6.50));
74: method.setDescription("UPS ground");
75: method.setId("UPS1");
76: return method;
77: }
78:
79: protected Customer createCustomer() {
80: Customer customer = new Customer();
81: Address address = customer.getBillingAddress();
82: address.setAddress1("1234 Progammer Way");
83: address.setAddress2("Suite 100");
84: address.setCity("Cincinnati");
85: address.setState("Ohio");
86: customer.setFirstName("Joe");
87: customer.setLastName("Schmoe");
88: customer.setEmail("joe.schmoe@company.com");
89: address.setCountry("USA");
90: customer.setUserName("Joe");
91: customer.setTaxRate(new Fraction(0.055));
92: return customer;
93: }
94: }
|