public SearchResults<UserGroupDto> searchMembers(GroupMembershipSearchRequest groupMembershipSearchRequest, int pageIndex, int pageSize) {
    try (DbSession dbSession = dbClient.openSession(false)) {
      UserGroupQuery query = new UserGroupQuery(null, groupMembershipSearchRequest.groupUuid(), groupMembershipSearchRequest.userUuid());
      int total = userGroupDao.countByQuery(dbSession, query);
      if (pageSize == 0) {
        return new SearchResults<>(List.of(), total);
      }
      List<UserGroupDto> userGroupDtos = userGroupDao.selectByQuery(dbSession, query, pageIndex, pageSize);
      return new SearchResults<>(userGroupDtos, total);
    }
  }
@Test
  public void searchMembers_shouldReturnMembers() {
    GroupDto groupDto = mockGroupDto();
    UserDto userDto = mockUserDto();

    UserGroupDto result = mock(UserGroupDto.class);
    when(userGroupDao.selectByQuery(any(), any(), anyInt(), anyInt())).thenReturn(List.of(result));
    when(userGroupDao.countByQuery(any(), any())).thenReturn(10);

    GroupMembershipSearchRequest searchRequest = new GroupMembershipSearchRequest(groupDto.getUuid(), userDto.getUuid());
    SearchResults<UserGroupDto> userGroupDtoSearchResults = groupMembershipService.searchMembers(searchRequest, 1, 10);

    assertThat(userGroupDtoSearchResults.searchResults()).containsOnly(result);
    assertThat(userGroupDtoSearchResults.total()).isEqualTo(10);

    verify(userGroupDao).selectByQuery(dbSession, new UserGroupQuery(null, groupDto.getUuid(), userDto.getUuid()), 1, 10);
    verify(userGroupDao).countByQuery(dbSession, new UserGroupQuery(null, groupDto.getUuid(), userDto.getUuid()));
  }