1 4 package com.openedit.store; 5 6 import java.util.List ; 7 8 import com.openedit.modules.cart.XmlCustomerArchive; 9 import com.openedit.store.customer.Customer; 10 import com.openedit.users.User; 11 12 16 public class CustomerTest extends StoreTestCase 17 { 18 19 22 public CustomerTest(String inArg0) 23 { 24 super(inArg0); 25 } 26 public void testFindCustomer() throws Exception 27 { 28 XmlCustomerArchive archive = (XmlCustomerArchive)getStore().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 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 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 } 94 | Popular Tags |