mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
additional checks to cover the issue RM-4572
This commit is contained in:
@@ -107,7 +107,7 @@ public class FilePlanComponentProperties
|
|||||||
|
|
||||||
@JsonProperty(value = PROPERTIES_PHYSICAL_SIZE, required = false)
|
@JsonProperty(value = PROPERTIES_PHYSICAL_SIZE, required = false)
|
||||||
private Integer physicalSize;
|
private Integer physicalSize;
|
||||||
|
|
||||||
@JsonProperty(value = PROPERTIES_RECORD_ID, required = false)
|
@JsonProperty(value = PROPERTIES_RECORD_ID, required = false)
|
||||||
private String recordId;
|
private String rmIdentifier;
|
||||||
}
|
}
|
||||||
|
@@ -32,8 +32,10 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
|||||||
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.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.FILE_PLAN_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.HOLD_CONTAINER_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.HOLD_CONTAINER_TYPE;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.HOLD_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.HOLD_TYPE;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.TRANSFER_CONTAINER_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.TRANSFER_CONTAINER_TYPE;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.TRANSFER_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.TRANSFER_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_CONTAINER_TYPE;
|
||||||
@@ -122,12 +124,12 @@ public interface TestData
|
|||||||
* The default electronic record name used when creating electronic records
|
* The default electronic record name used when creating electronic records
|
||||||
*/
|
*/
|
||||||
public static String ELECTRONIC_RECORD_NAME = "Record electronic" + getRandomAlphanumeric();
|
public static String ELECTRONIC_RECORD_NAME = "Record electronic" + getRandomAlphanumeric();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default Non electronic record name used when creating non-electronic records
|
* The default Non electronic record name used when creating non-electronic records
|
||||||
*/
|
*/
|
||||||
public static String NONELECTRONIC_RECORD_NAME = "Record nonelectronic" + getRandomAlphanumeric();
|
public static String NONELECTRONIC_RECORD_NAME = "Record nonelectronic" + getRandomAlphanumeric();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data Provider with:
|
* Data Provider with:
|
||||||
* with the object types not allowed as children for a record category
|
* with the object types not allowed as children for a record category
|
||||||
@@ -148,4 +150,19 @@ public interface TestData
|
|||||||
{ CONTENT_TYPE }
|
{ CONTENT_TYPE }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data Provider with:
|
||||||
|
* with the object types for creating a Record Folder
|
||||||
|
*
|
||||||
|
* @return file plan component alias
|
||||||
|
*/
|
||||||
|
@DataProvider
|
||||||
|
public static Object[][] folderTypes()
|
||||||
|
{
|
||||||
|
return new Object[][] {
|
||||||
|
{RECORD_FOLDER_TYPE},
|
||||||
|
{FOLDER_TYPE}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -221,6 +221,7 @@ public class ElectronicRecordTests extends BaseRMRestTest
|
|||||||
// created record will have record identifier inserted in its name but will be prefixed with
|
// created record will have record identifier inserted in its name but will be prefixed with
|
||||||
// the name it was created as
|
// the name it was created as
|
||||||
assertTrue(electronicRecord.getName().startsWith(record.getName()));
|
assertTrue(electronicRecord.getName().startsWith(record.getName()));
|
||||||
|
assertTrue(electronicRecord.getName().contains(electronicRecord.getProperties().getRmIdentifier()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -252,6 +253,7 @@ public class ElectronicRecordTests extends BaseRMRestTest
|
|||||||
// record will have record identifier inserted in its name but will for sure start with file name
|
// record will have record identifier inserted in its name but will for sure start with file name
|
||||||
// and end with its extension
|
// and end with its extension
|
||||||
assertTrue(electronicRecord.getName().startsWith(IMAGE_FILE.substring(0, IMAGE_FILE.indexOf("."))));
|
assertTrue(electronicRecord.getName().startsWith(IMAGE_FILE.substring(0, IMAGE_FILE.indexOf("."))));
|
||||||
|
assertTrue(electronicRecord.getName().contains(electronicRecord.getProperties().getRmIdentifier()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -44,6 +44,7 @@ import static org.springframework.http.HttpStatus.FORBIDDEN;
|
|||||||
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
|
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertFalse;
|
import static org.testng.Assert.assertFalse;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@@ -142,6 +143,7 @@ public class NonElectronicRecordTests extends BaseRMRestTest
|
|||||||
String file = "File " + getRandomAlphanumeric();
|
String file = "File " + getRandomAlphanumeric();
|
||||||
String shelf = "Shelf " + getRandomAlphanumeric();
|
String shelf = "Shelf " + getRandomAlphanumeric();
|
||||||
String location = "Location " + getRandomAlphanumeric();
|
String location = "Location " + getRandomAlphanumeric();
|
||||||
|
String name = "Record " + getRandomAlphanumeric();
|
||||||
|
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
Integer copies = random.nextInt(Integer.MAX_VALUE);
|
Integer copies = random.nextInt(Integer.MAX_VALUE);
|
||||||
@@ -149,7 +151,7 @@ public class NonElectronicRecordTests extends BaseRMRestTest
|
|||||||
|
|
||||||
// set values of all available properties for the non electronic records
|
// set values of all available properties for the non electronic records
|
||||||
FilePlanComponent filePlanComponent = FilePlanComponent.builder()
|
FilePlanComponent filePlanComponent = FilePlanComponent.builder()
|
||||||
.name("Record " + getRandomAlphanumeric())
|
.name(name)
|
||||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
||||||
.properties(FilePlanComponentProperties.builder()
|
.properties(FilePlanComponentProperties.builder()
|
||||||
.title(title)
|
.title(title)
|
||||||
@@ -183,6 +185,8 @@ public class NonElectronicRecordTests extends BaseRMRestTest
|
|||||||
assertEquals(location, nonElectronicRecord.getProperties().getLocation());
|
assertEquals(location, nonElectronicRecord.getProperties().getLocation());
|
||||||
assertEquals(copies, nonElectronicRecord.getProperties().getNumberOfCopies());
|
assertEquals(copies, nonElectronicRecord.getProperties().getNumberOfCopies());
|
||||||
assertEquals(size, nonElectronicRecord.getProperties().getPhysicalSize());
|
assertEquals(size, nonElectronicRecord.getProperties().getPhysicalSize());
|
||||||
|
assertTrue(nonElectronicRecord.getName().contains(nonElectronicRecord.getProperties().getRmIdentifier()));
|
||||||
|
assertTrue(nonElectronicRecord.getName().contains(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -85,7 +85,7 @@ public class ReadRecordTests extends BaseRMRestTest
|
|||||||
.nodeType(CONTENT_TYPE.toString())
|
.nodeType(CONTENT_TYPE.toString())
|
||||||
.content(FilePlanComponentContent.builder().mimeType("text/plain").build())
|
.content(FilePlanComponentContent.builder().mimeType("text/plain").build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
private FilePlanComponent nonelectronicRecord = FilePlanComponent.builder()
|
private FilePlanComponent nonelectronicRecord = FilePlanComponent.builder()
|
||||||
.properties(FilePlanComponentProperties.builder()
|
.properties(FilePlanComponentProperties.builder()
|
||||||
.description(NONELECTRONIC_RECORD_NAME)
|
.description(NONELECTRONIC_RECORD_NAME)
|
||||||
@@ -178,6 +178,8 @@ public class ReadRecordTests extends BaseRMRestTest
|
|||||||
assertNotNull(recordWithContent.getContent().getEncoding());
|
assertNotNull(recordWithContent.getContent().getEncoding());
|
||||||
assertNotNull(recordWithContent.getContent().getMimeType());
|
assertNotNull(recordWithContent.getContent().getMimeType());
|
||||||
assertNotNull(recordWithContent.getAspectNames());
|
assertNotNull(recordWithContent.getAspectNames());
|
||||||
|
assertFalse(recordWithContent.getName().equals(ELECTRONIC_RECORD_NAME));
|
||||||
|
assertTrue(recordWithContent.getName().contains(recordWithContent.getProperties().getRmIdentifier()));
|
||||||
assertStatusCode(OK);
|
assertStatusCode(OK);
|
||||||
|
|
||||||
//create non-electronic record
|
//create non-electronic record
|
||||||
@@ -196,6 +198,8 @@ public class ReadRecordTests extends BaseRMRestTest
|
|||||||
assertNotNull(nonElectronicRecord.getContent().getMimeType());
|
assertNotNull(nonElectronicRecord.getContent().getMimeType());
|
||||||
assertNotNull(nonElectronicRecord.getAspectNames());
|
assertNotNull(nonElectronicRecord.getAspectNames());
|
||||||
assertEquals(nonElectronicRecord.getProperties().getDescription(), NONELECTRONIC_RECORD_NAME);
|
assertEquals(nonElectronicRecord.getProperties().getDescription(), NONELECTRONIC_RECORD_NAME);
|
||||||
|
assertFalse(nonElectronicRecord.getName().equals(NONELECTRONIC_RECORD_NAME));
|
||||||
|
assertTrue(nonElectronicRecord.getName().contains(nonElectronicRecord.getProperties().getRmIdentifier()));
|
||||||
assertStatusCode(OK);
|
assertStatusCode(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,11 +213,11 @@ public class ReadRecordTests extends BaseRMRestTest
|
|||||||
{
|
{
|
||||||
FilePlanComponentAPI filePlanComponentAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
FilePlanComponentAPI filePlanComponentAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||||
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||||
|
|
||||||
String RECORD_ELECTRONIC = "Record " + getRandomAlphanumeric();
|
String RECORD_ELECTRONIC = "Record " + getRandomAlphanumeric();
|
||||||
String RECORD_ELECTRONIC_BINARY = "Binary Record" + getRandomAlphanumeric();
|
String RECORD_ELECTRONIC_BINARY = "Binary Record" + getRandomAlphanumeric();
|
||||||
String RELATIVE_PATH = "/" + CATEGORY_NAME + getRandomAlphanumeric() + "/folder";
|
String RELATIVE_PATH = "/" + CATEGORY_NAME + getRandomAlphanumeric() + "/folder";
|
||||||
|
|
||||||
// create the containers from the relativePath
|
// create the containers from the relativePath
|
||||||
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
||||||
.name(FOLDER_NAME)
|
.name(FOLDER_NAME)
|
||||||
@@ -221,7 +225,7 @@ public class ReadRecordTests extends BaseRMRestTest
|
|||||||
.relativePath(RELATIVE_PATH)
|
.relativePath(RELATIVE_PATH)
|
||||||
.build();
|
.build();
|
||||||
String folderId = filePlanComponentAPI.createFilePlanComponent(recordFolder, FILE_PLAN_ALIAS).getId();
|
String folderId = filePlanComponentAPI.createFilePlanComponent(recordFolder, FILE_PLAN_ALIAS).getId();
|
||||||
|
|
||||||
// text file as an electronic record
|
// text file as an electronic record
|
||||||
FilePlanComponent recordText = FilePlanComponent.builder()
|
FilePlanComponent recordText = FilePlanComponent.builder()
|
||||||
.name(RECORD_ELECTRONIC)
|
.name(RECORD_ELECTRONIC)
|
||||||
@@ -237,19 +241,19 @@ public class ReadRecordTests extends BaseRMRestTest
|
|||||||
.name(RECORD_ELECTRONIC_BINARY)
|
.name(RECORD_ELECTRONIC_BINARY)
|
||||||
.nodeType(CONTENT_TYPE)
|
.nodeType(CONTENT_TYPE)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
String binaryRecordId = filePlanComponentAPI.createElectronicRecord(recordBinary, IMAGE_FILE, folderId).getId();
|
String binaryRecordId = filePlanComponentAPI.createElectronicRecord(recordBinary, IMAGE_FILE, folderId).getId();
|
||||||
// binary content, therefore compare respective SHA1 checksums in order to verify this is identical content
|
// binary content, therefore compare respective SHA1 checksums in order to verify this is identical content
|
||||||
try
|
try
|
||||||
(
|
(
|
||||||
InputStream recordContentStream = recordsAPI.getRecordContent(binaryRecordId).asInputStream();
|
InputStream recordContentStream = recordsAPI.getRecordContent(binaryRecordId).asInputStream();
|
||||||
FileInputStream localFileStream = new FileInputStream(new File(Resources.getResource(IMAGE_FILE).getFile()));
|
FileInputStream localFileStream = new FileInputStream(new File(Resources.getResource(IMAGE_FILE).getFile()));
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
assertEquals(DigestUtils.sha1(recordContentStream), DigestUtils.sha1(localFileStream));
|
assertEquals(DigestUtils.sha1(recordContentStream), DigestUtils.sha1(localFileStream));
|
||||||
}
|
}
|
||||||
assertStatusCode(OK);
|
assertStatusCode(OK);
|
||||||
|
|
||||||
// electronic record with no content
|
// electronic record with no content
|
||||||
FilePlanComponent recordNoContent = FilePlanComponent.builder()
|
FilePlanComponent recordNoContent = FilePlanComponent.builder()
|
||||||
.name(RECORD_ELECTRONIC)
|
.name(RECORD_ELECTRONIC)
|
||||||
@@ -390,8 +394,9 @@ public class ReadRecordTests extends BaseRMRestTest
|
|||||||
assertFalse(filePlanComponent.getIsRecordFolder());
|
assertFalse(filePlanComponent.getIsRecordFolder());
|
||||||
assertFalse(filePlanComponent.getIsCategory());
|
assertFalse(filePlanComponent.getIsCategory());
|
||||||
|
|
||||||
//assertEquals(createdComponent.getName(), filePlanComponent.getName());
|
//check the record name
|
||||||
assertTrue(filePlanComponent.getName().startsWith(createdComponent.getName()));
|
assertTrue(filePlanComponent.getName().equals(createdComponent.getName()));
|
||||||
|
assertTrue(createdComponent.getName().contains(createdComponent.getProperties().getRmIdentifier()));
|
||||||
assertEquals(createdComponent.getNodeType(), filePlanComponent.getNodeType());
|
assertEquals(createdComponent.getNodeType(), filePlanComponent.getNodeType());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -316,6 +316,7 @@ public class RecordCategoryTest extends BaseRMRestTest
|
|||||||
|
|
||||||
// Verify properties
|
// Verify properties
|
||||||
// FIXME: Verify properties
|
// FIXME: Verify properties
|
||||||
|
assertNotNull(createdComponent.getProperties().getRmIdentifier());
|
||||||
}
|
}
|
||||||
catch (NoSuchElementException e)
|
catch (NoSuchElementException e)
|
||||||
{
|
{
|
||||||
@@ -336,7 +337,7 @@ public class RecordCategoryTest extends BaseRMRestTest
|
|||||||
dataProvider = "childrenNotAllowedForCategory"
|
dataProvider = "childrenNotAllowedForCategory"
|
||||||
|
|
||||||
)
|
)
|
||||||
@Bug (id="RM-4367")
|
@Bug (id="RM-4367, RM-4572")
|
||||||
public void createTypesNotAllowedInCategory(String nodeType) throws Exception
|
public void createTypesNotAllowedInCategory(String nodeType) throws Exception
|
||||||
{
|
{
|
||||||
String COMPONENT_NAME = "Component"+getRandomAlphanumeric();
|
String COMPONENT_NAME = "Component"+getRandomAlphanumeric();
|
||||||
|
@@ -74,12 +74,21 @@ public class RecordFolderTests extends BaseRMRestTest
|
|||||||
* Given that a record category exists
|
* Given that a record category exists
|
||||||
* When I use the API to create a new record folder
|
* When I use the API to create a new record folder
|
||||||
* Then it is created within the record category
|
* Then it is created within the record category
|
||||||
|
*
|
||||||
|
* Given that a record category exists
|
||||||
|
* When I use the API to create a folder (cm:folder type)
|
||||||
|
* Then the folder is converted to rma:recordFolder within the record category
|
||||||
|
* (see RM-4572 comments)
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
(
|
(
|
||||||
description = "Create a folder into a record category"
|
description = "Create a folder into a record category.",
|
||||||
|
dataProviderClass = TestData.class,
|
||||||
|
dataProvider = "folderTypes"
|
||||||
)
|
)
|
||||||
public void createFolderTest() throws Exception
|
@Bug (id = "RM-4572")
|
||||||
|
public void createFolderTest(String folderType) throws Exception
|
||||||
{
|
{
|
||||||
String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
|
String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
|
||||||
|
|
||||||
@@ -88,7 +97,7 @@ public class RecordFolderTests extends BaseRMRestTest
|
|||||||
|
|
||||||
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
||||||
.name(FOLDER_NAME)
|
.name(FOLDER_NAME)
|
||||||
.nodeType(RECORD_FOLDER_TYPE)
|
.nodeType(folderType)
|
||||||
.properties(FilePlanComponentProperties.builder()
|
.properties(FilePlanComponentProperties.builder()
|
||||||
.title(FOLDER_TITLE)
|
.title(FOLDER_TITLE)
|
||||||
.build())
|
.build())
|
||||||
@@ -113,6 +122,7 @@ public class RecordFolderTests extends BaseRMRestTest
|
|||||||
// Verify the returned file plan component properties
|
// Verify the returned file plan component properties
|
||||||
FilePlanComponentProperties folderProperties = folder.getProperties();
|
FilePlanComponentProperties folderProperties = folder.getProperties();
|
||||||
assertEquals(folderProperties.getTitle(), FOLDER_TITLE);
|
assertEquals(folderProperties.getTitle(), FOLDER_TITLE);
|
||||||
|
assertNotNull(folderProperties.getRmIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user