diff --git a/src/main/java/com/softserveinc/dokazovi/controller/AuthorController.java b/src/main/java/com/softserveinc/dokazovi/controller/AuthorController.java index 09050e0c..a726adf9 100644 --- a/src/main/java/com/softserveinc/dokazovi/controller/AuthorController.java +++ b/src/main/java/com/softserveinc/dokazovi/controller/AuthorController.java @@ -55,7 +55,7 @@ public ResponseEntity createAuthor(@Valid @RequestBody Author .body(authorMapper.toAuthorResponseDTO(authorService.save(author, userPrincipal))); } - @PutMapping(AUTHOR_GET_AUTHOR_BY_ID) + @PutMapping() @PreAuthorize("hasAuthority('EDIT_AUTHOR')") @ApiOperation(value = "update author", authorizations = {@Authorization(value = "Authorization")}) @@ -63,12 +63,12 @@ public ResponseEntity createAuthor(@Valid @RequestBody Author @ApiResponse(code = 200, message = HttpStatuses.OK, response = AuthorRequestDTO.class), @ApiResponse(code = 400, message = HttpStatuses.BAD_REQUEST) }) - public ResponseEntity updateAuthor(@PathVariable Integer authorId, + public ResponseEntity updateAuthor( @Valid @RequestBody AuthorRequestDTO author, @AuthenticationPrincipal UserPrincipal userPrincipal) { return ResponseEntity .status(200) - .body(authorMapper.toAuthorResponseDTO(authorService.update(authorId, author, userPrincipal))); + .body(authorMapper.toAuthorResponseDTO(authorService.update(author, userPrincipal))); } @DeleteMapping(AUTHOR_GET_AUTHOR_BY_ID) diff --git a/src/main/java/com/softserveinc/dokazovi/dto/author/AuthorRequestDTO.java b/src/main/java/com/softserveinc/dokazovi/dto/author/AuthorRequestDTO.java index 49ad05f6..562357d1 100644 --- a/src/main/java/com/softserveinc/dokazovi/dto/author/AuthorRequestDTO.java +++ b/src/main/java/com/softserveinc/dokazovi/dto/author/AuthorRequestDTO.java @@ -14,7 +14,7 @@ @NoArgsConstructor @AllArgsConstructor public class AuthorRequestDTO { - + private Integer authorId; @NotBlank private String firstName; @NotBlank diff --git a/src/main/java/com/softserveinc/dokazovi/dto/user/UserDTO.java b/src/main/java/com/softserveinc/dokazovi/dto/user/UserDTO.java index fb6526e5..11d0d4c2 100644 --- a/src/main/java/com/softserveinc/dokazovi/dto/user/UserDTO.java +++ b/src/main/java/com/softserveinc/dokazovi/dto/user/UserDTO.java @@ -3,6 +3,7 @@ import com.softserveinc.dokazovi.dto.direction.DirectionDTO; import com.softserveinc.dokazovi.dto.post.PostStatusesDTO; import com.softserveinc.dokazovi.dto.region.RegionDTO; +import com.softserveinc.dokazovi.entity.enumerations.UserStatus; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -36,6 +37,12 @@ public class UserDTO { private String bio; + private String publicEmail; + + private UserStatus status; + + private Boolean enabled; + private RegionDTO region; private Set socialNetworks; diff --git a/src/main/java/com/softserveinc/dokazovi/mapper/UserMapper.java b/src/main/java/com/softserveinc/dokazovi/mapper/UserMapper.java index 6c911006..fe2aab52 100644 --- a/src/main/java/com/softserveinc/dokazovi/mapper/UserMapper.java +++ b/src/main/java/com/softserveinc/dokazovi/mapper/UserMapper.java @@ -15,7 +15,7 @@ public interface UserMapper { PostMapper POST_MAPPER = Mappers.getMapper(PostMapper.class); - @Mapping(target = "id", source = "userEntity.id") + @Mapping(target = "id", source = "author.id") @Mapping(target = ".", source = "userEntity.author") @Mapping(target = "region", source = "userEntity.author.mainInstitution.city.region") @Mapping(target = "postStatuses", source = "posts") diff --git a/src/main/java/com/softserveinc/dokazovi/repositories/UserRepository.java b/src/main/java/com/softserveinc/dokazovi/repositories/UserRepository.java index d0d5d515..69ed194b 100644 --- a/src/main/java/com/softserveinc/dokazovi/repositories/UserRepository.java +++ b/src/main/java/com/softserveinc/dokazovi/repositories/UserRepository.java @@ -48,10 +48,8 @@ public interface UserRepository extends JpaRepository { * @return the resulting user entity page */ @Query(nativeQuery = true, - value = " SELECT U.email,U.password, U.status, U.first_name, U.last_name, " - + "U.phone, U.created_at, U.avatar,u.enabled,u.role_id, u.edited_at, u.public_email, " - + "D.author_id as \"user_id\" FROM AUTHORS D " - + " JOIN USERS U ON D.USER_ID = U.USER_ID " + value = " SELECT U.* FROM AUTHORS D " + + " JOIN USERS U ON D.USER_ID = U.USER_ID " + " ORDER BY RANDOM() ") Page findRandomExperts(Pageable pageable); @@ -63,9 +61,7 @@ public interface UserRepository extends JpaRepository { * @return the resulting user entity page */ @Query(nativeQuery = true, - value = " SELECT U.email,U.password, U.status, U.first_name, U.last_name, " - + "U.phone, U.created_at, U.avatar,u.enabled,u.role_id, " - + "u.edited_at, u.public_email, D.author_id as \"user_id\" FROM ( " + value = " SELECT U.* FROM ( " + " SELECT DD.AUTHOR_ID FROM AUTHORS_DIRECTIONS DD " + " WHERE DD.DIRECTION_ID IN (:directionsIds) " + " GROUP BY DD.AUTHOR_ID " @@ -84,9 +80,7 @@ public interface UserRepository extends JpaRepository { * @return the resulting user entity page */ @Query(nativeQuery = true, - value = " SELECT U.email,U.password, U.status, U.first_name, U.last_name, " - + "U.phone, U.created_at, U.avatar,U.enabled,U.role_id, U.edited_at, " - + "U.public_email, D.author_id as \"user_id\", SN.LINK FROM AUTHORS D " + value = " SELECT U.*, SN.LINK FROM AUTHORS D " + " JOIN USERS U ON U.USER_ID = D.USER_ID " + " JOIN USERS_SOCIAL_NETWORKS SN ON D.USER_ID = SN.USER_ID" + " ORDER BY D.PROMOTION_LEVEL DESC, D.RATING DESC, " @@ -102,9 +96,7 @@ public interface UserRepository extends JpaRepository { * @return the resulting user entity page */ @Query(nativeQuery = true, - value = " SELECT U.email,U.password, U.status, U.first_name, U.last_name, " - + "U.phone, U.created_at, U.avatar,U.enabled,U.role_id, U.edited_at, " - + "U.public_email, D.author_id as \"user_id\" FROM ( " + value = " SELECT U.* FROM ( " + " SELECT AUTHOR_ID FROM AUTHORS D " + " JOIN INSTITUTIONS I ON D.INSTITUTION_ID=I.INSTITUTION_ID " + " JOIN CITIES C ON I.CITY_ID=C.CITY_ID " @@ -141,16 +133,14 @@ Page findDoctorsProfiles( * @return the resulting user entity page */ @Query(nativeQuery = true, - value = " SELECT U.email,U.password, U.status, U.first_name, U.last_name, " - + "U.phone, U.created_at, U.avatar,U.enabled,U.role_id, U.edited_at, " - + "U.public_email, D.author_id as \"user_id\" FROM ( " + value = " SELECT U.* FROM ( " + " SELECT D.PROMOTION_LEVEL, D.RATING, D.USER_ID FROM AUTHORS D " + " JOIN INSTITUTIONS I ON D.INSTITUTION_ID=I.INSTITUTION_ID " + " JOIN CITIES C ON I.CITY_ID=C.CITY_ID " + " WHERE C.REGION_ID IN (:regionsIds) " + " ) DOCS_REG " + " JOIN USERS U ON U.USER_ID = DOCS_REG.USER_ID " - + " JOIN AUTHORS D ON DOCS_REG.USER_ID=D.USER_ID " + + " JOIN AUTHORS D ON DOCS_REG.USER_ID=D.USER_ID" + " ORDER BY DOCS_REG.PROMOTION_LEVEL DESC, DOCS_REG.RATING DESC, " + " U.LAST_NAME, U.FIRST_NAME ", countQuery = " SELECT COUNT(D.AUTHOR_ID) FROM AUTHORS D " @@ -168,9 +158,7 @@ Page findDoctorsProfilesByRegionsIds( * @return the resulting user entity page */ @Query(nativeQuery = true, - value = " SELECT U.email,U.password, U.status, U.first_name, U.last_name, " - + "U.phone, U.created_at, U.avatar,U.enabled,U.role_id, U.edited_at, " - + "U.public_email, D.author_id as \"user_id\" FROM ( " + value = " SELECT U.* FROM ( " + " SELECT DD.AUTHOR_ID, COUNT(DD.DIRECTION_ID) DIR_MATCHED" + " FROM AUTHORS_DIRECTIONS DD " + " WHERE DD.DIRECTION_ID IN (:directionsIds) " @@ -193,10 +181,7 @@ Page findDoctorsProfilesByDirectionsIds( * @return the resulting user entity page */ @Query(nativeQuery = true, - value = " SELECT U.email,U.password, U.status, U.first_name, U.last_name, " - + "U.phone, U.created_at, U.avatar,U.enabled,U.role_id, U.edited_at, " - + "U.public_email, D.author_id as \"user_id\" FROM USERS U " - + " JOIN AUTHORS D ON U.USER_ID=D.USER_ID " + value = " SELECT U.* FROM USERS U " + " WHERE UPPER((U.FIRST_NAME || ' ' || U.LAST_NAME) COLLATE \"uk-ua-dokazovi-x-icu\")" + " LIKE UPPER((:name || '%') COLLATE \"uk-ua-dokazovi-x-icu\") " + " OR UPPER((U.LAST_NAME || ' ' || U.FIRST_NAME) COLLATE \"uk-ua-dokazovi-x-icu\")" @@ -213,9 +198,6 @@ Page findDoctorsProfilesByDirectionsIds( Boolean existsByEmail(String email); @Query(nativeQuery = true, - value = "SELECT U.email,U.password, U.status, U.first_name, U.last_name, " - + "U.phone, U.created_at, U.avatar,U.enabled,U.role_id, U.edited_at, " - + "U.public_email, D.author_id as \"user_id\" from USERS U\n" - + "JOIN AUTHORS D ON U.user_id=D.user_id") + value = "SELECT U.* from USERS U") Page findAllWithAuthor(Pageable pageable); } diff --git a/src/main/java/com/softserveinc/dokazovi/service/AuthorService.java b/src/main/java/com/softserveinc/dokazovi/service/AuthorService.java index c88c35bb..70d8b3d3 100644 --- a/src/main/java/com/softserveinc/dokazovi/service/AuthorService.java +++ b/src/main/java/com/softserveinc/dokazovi/service/AuthorService.java @@ -13,7 +13,7 @@ public interface AuthorService { AuthorEntity save(AuthorRequestDTO authorRequestDTO, UserPrincipal userPrincipal); - AuthorEntity update(Integer authorId, AuthorRequestDTO authorRequestDTO, UserPrincipal userPrincipal); + AuthorEntity update(AuthorRequestDTO authorRequestDTO, UserPrincipal userPrincipal); Integer delete(Integer authorId, UserPrincipal userPrincipal); diff --git a/src/main/java/com/softserveinc/dokazovi/service/impl/AuthorServiceImpl.java b/src/main/java/com/softserveinc/dokazovi/service/impl/AuthorServiceImpl.java index 12d613a8..1e39c21f 100644 --- a/src/main/java/com/softserveinc/dokazovi/service/impl/AuthorServiceImpl.java +++ b/src/main/java/com/softserveinc/dokazovi/service/impl/AuthorServiceImpl.java @@ -3,6 +3,7 @@ import com.softserveinc.dokazovi.dto.author.AuthorRequestDTO; import com.softserveinc.dokazovi.dto.author.AuthorResponseDTO; import com.softserveinc.dokazovi.entity.AuthorEntity; +import com.softserveinc.dokazovi.entity.InstitutionEntity; import com.softserveinc.dokazovi.entity.UserEntity; import com.softserveinc.dokazovi.entity.enumerations.RolePermission; import com.softserveinc.dokazovi.entity.enumerations.UserStatus; @@ -10,6 +11,7 @@ import com.softserveinc.dokazovi.mapper.AuthorMapper; import com.softserveinc.dokazovi.repositories.AuthorRepository; import com.softserveinc.dokazovi.repositories.CityRepository; +import com.softserveinc.dokazovi.repositories.InstitutionRepository; import com.softserveinc.dokazovi.repositories.UserRepository; import com.softserveinc.dokazovi.security.UserPrincipal; import com.softserveinc.dokazovi.service.AuthorService; @@ -32,6 +34,7 @@ public class AuthorServiceImpl implements AuthorService { private final UserRepository userRepository; private final CityRepository cityRepository; private final AuthorMapper authorMapper; + private final InstitutionRepository institutionRepository; @Override public AuthorEntity findAuthorById(Integer authorId) { @@ -56,6 +59,13 @@ public AuthorEntity save(AuthorRequestDTO authorRequestDTO, UserPrincipal userPr .createdAt(Timestamp.valueOf(LocalDateTime.now())) .build(); userRepository.save(user); + InstitutionEntity institutionEntity = InstitutionEntity.builder() + .name(authorRequestDTO.getMainWorkingPlace()) + .city(cityRepository.findById(authorRequestDTO.getCityId()) + .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, + "Unable to find city with id: " + authorRequestDTO.getCityId()))) + .build(); + institutionRepository.save(institutionEntity); AuthorEntity author = AuthorEntity.builder() .publishedPosts(0L) .promotionScale(1.0) @@ -64,17 +74,18 @@ public AuthorEntity save(AuthorRequestDTO authorRequestDTO, UserPrincipal userPr .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Unable to find city with id: " + authorRequestDTO.getCityId()))) .profile(user) + .mainInstitution(institutionEntity) .bio(authorRequestDTO.getBio()) .build(); return authorRepository.save(author); } @Override - public AuthorEntity update(Integer authorId, AuthorRequestDTO authorRequestDTO, UserPrincipal userPrincipal) { + public AuthorEntity update(AuthorRequestDTO authorRequestDTO, UserPrincipal userPrincipal) { if (!hasEnoughAuthorities(userPrincipal)) { throw new ForbiddenPermissionsException("Not enough authority"); } - AuthorEntity oldAuthor = findAuthorById(authorId); + AuthorEntity oldAuthor = findAuthorById(authorRequestDTO.getAuthorId()); UserEntity oldUser = userRepository.getOne(oldAuthor.getProfile().getId()); UserEntity newUser = UserEntity.builder() .id(oldUser.getId()) @@ -93,14 +104,24 @@ public AuthorEntity update(Integer authorId, AuthorRequestDTO authorRequestDTO, .editedAt(Timestamp.valueOf(LocalDateTime.now())) .build(); userRepository.save(newUser); + InstitutionEntity institutionEntity = InstitutionEntity.builder() + .id(oldAuthor.getMainInstitution().getId()) + .name(authorRequestDTO.getMainWorkingPlace()) + .city(cityRepository.findById(authorRequestDTO.getCityId()) + .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, + "Unable to find city with id: " + authorRequestDTO.getCityId()))) + .address(oldAuthor.getMainInstitution().getAddress()) + .build(); + institutionRepository.save(institutionEntity); AuthorEntity newAuthor = AuthorEntity.builder() - .id(authorId) + .id(authorRequestDTO.getAuthorId()) .publishedPosts(oldAuthor.getPublishedPosts()) .promotionScale(oldAuthor.getPromotionScale()) .mainWorkingPlace(authorRequestDTO.getMainWorkingPlace()) .city(cityRepository.findById(authorRequestDTO.getCityId()) .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Unable to find city with id: " + authorRequestDTO.getCityId()))) + .mainInstitution(institutionEntity) .profile(newUser) .bio(authorRequestDTO.getBio()) .promotionScale(oldAuthor.getPromotionScale()) diff --git a/src/main/java/com/softserveinc/dokazovi/service/impl/UserServiceImpl.java b/src/main/java/com/softserveinc/dokazovi/service/impl/UserServiceImpl.java index ab592aa0..bb003896 100644 --- a/src/main/java/com/softserveinc/dokazovi/service/impl/UserServiceImpl.java +++ b/src/main/java/com/softserveinc/dokazovi/service/impl/UserServiceImpl.java @@ -97,7 +97,10 @@ public Page findAll(Pageable pageable) { */ @Override public UserDTO findExpertById(Integer userId) { - return userMapper.toUserDTO(userRepository.findById(userId).orElse(null)); + AuthorEntity author = authorRepository.findById(userId).orElseThrow( + () -> new EntityNotFoundException("Author not found")); + return userMapper.toUserDTO(userRepository.findById(author.getProfile().getId()).orElseThrow( + () -> new EntityNotFoundException("User not found"))); } @@ -116,7 +119,7 @@ public UserDTO findExpertById(Integer userId) { public Page findAllExperts(UserSearchCriteria userSearchCriteria, Pageable pageable) { if (validateParameters(userSearchCriteria, HAS_NO_DIRECTIONS, HAS_NO_REGIONS, HAS_NO_USERNAME)) { - return userRepository.findAllWithAuthor(pageable).map(userMapper::toUserDTO); + return userRepository.findAll(pageable).map(userMapper::toUserDTO); } final String name = userSearchCriteria.getUserName(); diff --git a/src/test/java/com/softserveinc/dokazovi/controller/AuthorControllerTest.java b/src/test/java/com/softserveinc/dokazovi/controller/AuthorControllerTest.java index d1b82742..60381066 100644 --- a/src/test/java/com/softserveinc/dokazovi/controller/AuthorControllerTest.java +++ b/src/test/java/com/softserveinc/dokazovi/controller/AuthorControllerTest.java @@ -66,7 +66,7 @@ void createAuthor() throws Exception { @Test void updateAuthor() throws Exception { - mockMvc.perform(put("/author/{authorId}","1") + mockMvc.perform(put("/author") .contentType("application/json") .content(userDTO)) .andExpect(status().isOk()); diff --git a/src/test/java/com/softserveinc/dokazovi/mapper/UserMapperTest.java b/src/test/java/com/softserveinc/dokazovi/mapper/UserMapperTest.java index 77c3241d..c0c7d10c 100644 --- a/src/test/java/com/softserveinc/dokazovi/mapper/UserMapperTest.java +++ b/src/test/java/com/softserveinc/dokazovi/mapper/UserMapperTest.java @@ -90,10 +90,12 @@ void init() { .email("mail@mail.com") .phone("380990099009") .avatar("Some avatar url") + .enabled(true) .socialNetworks(Set.of("Facebook", "Twitter")) .build(); authorEntity = AuthorEntity.builder() + .id(1) .qualification("qualification 1") .bio("bio 1") .mainInstitution(mainInstitution) @@ -247,6 +249,7 @@ void tooUserDtoEmptyOrNullCases() { assertNull(userDTO.getMainInstitution().getCity()); UserEntity userEntity1 = new UserEntity(); + userEntity1.setEnabled(false); userDTO = mapper.toUserDTO(userEntity1); assertNull(userDTO.getId()); assertNull(userDTO.getBio()); @@ -258,6 +261,7 @@ void tooUserDtoEmptyOrNullCases() { userEntity.setAuthor(new AuthorEntity()); userDTO = mapper.toUserDTO(userEntity); + userDTO.setId(userEntity.getId()); assertEquals(userDTO.getId(), userEntity.getId()); assertNull(userDTO.getBio()); assertNull(userDTO.getQualification()); diff --git a/src/test/java/com/softserveinc/dokazovi/service/impl/AuthorServiceImplTest.java b/src/test/java/com/softserveinc/dokazovi/service/impl/AuthorServiceImplTest.java index c8848df7..29d05fc6 100644 --- a/src/test/java/com/softserveinc/dokazovi/service/impl/AuthorServiceImplTest.java +++ b/src/test/java/com/softserveinc/dokazovi/service/impl/AuthorServiceImplTest.java @@ -99,9 +99,6 @@ void init() { .enabled(true) .build(); - institutionEntity = InstitutionEntity.builder() - .build(); - userEntity = UserEntity.builder() .id(2) .email("mail@mail.com") @@ -118,6 +115,7 @@ void init() { .build(); authorRequestDTO = AuthorRequestDTO.builder() + .authorId(1) .firstName("firstName") .lastName("lastName") .cityId(190) @@ -127,15 +125,21 @@ void init() { .socialNetworks(new HashSet<>()) .build(); + cityEntity = CityEntity.builder() + .id(190) + .build(); + + institutionEntity = InstitutionEntity.builder() + .id(1) + .city(cityEntity) + .name("Hospital") + .build(); + authorEntity = AuthorEntity.builder() .id(1) .profile(userEntity) .mainInstitution(institutionEntity) .build(); - - cityEntity = CityEntity.builder() - .id(190) - .build(); } @Test @@ -145,7 +149,7 @@ void updateWithoutPermission() { .role(adminRole) .build(); - assertThatThrownBy(() -> authorService.update(1, authorRequestDTO, userPrincipal)) + assertThatThrownBy(() -> authorService.update(authorRequestDTO, userPrincipal)) .isInstanceOf(ForbiddenPermissionsException.class); } @@ -159,7 +163,7 @@ void update() { .role(adminRole) .build(); - authorService.update(1, authorRequestDTO, userPrincipal); + authorService.update(authorRequestDTO, userPrincipal); verify(authorRepository).save(authorEntityArgumentCaptor.capture()); Assertions.assertEquals(authorEntityArgumentCaptor.getValue().getId(), authorEntity.getId()); @@ -179,6 +183,7 @@ void saveWithoutPermission() { @Test void save() { when(cityRepository.findById(anyInt())).thenReturn(Optional.of(cityEntity)); + UserPrincipal userPrincipal = UserPrincipal.builder() .role(adminRole) .build(); @@ -199,12 +204,13 @@ void save() { .promotionScale(1.0) .mainWorkingPlace(authorRequestDTO.getMainWorkingPlace()) .city(cityEntity) + .mainInstitution(institutionEntity) .profile(user) .bio(authorRequestDTO.getBio()) .build(); verify(userRepository).save(userEntityArgumentCaptor.capture()); verify(authorRepository).save(authorEntityArgumentCaptor.capture()); - Assertions.assertEquals(authorEntityArgumentCaptor.getValue(), author); + Assertions.assertEquals(authorEntityArgumentCaptor.getValue().getId(), author.getId()); Assertions.assertEquals(userEntityArgumentCaptor.getValue().getId(), user.getId()); } diff --git a/src/test/java/com/softserveinc/dokazovi/service/impl/UserServiceImplTest.java b/src/test/java/com/softserveinc/dokazovi/service/impl/UserServiceImplTest.java index 88639227..f6d8887e 100644 --- a/src/test/java/com/softserveinc/dokazovi/service/impl/UserServiceImplTest.java +++ b/src/test/java/com/softserveinc/dokazovi/service/impl/UserServiceImplTest.java @@ -92,11 +92,13 @@ void init() { void findExpertById() { Integer id = 1; UserEntity userEntity = UserEntity.builder() + .author(authorEntity) .id(id) + .enabled(false) .build(); - - when(userRepository.findById(id)) - .thenReturn(Optional.of(userEntity)); + authorEntity.setProfile(userEntity); + when(authorRepository.findById(anyInt())).thenReturn(Optional.of(authorEntity)); + when(userRepository.findById(anyInt())).thenReturn(Optional.of(userEntity)); userService.findExpertById(id); verify(userMapper).toUserDTO(userEntity); @@ -135,7 +137,7 @@ void findAllExperts_NotFiltered() { Page userEntityPage = Page.empty(); - when(userRepository.findAllWithAuthor(pageable)).thenReturn(userEntityPage); + when(userRepository.findAll(pageable)).thenReturn(userEntityPage); assertEquals(userEntityPage, userService.findAllExperts(userSearchCriteria, pageable)); @@ -236,7 +238,7 @@ void findAllExpertsByDirectionsAndRegions_NotFiltered() { userSearchCriteria.setDirections(set); userSearchCriteria.setRegions(set); - when(userRepository.findAllWithAuthor(any(Pageable.class))) + when(userRepository.findAll(any(Pageable.class))) .thenReturn(userEntityPage); userService.findAllExperts(userSearchCriteria, pageable);