Esempio n. 1
0
  /** Tests the functionality of the set methods for the customer class */
  @Test
  public void CustomerSetMethods() {

    testCustomer.setCustomerID(10);
    assertEquals(10, testCustomer.getCustomerID());

    testCustomer.setCustomerPhone("07788254414");
    assertEquals("07788254414", testCustomer.getCustomerPhone());

    testCustomer.setAvailableCredit(5000);
    assertEquals(5000f, testCustomer.getAvailableCredit(), 0.001f);

    testCustomer.setCustomerName("Jerry Springer");
    assertEquals("Jerry Springer", testCustomer.getCustomerName());

    testCustomer.setCustomerEmail("*****@*****.**");
    assertEquals("*****@*****.**", testCustomer.getCustomerEmail());

    testCustomer.setCustomerUsername("spring");
    assertEquals("spring", testCustomer.getCustomerUsername());

    testCustomer.setCustomerPassword("springer123");
    assertEquals("springer123", testCustomer.getCustomerPassword());

    testCustomer.setCustomerContactMethod("PHONE");
    assertEquals("PHONE", testCustomer.getCustomerContactMethod());
  }
Esempio n. 2
0
  public void testIdClass() {
    Type type = getSessions().getClassMetadata(Customer.class).getIdentifierType();
    Type[] types = getSessions().getClassMetadata(Customer.class).getPropertyTypes();
    Session s = openSession();
    Transaction t = s.beginTransaction();
    Customer cust = new FavoriteCustomer("JBoss", "RouteOne", "Detroit");
    s.persist(cust);
    t.commit();
    s.close();

    s = openSession();
    CustomerId custId = new CustomerId("JBoss", "RouteOne");
    t = s.beginTransaction();
    cust = (Customer) s.get(Customer.class, custId);
    assertEquals("Detroit", cust.getAddress());
    assertEquals(cust.getCustomerName(), custId.getCustomerName());
    assertEquals(cust.getOrgName(), custId.getOrgName());
    t.commit();
    s.close();

    s = openSession();
    t = s.beginTransaction();
    cust =
        (Customer) s.createQuery("from Customer where id.customerName = 'RouteOne'").uniqueResult();
    assertEquals("Detroit", cust.getAddress());
    assertEquals(cust.getCustomerName(), custId.getCustomerName());
    assertEquals(cust.getOrgName(), custId.getOrgName());
    t.commit();
    s.close();

    s = openSession();
    t = s.beginTransaction();
    cust = (Customer) s.createQuery("from Customer where customerName = 'RouteOne'").uniqueResult();
    assertEquals("Detroit", cust.getAddress());
    assertEquals(cust.getCustomerName(), custId.getCustomerName());
    assertEquals(cust.getOrgName(), custId.getOrgName());

    s.createQuery("delete from Customer").executeUpdate();

    t.commit();
    s.close();
  }
Esempio n. 3
0
 /** Tests the functionality of the get methods for the customer class */
 @Test
 public void CustomerGetMethods() {
   assertEquals(1, testCustomer.getCustomerID());
   assertEquals("01782566491", testCustomer.getCustomerPhone());
   assertEquals(10000f, testCustomer.getAvailableCredit(), 0.001f);
   assertEquals("George Freshwater", testCustomer.getCustomerName());
   assertEquals("*****@*****.**", testCustomer.getCustomerEmail());
   assertEquals("fresh", testCustomer.getCustomerUsername());
   assertEquals("water123", testCustomer.getCustomerPassword());
   assertEquals("EMAIL", testCustomer.getCustomerContactMethod());
 }