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());
}
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());
}
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());
}
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());
}
Aggregations