SearchModelFactory { public static SearchResult newSearchResult(final JsonArray items, final long nextPageOffset) { return ImmutableSearchResult.of(items, nextPageOffset, null); } private  SearchModelFactory(); static SearchResult newSearchResult(final JsonArray items, final long nextPageOffset); static SearchResult emptySearchResult(); static SearchResult newSearchResult(final JsonObject jsonObject); static SearchResult newSearchResult(final String jsonString); static SearchResultBuilder newSearchResultBuilder(); static SearchResultBuilder newSearchResultBuilder(final SearchResult searchResult); static LogicalSearchFilter and(final SearchFilter filter1, final SearchFilter filter2,
            final SearchFilter... furtherFilters); static LogicalSearchFilter or(final SearchFilter filter1, final SearchFilter filter2,
            final SearchFilter... furtherFilters); static LogicalSearchFilter not(final SearchFilter filter); static SearchProperty property(final JsonPointer propertyPath); static SearchProperty property(final CharSequence propertyPath); static SearchQuery newSearchQuery(final SearchFilter filter); static SearchQueryBuilder newSearchQueryBuilder(final SearchFilter filter); static SortOption newSortOption(final List<SortOptionEntry> sortOptionEntries); static SortOption newSortOption(final CharSequence propertyPath, final SortOptionEntry.SortOrder sortOrder); @Deprecated static SortOptionEntry newSortOptionEntry(final SortOptionEntry.SortOrder sortOrder,
            final CharSequence propertyPath); static SortOptionEntry newSortOptionEntry(final CharSequence propertyPath,
            final SortOptionEntry.SortOrder sortOrder); static LimitOption newLimitOption(final int offset, final int count); static SizeOption newSizeOption(final int size); static CursorOption newCursorOption(final String cursor);  }
@Test public void newSearchResult() { final SearchResult searchResult = SearchModelFactory.newSearchResult(JsonFactory.newArray(), SearchResult.NO_NEXT_PAGE); assertThat(searchResult) .hasNoNextPage() .isEmpty(); }
@Test public void newSearchResultFromJson() { final JsonArray itemsArray = JsonFactory.newArrayBuilder() .add(1, 2, 3) .build(); final long nextPageOffset = 10L; final String jsonStr = "{\"items\":" + itemsArray.toString() + ",\"nextPageOffset\":" + nextPageOffset + "}"; final JsonObject jsonObject = JsonFactory.newObject(jsonStr); final SearchResult searchResult = SearchModelFactory.newSearchResult(jsonObject); assertThat(searchResult) .containsExactlyElementsOf(itemsArray) .hasNextPageOffset(nextPageOffset); }
@Test public void newSearchResultFromJsonString() { final JsonArray itemsArray = JsonFactory.newArrayBuilder() .add(1, 2, 3) .build(); final long nextPageOffset = 10L; final String jsonStr = "{\"items\":" + itemsArray.toString() + ",\"nextPageOffset\":" + nextPageOffset + "}"; final SearchResult searchResult = SearchModelFactory.newSearchResult(jsonStr); assertThat(searchResult) .containsExactlyElementsOf(itemsArray) .hasNextPageOffset(nextPageOffset); }