Merge branch 'feature/RM-5116_TestsForAutoRename' into 'master'

Tests for RM-5116

See merge request !269
This commit is contained in:
Rodica Sutu
2017-05-15 06:49:59 +01:00
6 changed files with 151 additions and 2 deletions

View File

@@ -48,6 +48,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;
@@ -200,4 +201,7 @@ public class RecordProperties extends TestModel
@JsonProperty (PROPERTIES_OWNER)
private Owner owner;
@JsonProperty(PROPERTIES_AUTHOR)
private String author;
}

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
*/

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,6 +49,7 @@ 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;
@@ -294,6 +297,42 @@ 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>

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;
@@ -59,6 +62,7 @@ import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChi
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.alfresco.utility.report.Bug;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.DataProvider;
@@ -163,7 +167,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());
@@ -184,7 +188,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