Search in sources :

Example 21 with User

use of com.laurentiuspilca.ssc6.entities.User in project 2021-msk-food-delivery by netcracker-edu.

the class UserServiceImpl method changeFullName.

@Override
public boolean changeFullName(Long id, String newFullName) {
    User user = getUserById(id);
    if (newFullName != null) {
        user.setFullName(newFullName);
        userRepo.save(user);
        return true;
    }
    return false;
}
Also used : User(com.ncedu.fooddelivery.api.v1.entities.User)

Example 22 with User

use of com.laurentiuspilca.ssc6.entities.User in project 2021-msk-food-delivery by netcracker-edu.

the class ProfileControllerTest method changeAdminName.

@Test
public void changeAdminName() {
    UserChangeInfoDTO userChangeInfoDTO = new UserChangeInfoDTO();
    userChangeInfoDTO.setFullName("Howard Joel Wolowitz");
    Long authedUserId = 1L;
    when(userServiceMock.changeFullName(authedUserId, userChangeInfoDTO.getFullName())).thenReturn(true);
    User user = new User();
    user.setId(authedUserId);
    user.setRole(Role.ADMIN);
    ResponseEntity<?> resultResponse = profileController.changeUserInfo(userChangeInfoDTO, user);
    ResponseEntity<?> perfectResponse = createModifyResponse(true);
    assertEquals(perfectResponse, resultResponse);
}
Also used : User(com.ncedu.fooddelivery.api.v1.entities.User) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 23 with User

use of com.laurentiuspilca.ssc6.entities.User in project 2021-msk-food-delivery by netcracker-edu.

the class ProfileControllerTest method changeEmailWithBadValues.

@Test
public void changeEmailWithBadValues() {
    EmailChangeDTO emailChangeDTO = new EmailChangeDTO();
    emailChangeDTO.setEmail("wolowitz.bigbang");
    emailChangeDTO.setPassword("small");
    User user = new User();
    user.setId(1L);
    when(userServiceMock.changeEmail(user, emailChangeDTO)).thenReturn(false);
    ResponseEntity<?> resultResponse = profileController.changeUserEmail(emailChangeDTO, user);
    ResponseEntity<?> perfectResponse = createModifyResponse(false);
    assertEquals(perfectResponse, resultResponse);
}
Also used : User(com.ncedu.fooddelivery.api.v1.entities.User) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 24 with User

use of com.laurentiuspilca.ssc6.entities.User 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 25 with User

use of com.laurentiuspilca.ssc6.entities.User 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)

Aggregations

User (com.ncedu.fooddelivery.api.v1.entities.User)58 Test (org.junit.jupiter.api.Test)49 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)49 File (com.ncedu.fooddelivery.api.v1.entities.File)18 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)18 MultipartFile (org.springframework.web.multipart.MultipartFile)18 Path (java.nio.file.Path)16 FileLinkDTO (com.ncedu.fooddelivery.api.v1.dto.file.FileLinkDTO)12 UserInfoDTO (com.ncedu.fooddelivery.api.v1.dto.user.UserInfoDTO)9 BufferedImage (java.awt.image.BufferedImage)8 CommitAfter (org.apache.tapestry5.jpa.annotations.CommitAfter)7 AlreadyExistsException (com.ncedu.fooddelivery.api.v1.errors.badrequest.AlreadyExistsException)6 PasswordsMismatchException (com.ncedu.fooddelivery.api.v1.errors.badrequest.PasswordsMismatchException)6 PersistenceContext (javax.persistence.PersistenceContext)6 User (org.example.app0.entities.User)6 User (org.example.app1.entities.User)6 User (org.example.app6.entities.User)5 EmailChangeDTO (com.ncedu.fooddelivery.api.v1.dto.user.EmailChangeDTO)4 PasswordChangeDTO (com.ncedu.fooddelivery.api.v1.dto.user.PasswordChangeDTO)4 IOException (java.io.IOException)4