Search in sources :

Example 1 with SearchableUser

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;
}
Also used : SearchableUser(io.gravitee.rest.api.idp.api.identity.SearchableUser) IdentityLookup(io.gravitee.rest.api.idp.api.identity.IdentityLookup) SearchableUser(io.gravitee.rest.api.idp.api.identity.SearchableUser) User(io.gravitee.rest.api.idp.api.identity.User)

Example 2 with SearchableUser

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;
}
Also used : SearchableUser(io.gravitee.rest.api.idp.api.identity.SearchableUser)

Example 3 with SearchableUser

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());
}
Also used : SearchableUser(io.gravitee.rest.api.idp.api.identity.SearchableUser) SearchableUser(io.gravitee.rest.api.idp.api.identity.SearchableUser) User(io.gravitee.rest.api.portal.rest.model.User) Test(org.junit.Test)

Aggregations

SearchableUser (io.gravitee.rest.api.idp.api.identity.SearchableUser)3 IdentityLookup (io.gravitee.rest.api.idp.api.identity.IdentityLookup)1 User (io.gravitee.rest.api.idp.api.identity.User)1 User (io.gravitee.rest.api.portal.rest.model.User)1 Test (org.junit.Test)1