RM-6310: sc:securityMarksSearch is not properly updated when editing the content classification (affects the results from RM search results): automation tests

This commit is contained in:
jcule
2018-05-29 15:45:28 +01:00
3 changed files with 149 additions and 13 deletions

View File

@@ -121,6 +121,37 @@ public abstract class BaseAPI
return results;
}
/**
* Helper method to extract the property value for the given nodeRef and property name
*
* @param result
* @param nodeRef
* @param propertyName
* @return
*/
protected String getPropertyValue(JSONObject result, String nodeRef, String propertyName)
{
String propertyValue = "";
try
{
JSONArray items = result.getJSONArray("items");
for (int i = 0; i < items.length(); i++)
{
JSONObject item = items.getJSONObject(i);
if(nodeRef.equals(item.getString("nodeRef")))
{
propertyValue = item.getJSONObject("properties").getString(propertyName);
}
}
}
catch (JSONException error)
{
throw new RuntimeException("Unable to parse result", error);
}
return propertyValue;
}
/**
* Helper method to extract property values from request result and put them in map as a list that corresponds to a unique property value.
*

View File

@@ -63,7 +63,7 @@ public class SearchAPI extends BaseAPI
/** RM search URL template */
private static final String RM_SEARCH_ENDPOINT = "{0}alfresco/s/slingshot/rmsearch/{1}?{2}";
/** RM document search filters */
/** RM all nodes search filters */
private static final String RM_DEFAULT_NODES_FILTERS =
"records/true,undeclared/true,vital/false,folders/{0},categories/{1},frozen/false,cutoff/false";
@@ -123,23 +123,44 @@ public class SearchAPI extends BaseAPI
* Search as a user for nodes on site "rm" matching query, using SearchAPI.RM_DEFAULT_RECORD_FILTERS and sorted
* by sortby
* <br>
* If more fine-grained control of search parameters is required, use rmSearch() directly.
*
* @param username
* @param password
* @param query
* @param sortby
* @return list of record names
* @return list of node names
*/
public List<String> searchForRecordsAsUser(
String username, String password,
String query, String sortby,
boolean includeCategories, boolean includeFolders)
public List<String> searchForNodeNamesAsUser(String username, String password, String query, String sortby,
boolean includeCategories, boolean includeFolders)
{
String searchFilterParamaters = MessageFormat.format(RM_DEFAULT_NODES_FILTERS, Boolean.toString(includeFolders), Boolean.toString(includeCategories));
String searchFilterParamaters = MessageFormat.format(RM_DEFAULT_NODES_FILTERS, Boolean.toString(includeFolders),
Boolean.toString(includeCategories));
return getItemNames(rmSearch(username, password, "rm", query, searchFilterParamaters, sortby));
}
/**
* Search as a user for nodes on site "rm" matching query, using SearchAPI.RM_DEFAULT_RECORD_FILTERS and sorted
* by sortby and returns the property value for the given nodeRef and property name
*
* @param username
* @param password
* @param query
* @param sortby
* @param includeCategories
* @param includeFolders
* @return list of node properties
*/
public String searchForNodePropertyAsUser(String username, String password, String nodeRef, String propertyName, String query, String sortby,
boolean includeCategories, boolean includeFolders)
{
String searchFilterParamaters = MessageFormat.format(RM_DEFAULT_NODES_FILTERS, Boolean.toString(includeFolders),
Boolean.toString(includeCategories));
return getItemProperty(rmSearch(username, password, "rm", query, searchFilterParamaters, sortby), nodeRef, propertyName);
}
/**
>>>>>>> remotes/origin/feature/RM-6310_securityMarksSearchNotProperlyUpdated_AutomationTests
* Generic faceted search.
* @param username
* @param password
@@ -208,12 +229,35 @@ public class SearchAPI extends BaseAPI
/**
* Helper method to extract list of names from search result.
*
* @param searchResult
* @return list of document or record names in search result
* @throws FileNotFoundException
* @throws JsonSyntaxException
* @throws JsonIOException
* @throws RuntimeException for malformed search response
*/
/**
* Helper method to extract list of names from search result.
*
* @param searchResult
* @param getProperties
* @return
*/
private List<String> getItemNames(JSONObject searchResult)
{
return getPropertyValues(searchResult, "name");
}
/**
* Helper method to extract list of property values from search result for the given nodeRef.
*
* @param searchResult
* @param getProperties
* @return
*/
private String getItemProperty(JSONObject searchResult, String nodeRef, String propertyName)
{
return getPropertyValue(searchResult, nodeRef, propertyName);
}
}