mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Refactor create relationship test API.
This commit is contained in:
@@ -26,6 +26,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.v0;
|
package org.alfresco.rest.v0;
|
||||||
|
|
||||||
|
import static org.testng.AssertJUnit.assertTrue;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
import org.alfresco.rest.core.v0.BaseAPI;
|
import org.alfresco.rest.core.v0.BaseAPI;
|
||||||
@@ -117,37 +119,26 @@ public class CustomDefinitionsAPI extends BaseAPI
|
|||||||
* @param recordNodeIdFrom node ref to set a custom reference
|
* @param recordNodeIdFrom node ref to set a custom reference
|
||||||
* @param recordNodeIdTo node ref of the to record
|
* @param recordNodeIdTo node ref of the to record
|
||||||
* @param relationshipType relation type to be created
|
* @param relationshipType relation type to be created
|
||||||
* @return <code>true</code> if creating relationship was successful,
|
* @throws AssertionError if the creation fails.
|
||||||
* <code>false</code> otherwise
|
|
||||||
*/
|
*/
|
||||||
public boolean createRelationship(
|
public void createRelationship(
|
||||||
String adminUser,
|
String adminUser,
|
||||||
String adminPassword,
|
String adminPassword,
|
||||||
String recordNodeIdFrom,
|
String recordNodeIdFrom,
|
||||||
String recordNodeIdTo,
|
String recordNodeIdTo,
|
||||||
CustomDefinitions relationshipType)
|
CustomDefinitions relationshipType)
|
||||||
{
|
{
|
||||||
try
|
//create the request body
|
||||||
{
|
JSONObject requestParams = new JSONObject();
|
||||||
//create the request body
|
requestParams.put("toNode", NODE_REF_WORKSPACE_SPACES_STORE + recordNodeIdTo);
|
||||||
JSONObject requestParams = new JSONObject();
|
requestParams.put("refId", getCustomReferenceId(adminUser, adminPassword, relationshipType
|
||||||
requestParams.put("toNode", NODE_REF_WORKSPACE_SPACES_STORE + recordNodeIdTo);
|
.getDefinition()));
|
||||||
requestParams.put("refId", getCustomReferenceId(adminUser, adminPassword, relationshipType
|
//send the API request to create the relationship
|
||||||
.getDefinition()));
|
JSONObject setRelationshipStatus = doPostRequest(adminUser, adminPassword, requestParams,
|
||||||
//send the API request to create the relationship
|
MessageFormat.format(CREATE_RELATIONSHIP_API_ENDPOINT, "{0}", NODE_PREFIX + recordNodeIdFrom));
|
||||||
JSONObject setRelationshipStatus = doPostRequest(adminUser, adminPassword, requestParams,
|
//check the response
|
||||||
MessageFormat.format(CREATE_RELATIONSHIP_API_ENDPOINT, "{0}", NODE_PREFIX + recordNodeIdFrom));
|
boolean success = (setRelationshipStatus != null) && setRelationshipStatus.getBoolean("success");
|
||||||
//check the response
|
assertTrue("Creating relationship from " + recordNodeIdFrom + " to " + recordNodeIdTo + " failed.", success);
|
||||||
if (setRelationshipStatus != null)
|
|
||||||
{
|
|
||||||
return setRelationshipStatus.getBoolean("success");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (JSONException error)
|
|
||||||
{
|
|
||||||
LOGGER.error("Unable to extract response parameter", error);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user