### Question:
SearchQueryFactoryImpl implements SearchQueryFactory<C> { @Override public SolrQuery createQuery(C criteria, Paging paging) { SolrQuery query = new SolrQuery(); String queryString = criteriaTransformer.transformCriteria(criteria); query.setQuery(queryString); applyPaging(query, paging); applySorting(query, paging); applyHighlighting(query); return query; }  @Override SolrQuery createQuery(C criteria, Paging paging); void setCriteriaTransformer(CriteriaTransformer<C> criteriaTransformer); void setHighlightParams(HighlightingParams highlightParams);  }### Answer:
@Test public void createQuery_TRANSFORM_CRITERIA() { when(criteriaTransformer.transformCriteria(any())).thenReturn("+keyword:word"); SolrQuery solrQuery = queryFactory.createQuery(new JudgmentCriteria(), null); assertEquals("+keyword:word", solrQuery.getQuery()); }
@Test public void createQuery_PAGING() { JudgmentCriteria criteria = new JudgmentCriteria(); Paging paging = new Paging(3, 15); when(criteriaTransformer.transformCriteria(any())).thenReturn("*:*"); SolrQuery solrQuery = queryFactory.createQuery(criteria, paging); assertEquals(Integer.valueOf(45), solrQuery.getStart()); assertEquals(Integer.valueOf(15), solrQuery.getRows()); }
@Test public void createQuery_SORTING() { JudgmentCriteria criteria = new JudgmentCriteria(); Paging paging = new Paging(0, 10, Sorting.relevanceSorting()); when(criteriaTransformer.transformCriteria(any())).thenReturn("*:*"); SolrQuery solrQuery = queryFactory.createQuery(criteria, paging); assertEquals("score desc", solrQuery.getSortField()); }
@Test public void createQuery_HIGHLIGHTING() { when(criteriaTransformer.transformCriteria(any())).thenReturn("*:*"); SolrQuery solrQuery = queryFactory.createQuery(new JudgmentCriteria(), null); assertTrue(solrQuery.getHighlight()); assertEquals("<highlight>", solrQuery.getHighlightSimplePre()); assertEquals("</highlight>", solrQuery.getHighlightSimplePost()); assertEquals(2, solrQuery.getHighlightFields().length); assertEquals("firstContent", solrQuery.getHighlightFields()[0]); assertEquals("secondContent", solrQuery.getHighlightFields()[1]); assertEquals("50", solrQuery.getFieldParam("firstContent", HighlightParams.FRAGSIZE)); assertEquals("2", solrQuery.getFieldParam("firstContent", HighlightParams.SNIPPETS)); assertEquals("200", solrQuery.getFieldParam("secondContent", HighlightParams.FRAGSIZE)); assertEquals("5", solrQuery.getFieldParam("secondContent", HighlightParams.SNIPPETS)); }
@Test public void createQuery_HIGHLIGHTING_FROM_FIELD() { when(criteriaTransformer.transformCriteria(any())).thenReturn("+firstHighlightFrom:word +secondHighlightFrom:word +keyword:word"); SolrQuery solrQuery = queryFactory.createQuery(new JudgmentCriteria(), null); assertEquals("+firstContent:word +firstContent:word +keyword:word", solrQuery.get(HighlightParams.Q)); }