Merge origin/release/V2.6' into merge-2-7/MNT-19080_RM-6504_MergeFrom2.6

* remotes/origin/release/V2.6:
  fixed tests because exception changed
  use fileFolderService instead of contentService
  MNT-18806 create a new content URL for the copy only if it has content
  MNT-18806 create a new content bin for the copy on copy complete behavior
  MNT-18806 Add REST test for deleting copy of record.
  MNT-18806 Remove some raw Exceptions from REST test framework.
This commit is contained in:
Rodica Sutu
2018-08-27 20:01:26 +03:00
8 changed files with 185 additions and 28 deletions

View File

@@ -92,14 +92,28 @@ public class RestAPIFactory
return getRmRestWrapper().withSearchAPI();
}
public Node getNodeAPI(RepoTestModel model) throws Exception
public Node getNodeAPI(RepoTestModel model) throws RuntimeException
{
return getCoreAPI(null).usingNode(model);
try
{
return getCoreAPI(null).usingNode(model);
}
catch (Exception e)
{
throw new RuntimeException("Failed to load nodeAPI.", e);
}
}
public Node getNodeAPI(UserModel userModel, RepoTestModel model) throws Exception
public Node getNodeAPI(UserModel userModel, RepoTestModel model) throws RuntimeException
{
return getCoreAPI(userModel).usingNode(model);
try
{
return getCoreAPI(userModel).usingNode(model);
}
catch (Exception e)
{
throw new RuntimeException("Failed to load nodeAPI.", e);
}
}
public RMSiteAPI getRMSiteAPI()

View File

@@ -135,7 +135,7 @@ public class FilePlanAPI extends RMModelRequest
/**
* see {@link #createRootRecordCategory(RecordCategory, String, String)}
*/
public RecordCategory createRootRecordCategory(RecordCategory recordCategoryModel, String filePlanId) throws Exception
public RecordCategory createRootRecordCategory(RecordCategory recordCategoryModel, String filePlanId)
{
mandatoryObject("recordCategoryModel", recordCategoryModel);
mandatoryString("filePlanId", filePlanId);
@@ -150,7 +150,7 @@ public class FilePlanAPI extends RMModelRequest
* @param filePlanId The identifier of a file plan
* @param parameters The URL parameters to add
* @return The created {@link RecordCategory}
* @throws Exception for the following cases:
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code filePlanId} is not a valid format or {@code filePlanId} is invalid</li>
* <li>authentication fails</li>
@@ -160,7 +160,7 @@ public class FilePlanAPI extends RMModelRequest
* <li>model integrity exception, including node name with invalid characters</li>
* </ul>
*/
public RecordCategory createRootRecordCategory(RecordCategory recordCategoryModel, String filePlanId, String parameters) throws Exception
public RecordCategory createRootRecordCategory(RecordCategory recordCategoryModel, String filePlanId, String parameters)
{
mandatoryObject("recordCategoryModel", recordCategoryModel);
mandatoryString("filePlanId", filePlanId);

View File

@@ -201,7 +201,7 @@ public class RecordCategoryAPI extends RMModelRequest
/**
* see {@link #createRecordCategoryChild(RecordCategoryChild, String, String)}
*/
public RecordCategoryChild createRecordCategoryChild(RecordCategoryChild recordCategoryChildModel, String recordCategoryId) throws Exception
public RecordCategoryChild createRecordCategoryChild(RecordCategoryChild recordCategoryChildModel, String recordCategoryId)
{
mandatoryObject("recordCategoryChildModel", recordCategoryChildModel);
mandatoryString("recordCategoryId", recordCategoryId);
@@ -216,7 +216,7 @@ public class RecordCategoryAPI extends RMModelRequest
* @param recordCategoryId The identifier of a record category
* @param parameters The URL parameters to add
* @return The created {@link RecordCategoryChild}
* @throws Exception for the following cases:
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code recordCategoryId} is not a valid format or {@code recordCategoryChildModel} is invalid</li>
* <li>authentication fails</li>
@@ -226,7 +226,7 @@ public class RecordCategoryAPI extends RMModelRequest
* <li>model integrity exception, including node name with invalid characters</li>
* </ul>
*/
public RecordCategoryChild createRecordCategoryChild(RecordCategoryChild recordCategoryChildModel, String recordCategoryId, String parameters) throws Exception
public RecordCategoryChild createRecordCategoryChild(RecordCategoryChild recordCategoryChildModel, String recordCategoryId, String parameters)
{
mandatoryObject("filePlanComponentProperties", recordCategoryChildModel);
mandatoryString("recordCategoryId", recordCategoryId);

View File

@@ -40,6 +40,7 @@ import static org.springframework.http.HttpMethod.PUT;
import static org.testng.Assert.fail;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import com.fasterxml.jackson.databind.JsonNode;
@@ -212,7 +213,7 @@ public class RecordFolderAPI extends RMModelRequest
/**
* see {@link #createRecord(Record, String, String)}
*/
public Record createRecord(Record recordModel, String recordFolderId) throws Exception
public Record createRecord(Record recordModel, String recordFolderId)
{
mandatoryObject("recordModel", recordModel);
mandatoryString("recordFolderId", recordFolderId);
@@ -227,9 +228,9 @@ public class RecordFolderAPI extends RMModelRequest
* @param recordContent {@link File} pointing to the content of the electronic record to be created
* @param recordFolderId The identifier of a record folder
* @return newly created {@link Record}
* @throws Exception for invalid recordModel JSON strings
* @throws RuntimeException for invalid recordModel JSON strings
*/
public Record createRecord(Record recordModel, String recordFolderId, File recordContent) throws Exception
public Record createRecord(Record recordModel, String recordFolderId, File recordContent) throws RuntimeException
{
mandatoryString("recordFolderId", recordFolderId);
mandatoryObject("recordContent", recordContent);
@@ -245,7 +246,15 @@ public class RecordFolderAPI extends RMModelRequest
* to the request.
*/
RequestSpecBuilder builder = getRmRestWrapper().configureRequestSpec();
JsonNode root = new ObjectMapper().readTree(toJson(recordModel, Record.class, FilePlanComponentMixIn.class));
JsonNode root;
try
{
root = new ObjectMapper().readTree(toJson(recordModel, Record.class, FilePlanComponentMixIn.class));
}
catch (IOException e)
{
throw new RuntimeException("Failed to convert model to JSON.", e);
}
// add request fields
Iterator<String> fieldNames = root.fieldNames();
while (fieldNames.hasNext())
@@ -266,7 +275,7 @@ public class RecordFolderAPI extends RMModelRequest
* @param recordFolderId The identifier of a record folder
* @param parameters The URL parameters to add
* @return The created {@link Record}
* @throws Exception for the following cases:
* @throws RuntimeException for the following cases:
* <ul>
* <li>{@code recordFolderId is not a valid format or {@code recordModel} is invalid</li>
* <li>authentication fails</li>
@@ -275,7 +284,7 @@ public class RecordFolderAPI extends RMModelRequest
* <li>model integrity exception, including node name with invalid characters</li>
* </ul>
*/
public Record createRecord(Record recordModel, String recordFolderId, String parameters) throws Exception
public Record createRecord(Record recordModel, String recordFolderId, String parameters)
{
mandatoryObject("recordModel", recordModel);
mandatoryString("recordFolderId", recordFolderId);