Search in sources :

Example 1 with UserInfoDTO

use of com.ncedu.fooddelivery.api.v1.dto.user.UserInfoDTO in project 2021-msk-food-delivery by netcracker-edu.

the class UserServiceTest method unlockUserSuccess.

@Test
public void unlockUserSuccess() {
    User penny = UserUtils.clientPennyTeller(1L);
    Timestamp current = new Timestamp(System.currentTimeMillis());
    penny.setLockDate(current);
    UserInfoDTO resultDTO = userService.unlockUser(penny);
    assertEquals(null, resultDTO.getLockDate());
    verify(userRepoMock, times(1)).save(any(User.class));
}
Also used : User(com.ncedu.fooddelivery.api.v1.entities.User) UserInfoDTO(com.ncedu.fooddelivery.api.v1.dto.user.UserInfoDTO) Timestamp(java.sql.Timestamp) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with UserInfoDTO

use of com.ncedu.fooddelivery.api.v1.dto.user.UserInfoDTO in project 2021-msk-food-delivery by netcracker-edu.

the class UserServiceTest method getUserDTOByIdSuccess.

@Test
public void getUserDTOByIdSuccess() {
    Long userId = 1L;
    User sheldonCooper = UserUtils.adminSheldonCooper(userId);
    when(userRepoMock.findById(userId)).thenReturn(Optional.of(sheldonCooper));
    UserInfoDTO resultDTO = userService.getUserDTOById(userId);
    UserInfoDTO perfectDTO = UserUtils.createUserDTO(sheldonCooper);
    assertEquals(perfectDTO, resultDTO);
    verify(userRepoMock, times(1)).findById(userId);
}
Also used : User(com.ncedu.fooddelivery.api.v1.entities.User) UserInfoDTO(com.ncedu.fooddelivery.api.v1.dto.user.UserInfoDTO) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with UserInfoDTO

use of com.ncedu.fooddelivery.api.v1.dto.user.UserInfoDTO in project 2021-msk-food-delivery by netcracker-edu.

the class ProfileControllerTest method getClientProfile.

@Test
public void getClientProfile() {
    ClientInfoDTO clientInfoDTO = new ClientInfoDTO(1L, "CLIENT", "client@mail.ru");
    when(clientServiceMock.getClientDTOById(1L)).thenReturn(clientInfoDTO);
    User user = new User();
    user.setId(1L);
    user.setRole(Role.CLIENT);
    UserInfoDTO resultClientDTO = profileController.getProfile(user);
    assertEquals(clientInfoDTO, resultClientDTO);
}
Also used : User(com.ncedu.fooddelivery.api.v1.entities.User) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with UserInfoDTO

use of com.ncedu.fooddelivery.api.v1.dto.user.UserInfoDTO in project 2021-msk-food-delivery by netcracker-edu.

the class ProfileControllerTest method getModeratorProfile.

@Test
public void getModeratorProfile() {
    ModeratorInfoDTO moderatorInfoDTO = new ModeratorInfoDTO(1L, "MODERATOR", "moderator@mail.ru");
    when(moderatorServiceMock.getModeratorDTOById(1L)).thenReturn(moderatorInfoDTO);
    User user = new User();
    user.setId(1L);
    user.setRole(Role.MODERATOR);
    UserInfoDTO resultModeratorDTO = profileController.getProfile(user);
    assertEquals(moderatorInfoDTO, resultModeratorDTO);
}
Also used : User(com.ncedu.fooddelivery.api.v1.entities.User) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with UserInfoDTO

use of com.ncedu.fooddelivery.api.v1.dto.user.UserInfoDTO in project 2021-msk-food-delivery by netcracker-edu.

the class ProfileControllerTest method getAdminProfile.

@Test
public void getAdminProfile() {
    UserInfoDTO userInfoDTO = new UserInfoDTO(1L, "ADMIN", "admin@mail.ru");
    when(userServiceMock.getUserDTOById(1L)).thenReturn(userInfoDTO);
    User user = new User();
    user.setId(1L);
    user.setRole(Role.ADMIN);
    UserInfoDTO resultUserDTO = profileController.getProfile(user);
    assertEquals(userInfoDTO, resultUserDTO);
}
Also used : User(com.ncedu.fooddelivery.api.v1.entities.User) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

User (com.ncedu.fooddelivery.api.v1.entities.User)12 Test (org.junit.jupiter.api.Test)11 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)11 UserInfoDTO (com.ncedu.fooddelivery.api.v1.dto.user.UserInfoDTO)9 Timestamp (java.sql.Timestamp)3 ArrayList (java.util.ArrayList)3 Role (com.ncedu.fooddelivery.api.v1.entities.Role)2 PageImpl (org.springframework.data.domain.PageImpl)2 Pageable (org.springframework.data.domain.Pageable)2 EmailChangeDTO (com.ncedu.fooddelivery.api.v1.dto.user.EmailChangeDTO)1 PasswordChangeDTO (com.ncedu.fooddelivery.api.v1.dto.user.PasswordChangeDTO)1 File (com.ncedu.fooddelivery.api.v1.entities.File)1 AlreadyExistsException (com.ncedu.fooddelivery.api.v1.errors.badrequest.AlreadyExistsException)1 PasswordsMismatchException (com.ncedu.fooddelivery.api.v1.errors.badrequest.PasswordsMismatchException)1 NotFoundEx (com.ncedu.fooddelivery.api.v1.errors.notfound.NotFoundEx)1 UserRepo (com.ncedu.fooddelivery.api.v1.repos.UserRepo)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Slf4j (lombok.extern.slf4j.Slf4j)1