Created
September 22, 2013 12:50
-
-
Save craigew/6659601 to your computer and use it in GitHub Desktop.
JPA Unit test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestClientManagement { | |
@Test | |
public void should_persist_a_customer() { | |
Customer customer = new Customer("John", "Doe", "123456", 36); | |
long id=new CustomerManagementService().createCustomer(customer); | |
Assert.assertEquals("Id is not was expected",5,id); | |
} | |
@Test | |
public void should_return_a_customer() { | |
Customer customer = new CustomerManagementService().findCustomerByPrimaryKey(1); | |
Assert.assertEquals("Name is not equal","Jane",customer.getName()); | |
Assert.assertEquals("Surname is not equal","Doe",customer.getSurname()); | |
Assert.assertEquals("Identity number is not equal","654321",customer.getIdentity_number()); | |
Assert.assertEquals("Age number is not equal",36,customer.getAge()); | |
} | |
@Test | |
public void should_update_a_customer() { | |
Customer customer = new CustomerManagementService().findCustomerByPrimaryKey(1); | |
customer.setAge(37); | |
new CustomerManagementService().updateCustomer(customer); | |
customer = new CustomerManagementService().findCustomerByPrimaryKey(1); | |
Assert.assertEquals("Age is not updated",37,customer.getAge()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment