use of com.ncedu.fooddelivery.api.v1.dto.user.UserInfoDTO in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceImpl method getAllAdmins.
public List<UserInfoDTO> getAllAdmins() {
Role adminRole = Role.ADMIN;
List<User> admins = userRepo.findByRole(adminRole);
List<UserInfoDTO> adminsDTO = new ArrayList<>();
for (User admin : admins) {
adminsDTO.add(createUserDTO(admin));
}
return adminsDTO;
}
use of com.ncedu.fooddelivery.api.v1.dto.user.UserInfoDTO in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceImpl method addAvatar.
@Override
public UserInfoDTO addAvatar(User authedUser, String fileUuid) {
UUID avatarId = UUID.fromString(fileUuid);
File avatar = fileService.getFile(avatarId);
authedUser.setAvatarId(avatar.getId());
userRepo.save(authedUser);
return createUserDTO(authedUser);
}
use of com.ncedu.fooddelivery.api.v1.dto.user.UserInfoDTO in project 2021-msk-food-delivery by netcracker-edu.
the class UserServiceTest method getAllAdminsSuccess.
@Test
public void getAllAdminsSuccess() {
Long userId = 1L;
User sheldonAdmin = UserUtils.adminSheldonCooper(userId);
List<User> admins = new ArrayList<>();
admins.add(sheldonAdmin);
when(userRepoMock.findByRole(Role.ADMIN)).thenReturn(admins);
List<UserInfoDTO> resultDTO = userService.getAllAdmins();
List<UserInfoDTO> perfectDTO = new ArrayList<>();
perfectDTO.add(UserUtils.createUserDTO(sheldonAdmin));
assertEquals(perfectDTO, resultDTO);
verify(userRepoMock, times(1)).findByRole(Role.ADMIN);
}
Aggregations