public void testCustomerUpdateMySql() throws SQLException { // Create a new custom customer Customer cust1 = new Customer(-1, "name-1", "lastname-1", "address-1"); // Delete previous cust1, just in case customerDaoMysql.delete(cust1); // Add the just created customer customerDaoMysql.add(cust1); // Now duplicate and change some attrs Customer cust1Updt = new Customer(cust1); cust1Updt.setName("name-1-updated"); cust1Updt.setLastname("lastname-1-updated"); cust1Updt.setAddress("address-1-updated"); // Now, update the db customerDaoMysql.update(cust1Updt); // Find the updated customer in the DB Customer cust2 = new Customer(); cust2 = customerDaoMysql.find(-1); // Assert if something is different assertEquals(cust1Updt.getId(), cust2.getId()); assertEquals(cust1Updt.getName(), cust2.getName()); assertEquals(cust1Updt.getLastname(), cust2.getLastname()); assertEquals(cust1Updt.getAddress(), cust2.getAddress()); // And delete object to clean up after ourselves customerDaoMysql.delete(cust1); }
public void testCustomerAddMySql() throws SQLException { // Create a new custom customer Customer cust1 = new Customer(-1, "name-1", "lastname-1", "address-1"); // Delete previous cust1, just in case customerDaoMysql.delete(cust1); // Add the just created customer customerDaoMysql.add(cust1); // Find the added customer in the DB Customer cust2 = new Customer(); cust2 = customerDaoMysql.find(-1); // Assert if something is different assertEquals(cust1.getId(), cust2.getId()); assertEquals(cust1.getName(), cust2.getName()); assertEquals(cust1.getLastname(), cust2.getLastname()); assertEquals(cust1.getAddress(), cust2.getAddress()); // And delete object to clean up after ourselves customerDaoMysql.delete(cust1); }