@Test
public void testCrud() throws Exception {
databaseTester.onTearDown(); // clear db before tests
// CREATE
Assert.assertEquals(0, userService.count());
User user = new User();
user.setFirstName("Name");
user.setLastName("Name");
user.setEmail("a@a.com");
user.setUsername("username");
userService.add(user);
Assert.assertEquals(1, userService.count());
// READ
User readuser = userService.list().get(0);
Assert.assertEquals(readuser.getFirstName(), "Name");
Assert.assertEquals(readuser.getLastName(), "Name");
Assert.assertEquals(readuser.getEmail(), "a@a.com");
Assert.assertEquals(readuser.getUsername(), "username");
// UPDATE
readuser.setFirstName("updatedName");
userService.update(readuser);
User updateduser = userService.list().get(0);
Assert.assertEquals(updateduser.getFirstName(), "updatedName");
// DELETE
userService.delete(updateduser.getId());
Assert.assertEquals(0, userService.count());
}