KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > store > CustomerTest


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

4 package com.openedit.store;
5
6 import java.util.List JavaDoc;
7
8 import com.openedit.modules.cart.XmlCustomerArchive;
9 import com.openedit.store.customer.Customer;
10 import com.openedit.users.User;
11
12 /**
13  * @author cburkey
14  *
15  */

16 public class CustomerTest extends StoreTestCase
17 {
18
19     /**
20      * @param inArg0
21      */

22     public CustomerTest(String JavaDoc inArg0)
23     {
24         super(inArg0);
25     }
26     public void testFindCustomer() throws Exception JavaDoc
27     {
28         XmlCustomerArchive archive = (XmlCustomerArchive)getStore().getCustomerArchive();
29         
30         List JavaDoc 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 JavaDoc 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 JavaDoc
46     {
47         /**
48          * This test assumes Retail pro conversion worked ok
49          */

50         CustomerArchive archive = getStore().getCustomerArchive();
51         Customer customer = archive.getCustomer("1006");
52         assertNotNull(customer);
53         assertEquals("Julia", customer.getFirstName());
54         assertEquals("955 Lakepointe Court", customer.getShippingAddress().getAddress1());
55
56         customer.setFirstName("Bob");
57         customer.getBillingAddress().setAddress1("713 Evergreen Terrace");
58         customer.getShippingAddress().setAddress1("P.O. Box 500");
59         customer.getShippingAddress().setAddress2("Attn: Bob");
60         customer.getShippingAddress().setCity("Bridgetown");
61         customer.getShippingAddress().setState("OH");
62         customer.getShippingAddress().setZipCode("45212");
63         archive.saveCustomer(customer);
64
65         customer = archive.getCustomer("1006");
66         assertEquals("Bob", customer.getFirstName());
67         assertEquals("713 Evergreen Terrace", customer.getBillingAddress().getAddress1());
68         assertEquals("P.O. Box 500", customer.getShippingAddress().getAddress1());
69         assertEquals("Attn: Bob", customer.getShippingAddress().getAddress2());
70         assertEquals("Bridgetown", customer.getShippingAddress().getCity());
71         assertEquals("OH", customer.getShippingAddress().getState());
72         assertEquals("45212", customer.getShippingAddress().getZipCode());
73     }
74
75     public void testExport() throws Exception JavaDoc
76     {
77         CustomerArchive archive = getStore().getCustomerArchive();
78         Customer c = archive.getCustomer("1008");
79         assertNotNull(c);
80         archive.saveAndExportCustomer(c);
81         assertEquals("Barbara", c.getFirstName());
82         c.setFirstName("Lucy");
83         archive.saveAndExportCustomer(c);
84         c = archive.getCustomer("1008");
85         assertEquals("Lucy", c.getFirstName());
86         c.setFirstName("Barbara");
87         archive.saveAndExportCustomer(c);
88         c = archive.getCustomer("1008");
89         assertEquals("Barbara", c.getFirstName());
90         
91     }
92     //public void testOrderCustomer
93
}
94
Popular Tags