use of com.management.repositories.UserRepository in project Internet-Software-Architectures by zivko11.
the class UserManagerTest method ReadUser_ReturnsUser.
@Test
public void ReadUser_ReturnsUser() {
// Arrange
Mockery mock = new Mockery();
userRepository = mock.mock(UserRepository.class);
final User user = new User();
user.setUserId(1);
user.setUserActive(true);
user.setUserName("Pero");
user.setUserSurname("Peric");
user.setUserAdmin('O');
user.setUserCity("Novi Sad");
user.setUserCreationDate(new Date());
user.setUserEmail("pero@gmail.com");
user.setUserPassword("123");
user.setUserRank(0);
user.setUserPhone(123456);
user.setUserStateid("381");
mock.checking(new Expectations() {
{
oneOf(userRepository).findOne(1);
will(returnValue(user));
}
});
UserManager manager = new UserManager(userRepository);
// Act
UserDTO dto = manager.Read(1);
// Assert
Assert.assertNotNull(dto);
Assert.assertEquals(dto.getUserCity(), user.getUserCity());
Assert.assertEquals(dto.getUserAdmin(), user.getUserAdmin());
Assert.assertEquals(dto.getUserRank(), user.getUserRank());
Assert.assertEquals(dto.getUserCity(), user.getUserCity());
Assert.assertEquals(dto.getUserEmail(), user.getUserEmail());
Assert.assertEquals(dto.getUserName(), user.getUserName());
Assert.assertEquals(dto.getUserPassword(), user.getUserPassword());
Assert.assertEquals(dto.getUserSurname(), user.getUserSurname());
Assert.assertEquals(dto.getUserAdmin(), user.getUserAdmin());
Assert.assertEquals(dto.getUserCreationDate(), user.getUserCreationDate());
Assert.assertEquals(dto.getUserPhone(), user.getUserPhone());
Assert.assertEquals(dto.getUserStateid(), user.getUserStateid());
mock.assertIsSatisfied();
}
Aggregations