Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ public List<User> findByEmail(String email, String organizationId) throws Techni

@Override
public Set<User> findByIds(final Collection<String> ids) throws TechnicalException {
if (ids == null || ids.isEmpty()) {
return Collections.emptySet();
}
final String[] lastId = new String[1];
List<String> uniqueIds = ids
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public Optional<BaseUserEntity> findBaseUserById(String id) {

@Override
public Set<BaseUserEntity> findBaseUsersByIds(List<String> userIds) {
if (userIds == null || userIds.isEmpty()) {
return Set.of();
}
try {
log.debug("Find users [userIds={}]", userIds);
return userRepository.findByIds(userIds).stream().map(UserAdapter.INSTANCE::fromUser).collect(Collectors.toSet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ private void setMembersSourceId(Set<MemberCRD> members) {

membersById.forEach((id, member) -> {
var user = usersById.get(id);
member.setSourceId(user.getSourceId());
member.setSource(user.getSource());
if (user != null) {
member.setSourceId(user.getSourceId());
member.setSource(user.getSource());
}
member.setId(null);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.NullAndEmptySource;

public class UserCrudServiceImplTest {

Expand Down Expand Up @@ -121,6 +123,13 @@ void should_throw_when_technical_exception_occurs() throws TechnicalException {
@Nested
class FindBaseUserByIds {

@ParameterizedTest
@NullAndEmptySource
void should_return_empty_set_when_user_ids_is_null_or_empty(List<String> userIds) {
var result = service.findBaseUsersByIds(userIds);
assertThat(result).isEmpty();
}

@Test
void should_find_users_and_adapt_them() throws TechnicalException {
// Given
Expand Down