Example usage for com.liferay.portal.search.test.util DocumentsAssert assertValues

List of usage examples for com.liferay.portal.search.test.util DocumentsAssert assertValues

Introduction

In this page you can find the example usage for com.liferay.portal.search.test.util DocumentsAssert assertValues.

Prototype

public static void assertValues(String message, Stream<Document> documents, String fieldName, String expected) 

Source Link

Usage

From source file:com.liferay.asset.search.test.AssetUtilSearchSortTest.java

License:Open Source License

@Test
public void testPriority() throws Exception {
    double[] priorities = { 10, 1, 40, 5.3 };

    for (double priority : priorities) {
        addJournalArticle(serviceContext -> serviceContext.setAssetPriority(priority));
    }//from  w  ww  .  j  av  a2  s.  co m

    SearchContext searchContext = createSearchContext();

    QueryConfig queryConfig = searchContext.getQueryConfig();

    queryConfig.addSelectedFieldNames(Field.PRIORITY);

    AssetEntryQuery assetEntryQuery = createAssetEntryQueryOrderBy(Field.PRIORITY);

    Hits hits = _assetHelper.search(searchContext, assetEntryQuery, QueryUtil.ALL_POS, QueryUtil.ALL_POS);

    DocumentsAssert.assertValues((String) searchContext.getAttribute("queryString"), hits.getDocs(),
            Field.PRIORITY, Arrays.asList("1.0", "5.3", "10.0", "40.0"));
}