### Question:
UserDatastore extends CommonDatastore<UserItem, User> implements DatastoreHasGet<UserItem> { protected ItemSearchResult<UserItem> searchUsersWhoCanPerformTask(final String taskId, final int page, final int resultsByPage, final String search, final Map<String, String> filters, final String orders) { SearchResult<User> engineSearchResults; try { SearchOptionsCreator searchOptionsCreator = buildSearchOptionCreator(page, resultsByPage, search, filters, orders); engineSearchResults = getProcessEngineClient().getProcessApi().searchUsersWhoCanExecutePendingHumanTask(Long.valueOf(taskId), searchOptionsCreator.create()); } catch (NumberFormatException e) { throw new APIAttributeException(UserItem.FILTER_HUMAN_TASK_ID, "Cannot convert human task id: " + taskId + " into long."); } return new ItemSearchResult<>(page, resultsByPage, engineSearchResults.getCount(), userItemConverter.convert(engineSearchResults.getResult())); } UserDatastore(final APISession engineSession); UserItem add(final UserItem user); UserItem update(final APIID id, final Map<String, String> attributes); @Override UserItem get(final APIID id); ItemSearchResult<UserItem> search(final int page, final int resultsByPage, final String search,
            final Map<String, String> filters, final String orders); void delete(final List<APIID> ids);  }### Answer:
@Test public void testSearchUsersWhoCanPerformTask_with_should_return_nothing() throws Exception { when(processAPI.searchUsersWhoCanExecutePendingHumanTask(eq(0L), any(SearchOptions.class))).thenReturn(mock(SearchResult.class)); ItemSearchResult<UserItem> results = datastore.searchUsersWhoCanPerformTask("0", 0, 10, "jan", Collections.EMPTY_MAP, ""); verify(processAPI, times(1)).searchUsersWhoCanExecutePendingHumanTask(anyLong(), any(SearchOptions.class)); assertThat(results.getLength()).isEqualTo(10); assertThat(results.getPage()).isEqualTo(0); assertThat(results.getTotal()).isEqualTo(0); assertThat(results.getResults()).isEmpty(); }
@Test public void testSearchUsersWhoCanPerformTask_with_should_return_one_result() throws Exception { @SuppressWarnings("rawtypes") SearchResult engineSearchResults = mock(SearchResult.class); long expected = 1; when(engineSearchResults.getCount()).thenReturn(expected); User user = mock(User.class); String firstname = "Chuck"; when(user.getFirstName()).thenReturn(firstname); String lastname = "Norris"; when(user.getLastName()).thenReturn(lastname); List<User> userList = Collections.singletonList(user); when(engineSearchResults.getResult()).thenReturn(userList); when(processAPI.searchUsersWhoCanExecutePendingHumanTask(eq(18L), any(SearchOptions.class))).thenReturn(engineSearchResults); UserItem userItem = mock(UserItem.class); List<UserItem> userItemList = Collections.singletonList(userItem); when(userItemConverter.convert(userList)).thenReturn(userItemList); int page = 1; int resultsByPage = 8; ItemSearchResult<UserItem> results = datastore.searchUsersWhoCanPerformTask("18", page, resultsByPage, "jan", Collections.EMPTY_MAP, ""); assertThat(results.getLength()).isEqualTo(resultsByPage); assertThat(results.getPage()).isEqualTo(page); assertThat(results.getTotal()).isEqualTo(expected); assertThat(results.getResults()).isNotEmpty().hasSize(1).containsExactly(userItem); verify(processAPI, times(1)).searchUsersWhoCanExecutePendingHumanTask(anyLong(), any(SearchOptions.class)); verify(userItemConverter, times(1)).convert(userList); }