Refactor create relationship test API.

This commit is contained in:
Tom Page
2017-11-09 15:37:16 +00:00
parent c4fac4b0bd
commit e2c0fee0f6

View File

@@ -26,6 +26,8 @@
*/
package org.alfresco.rest.v0;
import static org.testng.AssertJUnit.assertTrue;
import java.text.MessageFormat;
import org.alfresco.rest.core.v0.BaseAPI;
@@ -117,17 +119,14 @@ public class CustomDefinitionsAPI extends BaseAPI
* @param recordNodeIdFrom node ref to set a custom reference
* @param recordNodeIdTo node ref of the to record
* @param relationshipType relation type to be created
* @return <code>true</code> if creating relationship was successful,
* <code>false</code> otherwise
* @throws AssertionError if the creation fails.
*/
public boolean createRelationship(
public void createRelationship(
String adminUser,
String adminPassword,
String recordNodeIdFrom,
String recordNodeIdTo,
CustomDefinitions relationshipType)
{
try
{
//create the request body
JSONObject requestParams = new JSONObject();
@@ -138,16 +137,8 @@ public class CustomDefinitionsAPI extends BaseAPI
JSONObject setRelationshipStatus = doPostRequest(adminUser, adminPassword, requestParams,
MessageFormat.format(CREATE_RELATIONSHIP_API_ENDPOINT, "{0}", NODE_PREFIX + recordNodeIdFrom));
//check the response
if (setRelationshipStatus != null)
{
return setRelationshipStatus.getBoolean("success");
}
}
catch (JSONException error)
{
LOGGER.error("Unable to extract response parameter", error);
}
return false;
boolean success = (setRelationshipStatus != null) && setRelationshipStatus.getBoolean("success");
assertTrue("Creating relationship from " + recordNodeIdFrom + " to " + recordNodeIdTo + " failed.", success);
}
}