use of com.ncedu.fooddelivery.api.v1.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);
}
use of com.ncedu.fooddelivery.api.v1.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);
}
use of com.ncedu.fooddelivery.api.v1.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);
}
use of com.ncedu.fooddelivery.api.v1.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);
}
use of com.ncedu.fooddelivery.api.v1.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class ProfileControllerTest method changeAdminNameWithNullName.
@Test
public void changeAdminNameWithNullName() {
// in DTO fullName not presented
UserChangeInfoDTO userChangeInfoDTO = new UserChangeInfoDTO();
userChangeInfoDTO.setPhoneNumber("+7 (800) 555 35-35");
Long authedUserId = 1L;
when(userServiceMock.changeFullName(authedUserId, userChangeInfoDTO.getFullName())).thenReturn(false);
User user = new User();
user.setId(authedUserId);
user.setRole(Role.ADMIN);
ResponseEntity<?> resultResponse = profileController.changeUserInfo(userChangeInfoDTO, user);
ResponseEntity<?> perfectResponse = createModifyResponse(false);
assertEquals(perfectResponse, resultResponse);
}
Aggregations