Search in sources :

Example 1 with UserRepositoryFake

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));
}
Also used : UserRepositoryFake(com.management.fake.UserRepositoryFake) UserManager(com.management.managers.UserManager) UserDTO(com.management.dto.UserDTO) Date(java.util.Date) Test(org.junit.Test)

Example 2 with UserRepositoryFake

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());
}
Also used : User(com.management.entities.User) UserRepositoryFake(com.management.fake.UserRepositoryFake) UserDTO(com.management.dto.UserDTO) Date(java.util.Date) Test(org.junit.Test)

Aggregations

UserDTO (com.management.dto.UserDTO)2 UserRepositoryFake (com.management.fake.UserRepositoryFake)2 Date (java.util.Date)2 Test (org.junit.Test)2 User (com.management.entities.User)1 UserManager (com.management.managers.UserManager)1