Merge 'master' into feature/RM-5012_recordIdentifier

This commit is contained in:
Ana Bozianu
2017-05-18 11:36:43 +03:00
35 changed files with 475 additions and 98 deletions

View File

@@ -47,6 +47,7 @@ public class FilePlanComponentFields
public static final String PROPERTIES_VITAL_RECORD_INDICATOR = "rma:vitalRecordIndicator";
public static final String PROPERTIES_REVIEW_PERIOD = "rma:reviewPeriod";
public static final String PROPERTIES_OWNER = "cm:owner";
public static final String PROPERTIES_AUTHOR="cm:author";
/** Common properties for record folders and records */
public static final String PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE = "rma:recordSearchHasDispositionSchedule";

View File

@@ -27,6 +27,7 @@
package org.alfresco.rest.rm.community.model.record;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_AUTHOR;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_BOX;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DATE_FILED;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DATE_TIME_ORIGINAL;
@@ -62,6 +63,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_ORIGINATING_USER_ID;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_ORIGINATING_CREATION_DATE;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.rm.community.model.common.Owner;
@@ -84,6 +86,7 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class RecordProperties extends TestModel
{
/*************************/
@@ -196,4 +199,7 @@ public class RecordProperties extends TestModel
@JsonProperty (PROPERTIES_OWNER)
private Owner owner;
@JsonProperty(PROPERTIES_AUTHOR)
private String author;
}

View File

@@ -130,7 +130,7 @@ public class RecordCategoryChildProperties extends TestModel
private Boolean recordSearchDispositionEventsEligible;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS)
private String recordSearchDispositionInstructions;
private String recordSearchDispositionInstructions;
@JsonProperty (PROPERTIES_OWNER)
private Owner owner;

View File

@@ -29,12 +29,11 @@ package org.alfresco.rest.rm.community.model.transfer;
import java.util.List;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.utility.model.TestModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

View File

@@ -29,12 +29,11 @@ package org.alfresco.rest.rm.community.model.transfercontainer;
import java.util.List;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.rest.rm.community.model.common.Path;
import org.alfresco.utility.model.TestModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.model.RestByUserModel;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

View File

@@ -57,13 +57,11 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_X_RESOLUTION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_Y_RESOLUTION;
import org.alfresco.rest.rm.community.model.common.Owner;
import org.alfresco.rest.rm.community.model.common.ReviewPeriod;
import org.alfresco.rest.rm.community.util.ReviewPeriodSerializer;
import org.alfresco.utility.model.TestModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.rm.community.model.common.Owner;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -155,7 +153,7 @@ public class UnfiledContainerChildProperties extends TestModel
@JsonProperty (PROPERTIES_Y_RESOLUTION)
private Double yResolution;
@JsonProperty (PROPERTIES_ORIGINAL_NAME)
private String originalName;

View File

@@ -27,15 +27,12 @@
package org.alfresco.rest.rm.community.model.unfiledcontainer;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_IDENTIFIER;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_OWNER;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_ROOT_NODE_REF;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import org.alfresco.rest.rm.community.model.common.Owner;
import org.alfresco.utility.model.TestModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.utility.model.TestModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

View File

@@ -41,19 +41,18 @@ import static org.testng.Assert.fail;
import java.io.File;
import java.util.Iterator;
import org.alfresco.rest.core.RMRestWrapper;
import org.alfresco.rest.rm.community.model.record.Record;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainer;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildCollection;
import org.alfresco.rest.rm.community.requests.RMModelRequest;
import org.alfresco.rest.rm.community.util.FilePlanComponentMixIn;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.restassured.builder.RequestSpecBuilder;
import com.jayway.restassured.http.ContentType;
import org.alfresco.rest.core.RMRestWrapper;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainer;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildCollection;
import org.alfresco.rest.rm.community.requests.RMModelRequest;
import org.alfresco.rest.rm.community.util.UnfiledContainerChildMixin;
/**
* Unfiled Container REST API Wrapper
*
@@ -209,7 +208,7 @@ public class UnfiledContainerAPI extends RMModelRequest
* to the request.
*/
RequestSpecBuilder builder = getRmRestWrapper().configureRequestSpec();
JsonNode root = new ObjectMapper().readTree(toJson(unfiledContainerChildModel, Record.class, FilePlanComponentMixIn.class));
JsonNode root = new ObjectMapper().readTree(toJson(unfiledContainerChildModel, UnfiledContainerChild.class, UnfiledContainerChildMixin.class));
// add request fields
Iterator<String> fieldNames = root.fieldNames();
while (fieldNames.hasNext())

View File

@@ -42,19 +42,18 @@ import static org.testng.Assert.fail;
import java.io.File;
import java.util.Iterator;
import org.alfresco.rest.core.RMRestWrapper;
import org.alfresco.rest.rm.community.model.record.Record;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildCollection;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledRecordFolder;
import org.alfresco.rest.rm.community.requests.RMModelRequest;
import org.alfresco.rest.rm.community.util.FilePlanComponentMixIn;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.restassured.builder.RequestSpecBuilder;
import com.jayway.restassured.http.ContentType;
import org.alfresco.rest.core.RMRestWrapper;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildCollection;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledRecordFolder;
import org.alfresco.rest.rm.community.requests.RMModelRequest;
import org.alfresco.rest.rm.community.util.UnfiledContainerChildMixin;
/**
* Unfiled Record Folders REST API Wrapper
*
@@ -209,7 +208,7 @@ public class UnfiledRecordFolderAPI extends RMModelRequest
* to the request.
*/
RequestSpecBuilder builder = getRmRestWrapper().configureRequestSpec();
JsonNode root = new ObjectMapper().readTree(toJson(unfiledRecordFolderChildModel, Record.class, FilePlanComponentMixIn.class));
JsonNode root = new ObjectMapper().readTree(toJson(unfiledRecordFolderChildModel, UnfiledContainerChild.class, UnfiledContainerChildMixin.class));
// add request fields
Iterator<String> fieldNames = root.fieldNames();
while (fieldNames.hasNext())

View File

@@ -0,0 +1,49 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2017 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.community.util;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties;
/**
* Mix class for Record POJO class
* Mix-in annotations are: a way to associate annotations with classes
* without modifying (target) classes themselves.
*
* @author Tuna Aksoy
* @since 2.6
*/
public abstract class UnfiledContainerChildMixin
{
/**
* Annotation used to indicate that a property should be serialized "unwrapped"
* Its properties are instead included as properties of its containing Object
*/
@JsonUnwrapped
abstract UnfiledContainerChildProperties getProperties();
}

View File

@@ -54,7 +54,6 @@ import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
/**
@@ -77,8 +76,6 @@ public class RMRolesAndActionsAPI extends BaseAPI
@Autowired
private AlfrescoHttpClientFactory alfrescoHttpClientFactory;
private ApplicationContext applicationContext;
/** user service */
@Autowired
private UserService userService;

View File

@@ -28,6 +28,7 @@ package org.alfresco.rest.rm.community.base;
import static lombok.AccessLevel.PROTECTED;
import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME;
import static org.alfresco.rest.rm.community.base.TestData.RECORD_CATEGORY_TITLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
@@ -35,10 +36,11 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_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_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryChildModel;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryModel;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createUnfiledContainerChildModel;
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.createStandardRMSiteModel;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
@@ -52,6 +54,7 @@ import java.util.List;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.core.RestAPIFactory;
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
import org.alfresco.rest.rm.community.model.record.Record;
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
@@ -334,8 +337,17 @@ public class BaseRMRestTest extends RestTest
*/
public UnfiledContainerChild createUnfiledContainerChild(UserModel user, String parentId, String childName, String nodeType) throws Exception
{
UnfiledContainerChild child = null;
UnfiledContainerChild childModel = createUnfiledContainerChildModel(childName, nodeType);
UnfiledContainerChild child = getRestAPIFactory().getUnfiledContainersAPI(user).createUnfiledContainerChild(childModel, parentId);
if (FilePlanComponentType.CONTENT_TYPE.equals(nodeType))
{
child = getRestAPIFactory().getUnfiledContainersAPI(user).uploadRecord(childModel, parentId, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME));
}
else
{
child = getRestAPIFactory().getUnfiledContainersAPI(user).createUnfiledContainerChild(childModel, parentId);
}
assertStatusCode(CREATED);
return child;

View File

@@ -159,6 +159,22 @@ public interface TestData
};
}
/**
* Data Provider with:
* with the object types for creating a Record Category Child
*
* @return record category child type
*/
@DataProvider
public static Object[][] categoryChild()
{
return new String[][] {
{ RECORD_FOLDER_TYPE },
{ FOLDER_TYPE },
{ RECORD_CATEGORY_TYPE }
};
}
/**
* Invalid root level types, at unfiled record folder/unfiled containers container level that shouldn't be possible to create
*/
@@ -171,7 +187,9 @@ public interface TestData
{ RECORD_CATEGORY_TYPE },
{ RECORD_FOLDER_TYPE },
{ TRANSFER_CONTAINER_TYPE },
{ UNFILED_CONTAINER_TYPE }
{ TRANSFER_TYPE },
{ UNFILED_CONTAINER_TYPE },
};
}
}

View File

@@ -45,12 +45,14 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING;
import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_MANAGER;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import static org.springframework.http.HttpStatus.CONFLICT;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.FORBIDDEN;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.OK;
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
@@ -322,6 +324,56 @@ public class FilePlanTests extends BaseRMRestTest
assertNotNull(rootRecordCategoryProperties.getIdentifier());
}
/**
* <pre>
* Given a root category
* When I ask the API to create a root category having the same name
* Then the response code received is 409 - name clashes with an existing node
*</pre>
* <pre>
* Given a root category
* When I ask the API to create a root category having the same name with autoRename parameter on true
* Then the record category is created the record category has a unique name by adding an integer suffix
* </pre>
*/
@Test
@Bug(id = "RM-5116")
public void createDuplicateCategories() throws Exception
{
String categoryName = "Category name " + getRandomAlphanumeric();
String categoryTitle = "Category title " + getRandomAlphanumeric();
// Create the root record category
RecordCategory recordCategory = RecordCategory.builder()
.name(categoryName)
.properties(RecordCategoryProperties.builder()
.title(categoryTitle)
.build())
.build();
// Create the root record category
RecordCategory rootRecordCategory = getRestAPIFactory().getFilePlansAPI().createRootRecordCategory(recordCategory,FILE_PLAN_ALIAS);
// Verify the status code
assertStatusCode(CREATED);
assertEquals(rootRecordCategory.getName(), categoryName);
// Create the same root record category
getRestAPIFactory().getFilePlansAPI().createRootRecordCategory(recordCategory, FILE_PLAN_ALIAS);
// Verify the status code
assertStatusCode(CONFLICT);
//create the same category with autoRename parameter on true
RecordCategory rootRecordCategoryAutoRename = getRestAPIFactory().getFilePlansAPI()
.createRootRecordCategory(recordCategory, FILE_PLAN_ALIAS,"autoRename=true");
// Verify the status code
assertStatusCode(CREATED);
assertNotEquals(rootRecordCategoryAutoRename.getName(), categoryName);
assertTrue(rootRecordCategoryAutoRename.getName().startsWith(categoryName));
}
@Test
public void listFilePlanChildren() throws Exception
{

View File

@@ -38,8 +38,10 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.TITLE_PREFIX;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryChildModel;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.CONFLICT;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.NO_CONTENT;
@@ -47,11 +49,13 @@ import static org.springframework.http.HttpStatus.OK;
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;
@@ -66,7 +70,10 @@ import org.alfresco.rest.rm.community.model.recordfolder.RecordFolder;
import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
import org.alfresco.rest.v0.RecordCategoriesAPI;
import org.alfresco.rest.core.v0.BaseAPI.RETENTION_SCHEDULE;
import org.alfresco.utility.report.Bug;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -83,6 +90,9 @@ public class RecordCategoryTests extends BaseRMRestTest
private static final int NUMBER_OF_CHILDREN = 10;
private static final int NUMBER_OF_FOLDERS = 5;
@Autowired
private RecordCategoriesAPI recordCategoriesAPI;
/**
* Invalid containers that cannot be deleted with record category end-point
*/
@@ -287,6 +297,43 @@ public class RecordCategoryTests extends BaseRMRestTest
assertEquals(folderProperties.getTitle(), TITLE_PREFIX + RECORD_FOLDER_NAME);
assertNotNull(folderProperties.getIdentifier());
}
@Test
(
dataProviderClass = TestData.class,
dataProvider = "categoryChild"
)
@Bug(id = "RM-5116")
public void createdDuplicateChild(String childType)throws Exception
{
// create a root category
String rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric()).getId();
// Create the record category child
RecordCategoryChild recordFolder = createRecordCategoryChild(rootRecordCategory, RECORD_FOLDER_NAME, childType);
// check the response code
assertStatusCode(CREATED);
assertEquals(recordFolder.getName(), RECORD_FOLDER_NAME);
// Create a record category child with the same name as the exiting one
RecordCategoryChild recordFolderDuplicate = getRestAPIFactory().getRecordCategoryAPI().createRecordCategoryChild(
createRecordCategoryChildModel(RECORD_FOLDER_NAME, childType), rootRecordCategory);
// check the response code
assertStatusCode(CONFLICT);
// Create a record folder with the same name as the exiting one and with the autoRename parameter on true
recordFolderDuplicate = getRestAPIFactory().getRecordCategoryAPI()
.createRecordCategoryChild(createRecordCategoryChildModel(RECORD_FOLDER_NAME,
childType),
rootRecordCategory, "autoRename=true");
// check the response code
assertStatusCode(CREATED);
assertNotEquals(recordFolderDuplicate.getName(), RECORD_FOLDER_NAME);
assertTrue(recordFolderDuplicate.getName().contains(RECORD_FOLDER_NAME));
}
/**
* <pre>
* Given that a record category exists
@@ -294,17 +341,37 @@ public class RecordCategoryTests extends BaseRMRestTest
* When I ask the API to get me the children of the record category
* Then I am returned the contained record categories and record folders and their details
* </pre>
* <pre>
* Given that a record category with a disposition schedule exists
* And contains a number of record categories and record folders
* When I ask the API to get me the children of the record category
* Then I am returned the contained record categories and record folders but not the disposition schedule
* </pre>
*/
@Test
(
description = "Get children of a record category"
)
(
description = "Get children of a record category excluding the disposition schedule"
)
@Bug (id="RM-5115")
public void getRecordCategoryChildren() throws Exception
{
// Create root level category
RecordCategory rootRecordCategory = createRootCategory(getRandomAlphanumeric());
assertNotNull(rootRecordCategory.getId());
// Create disposition schedule
String userName = getAdminUser().getUsername();
String userPassword = getAdminUser().getPassword();
String categoryName = rootRecordCategory.getName();
recordCategoriesAPI.createRetentionSchedule(userName, userPassword, categoryName);
// Add disposition schedule cut off step
HashMap<RETENTION_SCHEDULE, String> cutOffStep = new HashMap<>();
cutOffStep.put(RETENTION_SCHEDULE.NAME, "cutoff");
cutOffStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, "day|2");
cutOffStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Cut off after 2 days");
recordCategoriesAPI.addDispositionScheduleSteps(userName, userPassword, categoryName, cutOffStep);
// Add record category children
List<RecordCategoryChild> children = new ArrayList<RecordCategoryChild>();
for (int i=0; i < NUMBER_OF_CHILDREN; i++)

View File

@@ -34,6 +34,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.IS_CLOSED;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.FILE_PLAN_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.FOLDER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
@@ -105,7 +106,8 @@ public class RecordFolderTests extends BaseRMRestTest
{ UNFILED_CONTAINER_TYPE },
{ UNFILED_RECORD_FOLDER_TYPE },
{ TRANSFER_TYPE },
{ RECORD_CATEGORY_TYPE }
{ RECORD_CATEGORY_TYPE },
{ FOLDER_TYPE }
};
}
@@ -370,9 +372,6 @@ public class RecordFolderTests extends BaseRMRestTest
// Make a request to close the record folder
RecordFolder updatedRecordFolder = recordFolderAPI.updateRecordFolder(recordFolderModel, recordFolder.getId());
//FIXME - remove this workaround after RM-4921 is fixed.
updatedRecordFolder = recordFolderAPI.getRecordFolder(updatedRecordFolder.getId());
// Verify that the record folder is closed now
assertTrue(updatedRecordFolder.getProperties().getIsClosed());
@@ -386,9 +385,6 @@ public class RecordFolderTests extends BaseRMRestTest
// Make a request to reopen the record folder
updatedRecordFolder = recordFolderAPI.updateRecordFolder(recordFolderModel, recordFolder.getId());
//FIXME - remove this workaround after RM-4921 is fixed.
updatedRecordFolder = recordFolderAPI.getRecordFolder(updatedRecordFolder.getId());
// Verify that the record folder is open now
assertFalse(updatedRecordFolder.getProperties().getIsClosed());
}

View File

@@ -38,10 +38,13 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createUnfiledContainerChildModel;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.CONFLICT;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.OK;
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
@@ -61,6 +64,7 @@ import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledRecordFolder
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
import org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil;
import org.springframework.http.HttpStatus;
import org.alfresco.utility.report.Bug;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.DataProvider;
@@ -165,7 +169,7 @@ public class UnfiledContainerTests extends BaseRMRestTest
public void createUnfiledRecordFolderChild(String folderType) throws Exception
{
String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric();
UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, unfiledRecordFolderName, UNFILED_RECORD_FOLDER_TYPE);
UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, unfiledRecordFolderName, folderType);
assertNotNull(unfiledRecordFolderChild.getId());
@@ -186,7 +190,40 @@ public class UnfiledContainerTests extends BaseRMRestTest
assertEquals(unfiledRecordFolder.getParentId(),
getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS).getId());
}
@Test
( description = "Create duplicate unfiled folder child",
dataProvider = "unfiledFolderTypes"
)
@Bug(id ="RM-5116, RM-5148")
public void createDuplicateUnfiledFolderChild(String folderType) throws Exception
{
String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric();
UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS,
unfiledRecordFolderName, folderType);
// Verify the status code
assertStatusCode(CREATED);
assertEquals(unfiledRecordFolderChild.getName(), unfiledRecordFolderName);
// create the same unfiled folder
UnfiledContainerChild unfiledRecordFolderDuplicate = getRestAPIFactory().getUnfiledContainersAPI()
.createUnfiledContainerChild(createUnfiledContainerChildModel(unfiledRecordFolderName, folderType),
UNFILED_RECORDS_CONTAINER_ALIAS);
// Verify the status code
assertStatusCode(CONFLICT);
// create the same unfiled folder with the autoRename parameter on true
unfiledRecordFolderDuplicate = getRestAPIFactory().getUnfiledContainersAPI()
.createUnfiledContainerChild(createUnfiledContainerChildModel(unfiledRecordFolderName, folderType),UNFILED_RECORDS_CONTAINER_ALIAS,"autoRename=true");
//verify the response status code
assertStatusCode(CREATED);
assertNotEquals(unfiledRecordFolderDuplicate.getName(), unfiledRecordFolderName);
assertTrue(unfiledRecordFolderDuplicate.getName().startsWith(unfiledRecordFolderName));
}
/**
* <pre>
* Given that an unfiled records container exists
@@ -396,7 +433,8 @@ public class UnfiledContainerTests extends BaseRMRestTest
try
{
getRestAPIFactory().getUnfiledContainersAPI().createUnfiledContainerChild(unfiledFolderModel, UNFILED_RECORDS_CONTAINER_ALIAS);
} catch (Exception error)
}
catch (Exception error)
{
}
// Verify the status code

View File

@@ -487,8 +487,10 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
assertTrue(record.getName().equals(createdComponent.getName()),
"The record name "+ record.getName()+" is not equal with the record name returned when creating the record " + createdComponent
.getName());
assertTrue(record.getName().contains(record.getProperties().getIdentifier()));
String identifier = " \\(" + record.getProperties().getIdentifier() + "\\)";
String regex= "(" + NONELECTRONIC_RECORD_NAME + "|" + ELECTRONIC_RECORD_NAME + ")" + "[0-9]+" + identifier;
assertTrue(record.getName().matches(regex),
"The record name:" + record.getName() + " doesn't match the expression " + regex);
assertTrue(createdComponent.getName().contains(createdComponent.getProperties().getIdentifier()));
assertEquals(createdComponent.getNodeType(), record.getNodeType());