<commit_before>package uk.ac.ebi.quickgo.common.search.solr;

import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import static uk.ac.ebi.quickgo.common.search.solr.SolrRetrievalConfigHelper.HIGHLIGHT_END_DELIM_INDEX;
import static uk.ac.ebi.quickgo.common.search.solr.SolrRetrievalConfigHelper.HIGHLIGHT_START_DELIM_INDEX;
import static uk.ac.ebi.quickgo.common.search.solr.SolrRetrievalConfigHelper.convertHighlightDelims;

/**
 * Created 09/02/16
 * @author Edd
 */
public class SolrRetrievalConfigHelperTest {
    private static final String COMMA = ",";

    @Test
    public void settingZeroHighlightFieldsResultsInUsingDefaultHighlighting() {
        String highlightDelims = "";

        String[] convertedHighlightDelims = convertHighlightDelims(highlightDelims, COMMA);

        assertThat(convertedHighlightDelims[HIGHLIGHT_START_DELIM_INDEX], is(not(isEmptyOrNullString())));
        assertThat(convertedHighlightDelims[HIGHLIGHT_END_DELIM_INDEX], is(not(isEmptyOrNullString())));
    }

    @Test
    public void settingExplicitValidHighlightFieldsResultsInTheseFieldsBeingUsed() {
        String highlightDelimStart = "<b>";
        String highlightDelimEnd = "</b>";
        String highlightDelims = highlightDelimStart + "," + highlightDelimEnd;<commit_msg>Use the COMMA constant to represent the separation between highlighting.<commit_after>package uk.ac.ebi.quickgo.common.search.solr;

import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;
import static uk.ac.ebi.quickgo.common.search.solr.SolrRetrievalConfigHelper.HIGHLIGHT_END_DELIM_INDEX;
import static uk.ac.ebi.quickgo.common.search.solr.SolrRetrievalConfigHelper.HIGHLIGHT_START_DELIM_INDEX;
import static uk.ac.ebi.quickgo.common.search.solr.SolrRetrievalConfigHelper.convertHighlightDelims;

/**
 * Created 09/02/16
 * @author Edd
 */
public class SolrRetrievalConfigHelperTest {
    private static final String COMMA = ",";

    @Test
    public void settingZeroHighlightFieldsResultsInUsingDefaultHighlighting() {
        String highlightDelims = "";

        String[] convertedHighlightDelims = convertHighlightDelims(highlightDelims, COMMA);

        assertThat(convertedHighlightDelims[HIGHLIGHT_START_DELIM_INDEX], is(not(isEmptyOrNullString())));
        assertThat(convertedHighlightDelims[HIGHLIGHT_END_DELIM_INDEX], is(not(isEmptyOrNullString())));
    }

    @Test
    public void settingExplicitValidHighlightFieldsResultsInTheseFieldsBeingUsed() {
        String highlightDelimStart = "<b>";
        String highlightDelimEnd = "</b>";
        String highlightDelims = highlightDelimStart + COMMA + highlightDelimEnd;
{'fraction_non_alphanumeric': 0.09205591544493692, 'fraction_numerical': 0.004091374019774974, 'mean_word_length': 5.4483516483516485, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1798290', 'n_tokens_mistral': 921, 'n_tokens_neox': 872, 'n_words': 139}