Search in sources :

Example 1 with Spelling

use of org.alfresco.rest.api.search.model.Spelling in project alfresco-remote-api by Alfresco.

the class SearchMapperTests method fromSpelling.

@Test
public void fromSpelling() throws Exception {
    SearchParameters searchParameters = new SearchParameters();
    // Doesn't error
    searchMapper.fromSpellCheck(searchParameters, null);
    assertFalse(searchParameters.isSpellCheck());
    try {
        searchMapper.fromSpellCheck(searchParameters, new Spelling(null));
        fail();
    } catch (InvalidArgumentException iae) {
        // Can't be null
        assertNotNull(iae);
    }
    // Now set search term first
    searchParameters.setSearchTerm("fred");
    searchMapper.fromSpellCheck(searchParameters, new Spelling(null));
    assertEquals("fred", searchParameters.getSearchTerm());
    // Now query replaces userQuery (search term)
    searchMapper.fromSpellCheck(searchParameters, new Spelling("favourit"));
    assertEquals("favourit", searchParameters.getSearchTerm());
    assertTrue(searchParameters.isSpellCheck());
}
Also used : SearchParameters(org.alfresco.service.cmr.search.SearchParameters) Spelling(org.alfresco.rest.api.search.model.Spelling) InvalidArgumentException(org.alfresco.rest.framework.core.exceptions.InvalidArgumentException) Test(org.junit.Test)

Aggregations

Spelling (org.alfresco.rest.api.search.model.Spelling)1 InvalidArgumentException (org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)1 SearchParameters (org.alfresco.service.cmr.search.SearchParameters)1 Test (org.junit.Test)1