use of org.alfresco.service.cmr.search.GeneralHighlightParameters in project alfresco-remote-api by Alfresco.
the class ResultMapperTests method testHighlight.
@Test
public void testHighlight() throws Exception {
SearchParameters sp = new SearchParameters();
sp.setBulkFetchEnabled(false);
GeneralHighlightParameters highlightParameters = new GeneralHighlightParameters(null, null, null, null, null, null, null, null);
sp.setHighlight(highlightParameters);
assertNull(sp.getHighlight().getMergeContiguous());
assertNull(sp.getHighlight().getFields());
List<FieldHighlightParameters> fields = new ArrayList<>(2);
fields.add(new FieldHighlightParameters(null, null, null, null, null, null));
fields.add(new FieldHighlightParameters("myfield", null, null, null, "(", ")"));
highlightParameters = new GeneralHighlightParameters(1, 2, null, null, null, 50, true, fields);
sp.setHighlight(highlightParameters);
assertEquals(2, sp.getHighlight().getFields().size());
assertEquals(true, sp.getHighlight().getUsePhraseHighlighter().booleanValue());
assertEquals(1, sp.getHighlight().getSnippetCount().intValue());
assertEquals(50, sp.getHighlight().getMaxAnalyzedChars().intValue());
assertEquals(2, sp.getHighlight().getFragmentSize().intValue());
assertEquals("myfield", sp.getHighlight().getFields().get(1).getField());
assertEquals("(", sp.getHighlight().getFields().get(1).getPrefix());
assertEquals(")", sp.getHighlight().getFields().get(1).getPostfix());
}
use of org.alfresco.service.cmr.search.GeneralHighlightParameters in project alfresco-remote-api by Alfresco.
the class SearchMapperTests method fromHighlight.
@Test
public void fromHighlight() throws Exception {
SearchParameters searchParameters = new SearchParameters();
List<FieldHighlightParameters> fields = Arrays.asList(new FieldHighlightParameters("desc", 50, 100, false, "@", "#"), new FieldHighlightParameters("title", 55, 105, true, "*", "¿"));
GeneralHighlightParameters highlightParameters = new GeneralHighlightParameters(5, 10, false, "{", "}", 20, true, fields);
searchMapper.fromHighlight(searchParameters, highlightParameters);
assertEquals(searchParameters.getHighlight(), highlightParameters);
}
Aggregations