@PersistenceContext
EntityManager entityManager;
@Test
public void createUser() throws Exception {
User user = userService.createUser("test", "test1", "Kalle", "Anka");
Assert.assertNotNull(user);
Assert.assertEquals(user.getFirstname(), "Kalle");
try {
user = userService.createUser("test", "test1", "Kalle", "Anka");
Assert.fail("Should not be able to create user with same name");
} catch (CaseboxException e) {
Assert.assertEquals("error.user.alreadyexist", e.getMessageCode());
}
user = userService.createUser("test1", "test1", "Kalle", "Anka");
Assert.assertNotNull(user);
Assert.assertEquals(user.getUsername(), "test1");
ITable result = getConnection().createQueryTable("AUTHORITIES", "SELECT * FROM AUTHORITIES WHERE USERNAME = 'test1'");
Assert.assertEquals("ROLE_USER", result.getValue(0, "AUTHORITY"));
}