mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-4488 (Refactor REST API Automation test code according to the latest changes)
This commit is contained in:
@@ -28,6 +28,9 @@ package org.alfresco.rest.core;
|
|||||||
|
|
||||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RestIGCoreAPI;
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.RestIGCoreAPI;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FIXME!!!
|
* FIXME!!!
|
||||||
@@ -35,6 +38,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
* @author Tuna Aksoy
|
* @author Tuna Aksoy
|
||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
|
@Primary
|
||||||
|
@Service
|
||||||
|
@Scope(value = "prototype")
|
||||||
public class RMRestWrapper extends RestWrapper
|
public class RMRestWrapper extends RestWrapper
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@@ -205,7 +205,7 @@ public class FilePlanComponents extends RMModelRequest
|
|||||||
*/
|
*/
|
||||||
public FilePlanComponentModel createElectronicRecord(FilePlanComponentModel electronicRecordModel, File recordContent, String parentId) throws Exception
|
public FilePlanComponentModel createElectronicRecord(FilePlanComponentModel electronicRecordModel, File recordContent, String parentId) throws Exception
|
||||||
{
|
{
|
||||||
mandatoryObject("filePlanComponentProperties", electronicRecordModel);
|
mandatoryObject("electronicRecordModel", electronicRecordModel);
|
||||||
mandatoryString("parentId", parentId);
|
mandatoryString("parentId", parentId);
|
||||||
if (!electronicRecordModel.getNodeType().equals(CONTENT_TYPE))
|
if (!electronicRecordModel.getNodeType().equals(CONTENT_TYPE))
|
||||||
{
|
{
|
||||||
|
@@ -53,5 +53,6 @@ public abstract class RMModelRequest extends ModelRequest
|
|||||||
public RMModelRequest(RMRestWrapper rmRestWrapper)
|
public RMModelRequest(RMRestWrapper rmRestWrapper)
|
||||||
{
|
{
|
||||||
super(rmRestWrapper);
|
super(rmRestWrapper);
|
||||||
|
this.rmRestWrapper = rmRestWrapper;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
package org.alfresco.rest.rm.community.fileplancomponents;
|
package org.alfresco.rest.rm.community.fileplancomponents;
|
||||||
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
||||||
|
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.IMAGE_FILE;
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createElectronicRecordModel;
|
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createElectronicRecordModel;
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicRecordModel;
|
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicRecordModel;
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
import static org.springframework.http.HttpStatus.CREATED;
|
||||||
@@ -65,9 +66,6 @@ public class DeleteRecordTests extends BaseRestTest
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DataUser dataUser;
|
private DataUser dataUser;
|
||||||
|
|
||||||
/** image resource file to be used for records body */
|
|
||||||
private static final String IMAGE_FILE = "money.JPG";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* Given a record
|
* Given a record
|
||||||
|
@@ -32,6 +32,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
|||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
|
||||||
import static org.alfresco.rest.rm.community.util.PojoUtility.toJson;
|
import static org.alfresco.rest.rm.community.util.PojoUtility.toJson;
|
||||||
|
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.IMAGE_FILE;
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createElectronicRecordModel;
|
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createElectronicRecordModel;
|
||||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
import static org.springframework.http.HttpStatus.CREATED;
|
||||||
@@ -55,9 +56,6 @@ import org.testng.annotations.Test;
|
|||||||
*/
|
*/
|
||||||
public class ElectronicRecordTests extends BaseRestTest
|
public class ElectronicRecordTests extends BaseRestTest
|
||||||
{
|
{
|
||||||
/** image resource file to be used for records body */
|
|
||||||
private static final String IMAGE_FILE = "money.JPG";
|
|
||||||
|
|
||||||
/** Valid root containers where electronic records can be created */
|
/** Valid root containers where electronic records can be created */
|
||||||
@DataProvider(name = "invalidParentContainers")
|
@DataProvider(name = "invalidParentContainers")
|
||||||
public Object[][] invalidContainers() throws Exception
|
public Object[][] invalidContainers() throws Exception
|
||||||
@@ -199,7 +197,7 @@ public class ElectronicRecordTests extends BaseRestTest
|
|||||||
public void canCreateElectronicRecordsInValidContainers(FilePlanComponentModel container) throws Exception
|
public void canCreateElectronicRecordsInValidContainers(FilePlanComponentModel container) throws Exception
|
||||||
{
|
{
|
||||||
FilePlanComponentModel record = createElectronicRecordModel();
|
FilePlanComponentModel record = createElectronicRecordModel();
|
||||||
String newRecordId = getFilePlanComponentsAPI().createElectronicRecord(createElectronicRecordModel(), IMAGE_FILE, container.getId()).getId();
|
String newRecordId = getFilePlanComponentsAPI().createElectronicRecord(record, IMAGE_FILE, container.getId()).getId();
|
||||||
|
|
||||||
// verify the create request status code
|
// verify the create request status code
|
||||||
assertStatusCode(CREATED);
|
assertStatusCode(CREATED);
|
||||||
|
@@ -34,6 +34,7 @@ import static org.alfresco.rest.rm.community.utils.RMSiteUtil.RM_DESCRIPTION;
|
|||||||
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.RM_ID;
|
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.RM_ID;
|
||||||
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.RM_TITLE;
|
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.RM_TITLE;
|
||||||
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.createDOD5015RMSiteModel;
|
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.createDOD5015RMSiteModel;
|
||||||
|
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.createRMSiteModel;
|
||||||
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.createStandardRMSiteModel;
|
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.createStandardRMSiteModel;
|
||||||
import static org.alfresco.utility.constants.UserRole.SiteManager;
|
import static org.alfresco.utility.constants.UserRole.SiteManager;
|
||||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||||
@@ -124,10 +125,7 @@ public class RMSiteTests extends BaseRestTest
|
|||||||
String newDescription = RM_DESCRIPTION + "createRMSiteWhenSiteExists";
|
String newDescription = RM_DESCRIPTION + "createRMSiteWhenSiteExists";
|
||||||
|
|
||||||
// Create the RM site
|
// Create the RM site
|
||||||
RMSiteModel rmSiteModel = RMSiteModel.builder().compliance(STANDARD).build();
|
RMSiteModel rmSiteModel = createRMSiteModel(STANDARD, newTitle, newDescription);
|
||||||
rmSiteModel.setTitle(newTitle);
|
|
||||||
rmSiteModel.setDescription(newDescription);
|
|
||||||
|
|
||||||
getRMSiteAPI().createRMSite(rmSiteModel);
|
getRMSiteAPI().createRMSite(rmSiteModel);
|
||||||
|
|
||||||
// Verify the status code
|
// Verify the status code
|
||||||
@@ -145,6 +143,9 @@ public class RMSiteTests extends BaseRestTest
|
|||||||
)
|
)
|
||||||
public void deleteRMSite() throws Exception
|
public void deleteRMSite() throws Exception
|
||||||
{
|
{
|
||||||
|
// Create the RM site if it does not exist
|
||||||
|
createRMSiteIfNotExists();
|
||||||
|
|
||||||
// Delete the RM site
|
// Delete the RM site
|
||||||
getRMSiteAPI().deleteRMSite();
|
getRMSiteAPI().deleteRMSite();
|
||||||
|
|
||||||
|
@@ -46,6 +46,9 @@ public class FilePlanComponentsUtil
|
|||||||
// Intentionally blank
|
// Intentionally blank
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** image resource file to be used for records body */
|
||||||
|
public static final String IMAGE_FILE = "money.JPG";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FIXME!!!
|
* FIXME!!!
|
||||||
*
|
*
|
||||||
|
@@ -50,6 +50,22 @@ public class RMSiteUtil
|
|||||||
public static final String RM_TITLE = "Records Management";
|
public static final String RM_TITLE = "Records Management";
|
||||||
public static final String RM_DESCRIPTION = "Records Management Site";
|
public static final String RM_DESCRIPTION = "Records Management Site";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FIXME!!!
|
||||||
|
*
|
||||||
|
* @param compliance FIXME!!!
|
||||||
|
* @param title FIXME!!!
|
||||||
|
* @param description FIXME!!!
|
||||||
|
* @return FIXME!!!
|
||||||
|
*/
|
||||||
|
public static RMSiteModel createRMSiteModel(RMSiteCompliance compliance, String title, String description)
|
||||||
|
{
|
||||||
|
RMSiteModel rmSiteModel = RMSiteModel.builder().compliance(compliance).build();
|
||||||
|
rmSiteModel.setTitle(title);
|
||||||
|
rmSiteModel.setDescription(description);
|
||||||
|
return rmSiteModel;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FIXME!!!
|
* FIXME!!!
|
||||||
*
|
*
|
||||||
@@ -58,10 +74,7 @@ public class RMSiteUtil
|
|||||||
*/
|
*/
|
||||||
private static RMSiteModel createRMSiteModel(RMSiteCompliance compliance)
|
private static RMSiteModel createRMSiteModel(RMSiteCompliance compliance)
|
||||||
{
|
{
|
||||||
RMSiteModel rmSiteModel = RMSiteModel.builder().compliance(compliance).build();
|
return createRMSiteModel(compliance, RM_TITLE, RM_DESCRIPTION);
|
||||||
rmSiteModel.setTitle(RM_TITLE);
|
|
||||||
rmSiteModel.setDescription(RM_DESCRIPTION);
|
|
||||||
return rmSiteModel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,5 +96,4 @@ public class RMSiteUtil
|
|||||||
{
|
{
|
||||||
return createRMSiteModel(DOD5015);
|
return createRMSiteModel(DOD5015);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user