use of org.alfresco.rest.api.tests.client.data.Person in project alfresco-remote-api by Alfresco.
the class QueriesPeopleApiTest method checkApiCall.
private void checkApiCall(String term, String orderBy, String fields, Paging paging, int expectedStatus, List<String> expectedPeople, int... userIds) throws Exception {
createParamIdNotNull(Queries.PARAM_TERM, term);
createParamIdNotNull(Queries.PARAM_ORDERBY, orderBy);
createParamIdNotNull(Queries.PARAM_FIELDS, fields);
dummySearchServiceQueryNodeRefs.clear();
for (int i : userIds) {
NodeRef nodeRef = testPersonNodeRefs.get(i);
dummySearchServiceQueryNodeRefs.add(nodeRef);
}
response = getAll(URL_QUERIES_LSP, paging, params, expectedStatus);
if (expectedStatus == 200) {
String termWithEscapedAsterisks = term.replaceAll("\\*", "\\\\*");
String expectedQuery = "TYPE:\"{http://www.alfresco.org/model/content/1.0}person\" AND (\"*" + termWithEscapedAsterisks + "*\")";
ArgumentCaptor<SearchParameters> searchParametersCaptor = ArgumentCaptor.forClass(SearchParameters.class);
verify(mockSearchService, times(++callCountToMockSearchService)).query(searchParametersCaptor.capture());
SearchParameters parameters = searchParametersCaptor.getValue();
assertEquals("Query", expectedQuery, parameters.getQuery());
people = Person.parsePeople(response.getJsonResponse()).getList();
if (!expectedPeople.isEmpty()) {
StringJoiner actual = new StringJoiner("\n");
StringJoiner expected = new StringJoiner("\n");
for (String people : expectedPeople) {
expected.add(people);
}
for (Person person : people) {
actual.add(person.toString());
}
String exp = expected.toString().replaceAll(TEST_TERM_PREFIX, "");
String act = actual.toString().replaceAll(TEST_TERM_PREFIX, "");
assertEquals(exp, act);
}
}
}
Aggregations