Search in sources :

Example 1 with LiveSearchResults

use of org.uberfire.ext.widgets.common.client.dropdown.LiveSearchResults in project kie-wb-common by kiegroup.

the class AssigneeLiveSearchServiceTest method testSearchSingleUser.

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

Example 2 with LiveSearchResults

use of org.uberfire.ext.widgets.common.client.dropdown.LiveSearchResults in project kie-wb-common by kiegroup.

the class AssigneeLiveSearchServiceTest method testSearchSingleGroup.

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

Example 3 with LiveSearchResults

use of org.uberfire.ext.widgets.common.client.dropdown.LiveSearchResults 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 4 with LiveSearchResults

use of org.uberfire.ext.widgets.common.client.dropdown.LiveSearchResults 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

RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)4 Test (org.junit.Test)4 SearchRequestImpl (org.uberfire.ext.security.management.impl.SearchRequestImpl)4 LiveSearchResults (org.uberfire.ext.widgets.common.client.dropdown.LiveSearchResults)4 LiveSearchEntry (org.uberfire.ext.widgets.common.client.dropdown.LiveSearchEntry)2