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; 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,17 +119,14 @@ 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 //create the request body
JSONObject requestParams = new JSONObject(); JSONObject requestParams = new JSONObject();
@@ -138,16 +137,8 @@ public class CustomDefinitionsAPI extends BaseAPI
JSONObject setRelationshipStatus = doPostRequest(adminUser, adminPassword, requestParams, JSONObject setRelationshipStatus = doPostRequest(adminUser, adminPassword, requestParams,
MessageFormat.format(CREATE_RELATIONSHIP_API_ENDPOINT, "{0}", NODE_PREFIX + recordNodeIdFrom)); MessageFormat.format(CREATE_RELATIONSHIP_API_ENDPOINT, "{0}", NODE_PREFIX + recordNodeIdFrom));
//check the response //check the response
if (setRelationshipStatus != null) boolean success = (setRelationshipStatus != null) && setRelationshipStatus.getBoolean("success");
{ assertTrue("Creating relationship from " + recordNodeIdFrom + " to " + recordNodeIdTo + " failed.", success);
return setRelationshipStatus.getBoolean("success");
}
}
catch (JSONException error)
{
LOGGER.error("Unable to extract response parameter", error);
}
return false;
} }
} }