@Test public void testCreate() throws Exception { final EntityTransaction tx = entityManager.getTransaction(); tx.begin(); final User frank = createUser.create(new CredentialsVO("createdUser", "strongP@ass001")); tx.commit(); final User persistedUser = entityManager.find(User.class, frank.getId()); assertEquals("The right user was loaded from database", frank, persistedUser); }
@Test(expected = IllegalArgumentException.class) public void testCreateWithEmptyPassword() throws Exception { final User frank = createUser.create(new CredentialsVO("invalidUser", "")); }
@Test(expected = IllegalArgumentException.class) public void testCreateWithEmptyUsername() throws Exception { final User frank = createUser.create(new CredentialsVO("", "strongP@ass001")); }