Search in sources :

Example 6 with SearchRequestImpl

use of org.uberfire.ext.security.management.impl.SearchRequestImpl in project kie-wb-common by kiegroup.

the class AssigneeLiveSearchServiceTest method testSearchGroups.

@Test
public void testSearchGroups() {
    assigneeLiveSearchService.init(AssigneeType.GROUP);
    assigneeLiveSearchService.search("it", 10, callback);
    ArgumentCaptor<SearchRequestImpl> requestArgumentCaptor = ArgumentCaptor.forClass(SearchRequestImpl.class);
    verify(groupManager).search(requestArgumentCaptor.capture());
    SearchRequestImpl request = requestArgumentCaptor.getValue();
    assertEquals("it", request.getSearchPattern());
    assertEquals(10, request.getPageSize());
    ArgumentCaptor<RemoteCallback> callbackArgumentCaptor = ArgumentCaptor.forClass(RemoteCallback.class);
    verify(userSystemManager).groups(callbackArgumentCaptor.capture(), any());
    RemoteCallback<AbstractEntityManager.SearchResponse<?>> successCallback = callbackArgumentCaptor.getValue();
    successCallback.callback(prepareGroupsResponse());
    ArgumentCaptor<LiveSearchResults> resultsArgumentCaptor = ArgumentCaptor.forClass(LiveSearchResults.class);
    verify(callback).afterSearch(resultsArgumentCaptor.capture());
    LiveSearchResults result = resultsArgumentCaptor.getValue();
    assertEquals(3, result.size());
}
Also used : LiveSearchResults(org.uberfire.ext.widgets.common.client.dropdown.LiveSearchResults) SearchRequestImpl(org.uberfire.ext.security.management.impl.SearchRequestImpl) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) Test(org.junit.Test)

Example 7 with SearchRequestImpl

use of org.uberfire.ext.security.management.impl.SearchRequestImpl in project kie-wb-common by kiegroup.

the class AssigneeLiveSearchServiceTest method testSearchUsers.

@Test
public void testSearchUsers() {
    assigneeLiveSearchService.init(AssigneeType.USER);
    assigneeLiveSearchService.search("admin", 10, callback);
    ArgumentCaptor<SearchRequestImpl> requestArgumentCaptor = ArgumentCaptor.forClass(SearchRequestImpl.class);
    verify(userManager).search(requestArgumentCaptor.capture());
    SearchRequestImpl request = requestArgumentCaptor.getValue();
    assertEquals("admin", request.getSearchPattern());
    assertEquals(10, request.getPageSize());
    ArgumentCaptor<RemoteCallback> callbackArgumentCaptor = ArgumentCaptor.forClass(RemoteCallback.class);
    verify(userSystemManager).users(callbackArgumentCaptor.capture(), any());
    RemoteCallback<AbstractEntityManager.SearchResponse<?>> successCallback = callbackArgumentCaptor.getValue();
    successCallback.callback(prepareUsersResponse());
    ArgumentCaptor<LiveSearchResults> resultsArgumentCaptor = ArgumentCaptor.forClass(LiveSearchResults.class);
    verify(callback).afterSearch(resultsArgumentCaptor.capture());
    LiveSearchResults result = resultsArgumentCaptor.getValue();
    assertEquals(3, result.size());
}
Also used : LiveSearchResults(org.uberfire.ext.widgets.common.client.dropdown.LiveSearchResults) SearchRequestImpl(org.uberfire.ext.security.management.impl.SearchRequestImpl) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) Test(org.junit.Test)

Aggregations

SearchRequestImpl (org.uberfire.ext.security.management.impl.SearchRequestImpl)7 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)6 LiveSearchResults (org.uberfire.ext.widgets.common.client.dropdown.LiveSearchResults)6 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Optional (java.util.Optional)2 Set (java.util.Set)2 TreeSet (java.util.TreeSet)2 Collectors (java.util.stream.Collectors)2 Dependent (javax.enterprise.context.Dependent)2 Inject (javax.inject.Inject)2 Message (org.jboss.errai.bus.client.api.messaging.Message)2 ErrorCallback (org.jboss.errai.common.client.api.ErrorCallback)2 Group (org.jboss.errai.security.shared.api.Group)2 User (org.jboss.errai.security.shared.api.identity.User)2 AssigneeType (org.kie.workbench.common.stunner.bpmn.forms.model.AssigneeType)2 AbstractEntityManager (org.uberfire.ext.security.management.api.AbstractEntityManager)2 ClientUserSystemManager (org.uberfire.ext.security.management.client.ClientUserSystemManager)2 EntryCreationLiveSearchService (org.uberfire.ext.widgets.common.client.dropdown.EntryCreationLiveSearchService)2