01: /*
02: * Created on Oct 5, 2004
03: */
04: package com.openedit.store;
05:
06: import java.util.List;
07:
08: import org.openedit.store.CustomerArchive;
09: import org.openedit.store.StoreTestCase;
10: import org.openedit.store.customer.Customer;
11: import org.openedit.store.xmldb.XmlCustomerArchive;
12:
13: /**
14: * @author cburkey
15: *
16: */
17: public class CustomerTest extends StoreTestCase {
18:
19: /**
20: * @param inArg0
21: */
22: public CustomerTest(String inArg0) {
23: super (inArg0);
24: }
25:
26: public void testFindCustomer() throws Exception {
27: XmlCustomerArchive archive = (XmlCustomerArchive) getStore()
28: .getCustomerArchive();
29:
30: List users = archive.findUser("user-name:admin");
31: assertEquals(1, users.size());
32:
33: // users = archive.findUser("Phone1:5135423401");
34: // assertEquals(2,users.size() );
35: //
36: // users = archive.findUser("lastName:Burkey");
37: // assertEquals(1,users.size() );
38: //
39: // List hits = archive.findCustomer(User.LAST_NAME_PROPERTY,"BURKEY",
40: // Customer.PHONE1,"513-542-3401");
41: // assertNotNull(hits);
42: // assertEquals(1,hits.size() );
43: }
44:
45: public void testEditCustomer() throws Exception {
46: /**
47: * This test assumes Retail pro conversion worked ok
48: */
49: CustomerArchive archive = getStore().getCustomerArchive();
50: Customer customer = archive.createNewCustomer("1006", "sdfdsf");
51: assertNotNull(customer);
52:
53: //assertEquals("Julia", customer.getFirstName());
54: //assertEquals("955 Lakepointe Court", customer.getShippingAddress().getAddress1());
55:
56: customer.setFirstName("Bob");
57: customer.getBillingAddress().setAddress1(
58: "713 Evergreen Terrace");
59: customer.getShippingAddress().setAddress1("P.O. Box 500");
60: customer.getShippingAddress().setAddress2("Attn: Bob");
61: customer.getShippingAddress().setCity("Bridgetown");
62: customer.getShippingAddress().setState("OH");
63: customer.getShippingAddress().setZipCode("45212");
64: archive.saveCustomer(customer);
65:
66: customer = archive.getCustomer("1006");
67: assertEquals("Bob", customer.getFirstName());
68: assertEquals("713 Evergreen Terrace", customer
69: .getBillingAddress().getAddress1());
70: assertEquals("P.O. Box 500", customer.getShippingAddress()
71: .getAddress1());
72: assertEquals("Attn: Bob", customer.getShippingAddress()
73: .getAddress2());
74: assertEquals("Bridgetown", customer.getShippingAddress()
75: .getCity());
76: assertEquals("OH", customer.getShippingAddress().getState());
77: assertEquals("45212", customer.getShippingAddress()
78: .getZipCode());
79: }
80:
81: public void XtestExport() throws Exception {
82: CustomerArchive archive = getStore().getCustomerArchive();
83: Customer c = archive.getCustomer("1008");
84: assertNotNull(c);
85: archive.saveAndExportCustomer(c);
86: assertEquals("Barbara", c.getFirstName());
87: c.setFirstName("Lucy");
88: archive.saveAndExportCustomer(c);
89: c = archive.getCustomer("1008");
90: assertEquals("Lucy", c.getFirstName());
91: c.setFirstName("Barbara");
92: archive.saveAndExportCustomer(c);
93: c = archive.getCustomer("1008");
94: assertEquals("Barbara", c.getFirstName());
95:
96: }
97: //public void testOrderCustomer
98: }
|