use of com.management.fake.UserRepositoryFake in project Internet-Software-Architectures by zivko11.
the class UserControllerTests method AddingNewUser_ReturnsOK.
@Test
public void AddingNewUser_ReturnsOK() {
// Arrange
userRepository = new UserRepositoryFake();
UserDTO dto = new UserDTO();
dto.setUserActive(true);
dto.setUserName("Pero");
dto.setUserSurname("Peric");
dto.setUserAdmin('O');
dto.setUserCity("Novi Sad");
dto.setUserCreationDate(new Date());
dto.setUserEmail("pero@gmail.com");
dto.setUserPassword("123");
dto.setUserRank(0);
dto.setUserPhone(123456);
dto.setUserStateid("381");
UserManager manager = new UserManager(userRepository);
UserController controller = new UserController(manager);
// Act and assert
Assert.assertNotNull(controller);
Assert.assertEquals(controller.addUser(dto), new ResponseEntity<UserDTO>(dto, HttpStatus.OK));
}
use of com.management.fake.UserRepositoryFake in project Internet-Software-Architectures by zivko11.
the class UserManagerTest method AddingNewUser_ReturnsBoolean.
@Test
public void AddingNewUser_ReturnsBoolean() {
// Arrange
userRepository = new UserRepositoryFake();
UserDTO dto = new UserDTO();
dto.setUserActive(true);
dto.setUserName("Pero");
dto.setUserSurname("Peric");
dto.setUserAdmin('O');
dto.setUserCity("Novi Sad");
dto.setUserCreationDate(new Date());
dto.setUserEmail("pero@gmail.com");
dto.setUserPassword("123");
dto.setUserRank(0);
dto.setUserPhone(123456);
dto.setUserStateid("381");
UserManager manager = new UserManager(userRepository);
// Act and assert
Assert.assertNotNull(manager);
Assert.assertTrue(manager.Create(dto));
User user = userRepository.findOne(0);
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());
}
Aggregations