@Test(dependsOnMethods = "createCustomer") private void readCustomer() { customerCrudService = (CustomerCrudService) ctx.getBean("customerCrudService"); // Get Tax Table By ID Customer customer = customerCrudService.findById(id); // Do assertions Assert.assertEquals(customer.getCustomerNumber(), "TH66666"); }
@Test(dependsOnMethods = "readCustomer") private void updateCustomer() { customerCrudService = (CustomerCrudService) ctx.getBean("customerCrudService"); Customer customer = customerCrudService.findById(id); customer.setCustomerNumber("TY77777"); // Update the Record in the Database customerCrudService.merge(customer); // Retrive the UPdata Record Customer updatedCustomer = customerCrudService.findById(id); // Test if the Change Happened Assert.assertEquals(updatedCustomer.getCustomerNumber(), "TY77777"); }
@Test private void createCustomer() { // Create the Service Object customerCrudService = (CustomerCrudService) ctx.getBean("customerCrudService"); Name name = AppFactory.getName("Sannie", "Meyer"); Demographic demo = AppFactory.getDemographic("female", "white"); Contact contact = AppFactory.getContact("098877777", "878878987"); Customer customer = AppFactory.getCustomer("TH66666", name, contact, demo); customerCrudService.persist(customer); // Collect the ID for use in later TESTS id = customer.getId(); // Asssert if we have persisted the Customer Assert.assertNotNull(customer); }