use of io.gravitee.rest.api.idp.api.identity.SearchableUser in project gravitee-management-rest-api by gravitee-io.
the class CompositeIdentityManager method search.
@Override
public Collection<SearchableUser> search(String query) {
Set<SearchableUser> users = new HashSet<>();
for (IdentityLookup identityLookup : identityLookups) {
if (identityLookup.searchable()) {
Collection<User> lookupUsers = identityLookup.search(query);
if (lookupUsers != null) {
boolean allowEmailInSearchResults = identityLookup.allowEmailInSearchResults();
users.addAll(lookupUsers.stream().map(user -> new DefaultSearchableUser(user, allowEmailInSearchResults)).collect(Collectors.toSet()));
}
}
}
return users;
}
use of io.gravitee.rest.api.idp.api.identity.SearchableUser in project gravitee-management-rest-api by gravitee-io.
the class UserMapper method convert.
public User convert(SearchableUser user) {
final User userItem = new User();
userItem.setEmail(user.getEmail());
userItem.setFirstName(user.getFirstname());
userItem.setLastName(user.getLastname());
userItem.setDisplayName(user.getDisplayName());
userItem.setId(user.getId());
userItem.setReference(user.getReference());
return userItem;
}
use of io.gravitee.rest.api.idp.api.identity.SearchableUser in project gravitee-management-rest-api by gravitee-io.
the class UserMapperTest method testConvertSearchableUser.
@Test
public void testConvertSearchableUser() {
// init
SearchableUser searchableUser = Mockito.mock(SearchableUser.class);
Mockito.when(searchableUser.getDisplayName()).thenReturn(SEARCHABLE_USER_DISPLAY_NAME);
Mockito.when(searchableUser.getEmail()).thenReturn(USER_EMAIL);
Mockito.when(searchableUser.getFirstname()).thenReturn(USER_FIRSTNAME);
Mockito.when(searchableUser.getId()).thenReturn(USER_ID);
Mockito.when(searchableUser.getLastname()).thenReturn(USER_LASTNAME);
Mockito.when(searchableUser.getReference()).thenReturn(SEARCHABLE_USER_REFERENCE);
// Test
User responseUser = userMapper.convert(searchableUser);
assertNotNull(responseUser);
assertEquals(USER_ID, responseUser.getId());
assertEquals(USER_EMAIL, responseUser.getEmail());
assertEquals(USER_FIRSTNAME, responseUser.getFirstName());
assertEquals(USER_LASTNAME, responseUser.getLastName());
assertEquals(SEARCHABLE_USER_DISPLAY_NAME, responseUser.getDisplayName());
assertEquals(SEARCHABLE_USER_REFERENCE, responseUser.getReference());
}
Aggregations