mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
Made the faceted group test go green
This commit is contained in:
@@ -19,15 +19,13 @@
|
||||
package org.alfresco.rest.search;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.testng.Assert;
|
||||
import org.testng.TestException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
@@ -102,13 +100,6 @@ public class FacetedSearchTest extends AbstractSearchTest
|
||||
facets.add(new FacetQuery("content.size:[1048576 TO 16777216]", "large"));
|
||||
query.setFacetQueries(facets);
|
||||
|
||||
// RestRequestFacetFieldsModel facetFields = new RestRequestFacetFieldsModel();
|
||||
// List<Object> list = new ArrayList<Object>();
|
||||
// list.add(new FacetFieldQuery("'content.size'"));
|
||||
// facetFields.setFacets(list);
|
||||
//
|
||||
// query.setFacetFields(facetFields);
|
||||
|
||||
SearchResponse response = query(query);
|
||||
response.assertThat().entriesListIsNotEmpty();
|
||||
response.getContext().assertThat().field("facetQueries").isNotEmpty();
|
||||
@@ -166,6 +157,8 @@ public class FacetedSearchTest extends AbstractSearchTest
|
||||
* }
|
||||
* }
|
||||
* }}
|
||||
*
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void searchFacetGroup() throws Exception
|
||||
@@ -187,21 +180,34 @@ public class FacetedSearchTest extends AbstractSearchTest
|
||||
facetFields.setFacets(list);
|
||||
|
||||
query.setFacetFields(facetFields);
|
||||
System.out.println(query.toJson());
|
||||
SearchResponse response = query(query);
|
||||
System.out.println(response);
|
||||
//We don't expect to see the FacetQueries if group is being used.
|
||||
Assert.assertTrue(response.getContext().getFacetQueries().isEmpty());
|
||||
Assert.assertTrue(response.getContext().getFacetQueries() == null);
|
||||
//Validate the facet field structure is correct.
|
||||
Assert.assertFalse(response.getContext().getFacetsFields().isEmpty());
|
||||
RestResultBucketsModel bucket = response.getContext().getFacetsFields().get(0);
|
||||
Assert.assertEquals(response.getContext().getFacetsFields().get(0).getLabel(), "foo");
|
||||
FacetFieldBucket bucket = response.getContext().getFacetsFields().get(0).getBuckets().get(0);
|
||||
bucket.assertThat().field("label").isNotEmpty();
|
||||
bucket.assertThat().field("count").isNotEmpty();
|
||||
bucket.assertThat().field("filterQuery").isNotEmpty();
|
||||
Assert.assertEquals(bucket.getLabel(), "foo");
|
||||
bucket.assertThat().field("label").contains("small").and().field("filterQuery").is("content.size:[0 TO 102400]");
|
||||
bucket.assertThat().field("label").contains("medium").and().field("filterQuery").is("content.size:[1048576 TO 16777216]");
|
||||
bucket.assertThat().field("label").contains("large").and().field("filterQuery").is("content.size:[102400 TO 1048576]");
|
||||
response.getContext().getFacetsFields().get(0).getBuckets().forEach(action -> {
|
||||
switch (action.getLabel())
|
||||
{
|
||||
case "small":
|
||||
Assert.assertEquals(action.getFilterQuery(), "content.size:[0 TO 102400]");
|
||||
break;
|
||||
case "medium":
|
||||
Assert.assertEquals(action.getFilterQuery(), "content.size:[102400 TO 1048576]");
|
||||
break;
|
||||
case "large":
|
||||
Assert.assertEquals(action.getFilterQuery(), "content.size:[1048576 TO 16777216]");
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new TestException("Unexpected value returned");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user