コード例 #1
0
 private Customer getNewCustomerWithUniqueName() {
   Customer c1 = getCustomerComponent().createNew();
   c1.setName("A" + System.currentTimeMillis());
   c1.setPhoneNumber("808-555-1212");
   getCustomerComponent().persist(c1);
   return c1;
 }
コード例 #2
0
 @Test
 public void testDeleteCustomer() {
   Customer c1 = getNewCustomerWithUniqueName();
   Customer c1FromDb = getCustomerComponent().getById(c1.getId());
   getCustomerComponent().delete(c1FromDb);
   Customer c1FromDbAgain = getCustomerComponent().getById(c1.getId());
   assertNull(c1FromDbAgain);
 }
コード例 #3
0
  @Test
  public void testCustomerInsertAndGet() {
    Customer c1 = getNewCustomerWithUniqueName();
    Customer c2 = getNewCustomerWithUniqueName();

    assertEquals(c1.getId() + 1, c2.getId());

    Customer c1FromDb = getCustomerComponent().getById(c1.getId());
    assertEquals(c1.getName(), c1FromDb.getName());
  }
コード例 #4
0
 @Test
 public void testCustomerUpdateAndGet() {
   Customer c1 = getNewCustomerWithUniqueName();
   Customer c1FromDb = getCustomerComponent().getById(c1.getId());
   String NEW_PHONE = "415-555-1212";
   c1FromDb.setPhoneNumber(NEW_PHONE);
   getCustomerComponent().persist(c1FromDb);
   Customer c1FromDbAgain = getCustomerComponent().getById(c1.getId());
   assertEquals(NEW_PHONE, c1FromDbAgain.getPhoneNumber());
 }