@Test public void readUserTest() throws ServiceException, DAOException { User expectedUser = userMock; User resultUser = null; when(userDAOMock.read(anyLong())).thenReturn(expectedUser); resultUser = userService.readUser(anyLong()); verify(userDAOMock, times(1)).read(anyLong()); assertEquals(expectedUser, resultUser); }
@Test public void getAllUsersTest() throws ServiceException, DAOException { List<UserWithRestLinks> expectedUsers = usersWithLinkMock; List<UserWithRestLinks> resultUsers = null; when(userDAOMock.getAllUsers()).thenReturn(expectedUsers); resultUsers = userService.getAllUsers(); verify(userDAOMock, times(1)).getAllUsers(); assertEquals(expectedUsers, resultUsers); }
@Test public void createUserTest() throws ServiceException, DAOException { Long expectedRoleId = anyLong(); Long resultRoleId = null; when(userDAOMock.create(userMock)).thenReturn(anyLong()); resultRoleId = userService.createUser(userMock); verify(userDAOMock, times(1)).create(userMock); assertEquals(expectedRoleId, resultRoleId); }