@Test public void testRegister() throws MovieException { User user = TestUtils.createTestUser(NAME, "pass123", new Date(), NAME + "@email.com"); int accountId = accountService.create(user.getAccount()); user.getAccount().setId(accountId); service.register(user); user = service.getUserByName(NAME); assertTrue(user.getId() > 0); }
@Test public void testUpdate() throws MovieException { User user = service.getUserByName(NAME); String newName = NAME + " 1"; user.setName(newName); service.update(user); user = service.getUserByName(newName); assertEquals(user.getUsername(), newName); }
@Test public void testGetByEmail() throws MovieException { String email = "*****@*****.**"; User user = service.getUserByEmail(email); assertNotNull(user); assertEquals(user.getEmail(), email); }
@Test public void testGetById() { int id = 1; User user = service.getById(id); assertNotNull(user); assertEquals(user.getId(), id); }
@Test public void testGetByName() throws MovieException { String name = "Olga"; User user = service.getUserByName(name); assertNotNull(user); assertEquals(user.getUsername(), name); }
@Test(expected = MovieException.class) public void testGetByEmptyEmail() throws MovieException { String email = ""; service.getUserByEmail(email); }
@Test(expected = MovieException.class) public void testGetByEmptyName() throws MovieException { String name = ""; service.getUserByName(name); }