### Question:
APICustomUserInfoValue extends ConsoleAPI<CustomUserInfoItem> implements APIHasSearch<CustomUserInfoItem>, APIHasUpdate<CustomUserInfoItem> { @Override public ItemSearchResult<CustomUserInfoItem> search(int page, int resultsByPage, String search, String orders, Map<String, String> filters) { SearchResult<CustomUserInfoValue> result = getClient().searchCustomUserInfoValues(new SearchOptionsCreator( page, resultsByPage, search, new Sorts(orders), new Filters(filters, new GenericFilterCreator(new CustomUserInfoAttributeConverter()))).create()); return new ItemSearchResultConverter<CustomUserInfoItem, CustomUserInfoValue>( page, resultsByPage, result, new CustomUserInfoConverter()).toItemSearchResult(); } APICustomUserInfoValue(CustomUserInfoEngineClientCreator engineClientCreator); @Override ItemSearchResult<CustomUserInfoItem> search(int page, int resultsByPage, String search, String orders, Map<String, String> filters); @Override String defineDefaultSearchOrder(); @Override CustomUserInfoItem update(APIID id, Map<String, String> attributes);  }### Answer:
@Test public void should_retrieve_custom_user_info() throws Exception { given(engine.searchCustomUserInfoValues(any(SearchOptions.class))).willReturn( new SearchResultImpl<CustomUserInfoValue>(3, Arrays.<CustomUserInfoValue> asList( createValue("foo"), createValue("bar")))); ItemSearchResult<CustomUserInfoItem> result = api.search(0, 2, null, null, Collections.<String, String>emptyMap()); assertThat(result.getPage()).isEqualTo(0); assertThat(result.getTotal()).isEqualTo(3); assertThat(result.getLength()).isEqualTo(2); assertThat(result.getResults().get(0).getValue()).isEqualTo("foo"); assertThat(result.getResults().get(1).getValue()).isEqualTo("bar"); }
@Test public void should_retrieve_custom_user_info_sorted() throws Exception { given(engine.searchCustomUserInfoValues(any(SearchOptions.class))).willReturn( new SearchResultImpl<CustomUserInfoValue>(0, Collections.<CustomUserInfoValue> emptyList())); ArgumentCaptor<SearchOptions> argument = ArgumentCaptor.forClass(SearchOptions.class); api.search(0, 2, null, "userId ASC", Collections.<String, String> emptyMap()); verify(engine).searchCustomUserInfoValues(argument.capture()); assertThat(argument.getValue().getSorts().get(0).getField()).isEqualTo("userId"); assertThat(argument.getValue().getSorts().get(0).getOrder()).isEqualTo(Order.ASC); }
@Test public void should_retrieve_custom_user_info_filtered() throws Exception { given(engine.searchCustomUserInfoValues(any(SearchOptions.class))).willReturn( new SearchResultImpl<CustomUserInfoValue>(0, Collections.<CustomUserInfoValue> emptyList())); ArgumentCaptor<SearchOptions> argument = ArgumentCaptor.forClass(SearchOptions.class); api.search(0, 2, null, null, Collections.singletonMap(CustomUserInfoItem.ATTRIBUTE_VALUE, "bar")); verify(engine).searchCustomUserInfoValues(argument.capture()); assertThat(argument.getValue().getFilters().get(0).getField()).isEqualTo(CustomUserInfoItem.ATTRIBUTE_VALUE); assertThat(argument.getValue().getFilters().get(0).getValue()).isEqualTo("bar"); }
@Test public void should_retrieve_custom_user_info_term_filtered() throws Exception { given(engine.searchCustomUserInfoValues(any(SearchOptions.class))).willReturn( new SearchResultImpl<CustomUserInfoValue>(0, Collections.<CustomUserInfoValue> emptyList())); ArgumentCaptor<SearchOptions> argument = ArgumentCaptor.forClass(SearchOptions.class); api.search(0, 2, "foo", null, Collections.<String, String>emptyMap()); verify(engine).searchCustomUserInfoValues(argument.capture()); assertThat(argument.getValue().getSearchTerm()).isEqualTo("foo"); }