Merged 5.2.N (5.2.1) to HEAD (5.2)

130181 gjames: Merged searchapi (5.2.1) to 5.2.N (5.2.1)
      129821 gjames: SEARCH-150: Implementing include in the JSON body


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@130332 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-09-06 22:04:51 +00:00
parent 7e95472e8c
commit e8e0209f8c
4 changed files with 81 additions and 5 deletions

View File

@@ -37,11 +37,12 @@ import org.alfresco.rest.api.search.model.Query;
import org.alfresco.rest.api.search.model.SearchQuery;
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
import org.alfresco.rest.framework.resource.parameters.Paging;
import org.alfresco.rest.framework.resource.parameters.Params;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchParameters;
import org.junit.Test;
import java.util.Arrays;
/**
* Tests the SearchMapper class
*
@@ -136,10 +137,41 @@ public class SearchMapperTests
assertEquals(searchParameters.getSkipCount(),paging.getSkipCount());
}
@Test
public void validateInclude() throws Exception
{
try
{
searchMapper.validateInclude(Arrays.asList("sausage"));
fail();
}
catch (InvalidArgumentException iae)
{
//Sausage is illegal
assertNotNull(iae);
}
searchMapper.validateInclude(null);
try
{
searchMapper.validateInclude(Arrays.asList("AspectNames"));
fail();
}
catch (InvalidArgumentException iae)
{
//Case sensitive
assertNotNull(iae);
}
searchMapper.validateInclude(Arrays.asList("properties", "aspectNames"));
}
private SearchQuery minimalQuery()
{
Query query = new Query("cmis", "foo", "");
SearchQuery sq = new SearchQuery(query,null);
SearchQuery sq = new SearchQuery(query,null, null);
return sq;
}
}

View File

@@ -26,6 +26,7 @@
package org.alfresco.rest.api.search;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.alfresco.rest.api.model.Comment;
@@ -64,7 +65,7 @@ public class SearchQuerySerializerTests implements RequestReader
public void testDeserializeQuery() throws IOException
{
String json = "{ \"query\": {\"query\": \"g*\",\"userQuery\": \"great\",\"language\": \"bob\"}, "
+ "\"paging\": {\"maxItems\": \"99\",\"skipCount\": \"4\"}}";
+ "\"paging\": {\"maxItems\": \"99\",\"skipCount\": \"4\"}, \"include\": [\"bob\", \"hope\"]}";
SearchQuery searchQuery = extractFromJson(json);
assertEquals(SearchQuery.class, searchQuery.getClass());
assertEquals("bob", searchQuery.getQuery().getLanguage());
@@ -72,6 +73,9 @@ public class SearchQuerySerializerTests implements RequestReader
assertEquals("great", searchQuery.getQuery().getUserQuery());
assertEquals(99, searchQuery.getPaging().getMaxItems());
assertEquals(4, searchQuery.getPaging().getSkipCount());
assertEquals(2, searchQuery.getInclude().size());
assertTrue(searchQuery.getInclude().contains("bob"));
assertTrue(searchQuery.getInclude().contains("hope"));
}
private SearchQuery extractFromJson(String json) throws IOException