mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-4396: Experiment using lombok to remove boiler plate code
This commit is contained in:
@@ -182,7 +182,13 @@ public class BaseRestTest extends RestTest
|
||||
{
|
||||
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
FilePlanComponent filePlanComponent=new FilePlanComponent(componentName, componentType.toString(),new FilePlanComponentProperties(componentTitle));
|
||||
FilePlanComponent filePlanComponent = FilePlanComponent.builder()
|
||||
.name(componentName)
|
||||
.nodeType(componentType.toString())
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(componentTitle)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
FilePlanComponent fpc = filePlanComponentAPI.createFilePlanComponent(filePlanComponent, parentComponentId);
|
||||
restWrapper.assertStatusCodeIs(CREATED);
|
||||
|
@@ -199,9 +199,12 @@ public class FilePlanTests extends BaseRestTest
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
|
||||
// Build object for updating the filePlan
|
||||
FilePlanComponent filePlanComponent= new FilePlanComponent();
|
||||
FilePlanComponentProperties filePlanComponentProperties=new FilePlanComponentProperties(FILE_PLAN_TITLE, FILE_PLAN_DESCRIPTION);
|
||||
filePlanComponent.setProperties(filePlanComponentProperties);
|
||||
FilePlanComponent filePlanComponent = FilePlanComponent.builder()
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(FILE_PLAN_TITLE)
|
||||
.description(FILE_PLAN_DESCRIPTION)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
// Update the record category
|
||||
FilePlanComponent renamedFilePlanComponent = filePlanComponentAPI.updateFilePlanComponent(filePlanComponent,FILE_PLAN_ALIAS.toString());
|
||||
@@ -301,7 +304,12 @@ public class FilePlanTests extends BaseRestTest
|
||||
String name = filePlanAlias + getRandomAlphanumeric();
|
||||
|
||||
// Build the file plan root properties
|
||||
FilePlanComponent filePlanComponent=new FilePlanComponent(name,rmType.toString(),new FilePlanComponentProperties());
|
||||
FilePlanComponent filePlanComponent = FilePlanComponent.builder()
|
||||
.name(name)
|
||||
.nodeType(rmType.toString())
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.build())
|
||||
.build();
|
||||
|
||||
// Authenticate with admin user
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
|
@@ -94,8 +94,15 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
||||
|
||||
// Build the record category properties
|
||||
FilePlanComponent recordCategory= new FilePlanComponent(categoryName,RECORD_CATEGORY_TYPE.toString(),
|
||||
new FilePlanComponentProperties(categoryTitle));
|
||||
FilePlanComponent recordCategory = FilePlanComponent.builder()
|
||||
.name(categoryName)
|
||||
.nodeType(RECORD_CATEGORY_TYPE.toString())
|
||||
.properties(
|
||||
FilePlanComponentProperties.builder()
|
||||
.title(categoryTitle)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
// Create the record category
|
||||
FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString());
|
||||
|
||||
@@ -103,9 +110,9 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
restWrapper.assertStatusCodeIs(CREATED);
|
||||
|
||||
// Verify the returned file plan component
|
||||
assertTrue(filePlanComponent.isIsCategory());
|
||||
assertFalse(filePlanComponent.isIsFile());
|
||||
assertFalse(filePlanComponent.isIsRecordFolder());
|
||||
assertTrue(filePlanComponent.getIsCategory());
|
||||
assertFalse(filePlanComponent.getIsFile());
|
||||
assertFalse(filePlanComponent.getIsRecordFolder());
|
||||
|
||||
assertEquals(filePlanComponent.getName(), categoryName);
|
||||
assertEquals(filePlanComponent.getNodeType(), RECORD_CATEGORY_TYPE.toString());
|
||||
@@ -139,8 +146,14 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
||||
|
||||
// Build the record category properties
|
||||
FilePlanComponent recordCategory = new FilePlanComponent(categoryName, RECORD_CATEGORY_TYPE.toString(),
|
||||
new FilePlanComponentProperties(categoryTitle));
|
||||
FilePlanComponent recordCategory = FilePlanComponent.builder()
|
||||
.name(categoryName)
|
||||
.nodeType(RECORD_CATEGORY_TYPE.toString())
|
||||
.properties(
|
||||
FilePlanComponentProperties.builder()
|
||||
.title(categoryTitle)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
// Create the record category
|
||||
FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString());
|
||||
@@ -148,7 +161,7 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
String newCategoryName = "Rename " + categoryName;
|
||||
|
||||
// Build the properties which will be updated
|
||||
FilePlanComponent recordCategoryUpdated = new FilePlanComponent(newCategoryName);
|
||||
FilePlanComponent recordCategoryUpdated = FilePlanComponent.builder().name(newCategoryName).build();
|
||||
|
||||
// Update the record category
|
||||
FilePlanComponent renamedFilePlanComponent = filePlanComponentAPI.updateFilePlanComponent(recordCategoryUpdated, filePlanComponent.getId());
|
||||
@@ -186,8 +199,15 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
||||
|
||||
// Build the record category properties
|
||||
FilePlanComponent recordCategory = new FilePlanComponent(categoryName, RECORD_CATEGORY_TYPE.toString(),
|
||||
new FilePlanComponentProperties(categoryTitle));
|
||||
FilePlanComponent recordCategory = FilePlanComponent.builder()
|
||||
.name(categoryName)
|
||||
.nodeType(RECORD_CATEGORY_TYPE.toString())
|
||||
.properties(
|
||||
FilePlanComponentProperties.builder()
|
||||
.title(categoryTitle)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
// Create the record category
|
||||
FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString());
|
||||
|
||||
@@ -226,9 +246,9 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
|
||||
// Verify child category
|
||||
assertEquals(childCategory.getParentId(), rootCategory.getId());
|
||||
assertTrue(childCategory.isIsCategory());
|
||||
assertFalse(childCategory.isIsFile());
|
||||
assertFalse(childCategory.isIsRecordFolder());
|
||||
assertTrue(childCategory.getIsCategory());
|
||||
assertFalse(childCategory.getIsFile());
|
||||
assertFalse(childCategory.getIsRecordFolder());
|
||||
assertEquals(childCategory.getNodeType(), RECORD_CATEGORY_TYPE.toString());
|
||||
}
|
||||
|
||||
@@ -295,19 +315,19 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
assertEquals(filePlanComponent.getParentId(), rootCategory.getId());
|
||||
|
||||
// Only categories or folders have been created
|
||||
assertFalse(filePlanComponent.isIsFile());
|
||||
assertFalse(filePlanComponent.getIsFile());
|
||||
|
||||
// Boolean properties related to node type
|
||||
// Only RECORD_CATEGORY_TYPE and RECORD_FOLDER_TYPE have been created
|
||||
if (filePlanComponent.getNodeType().equals(RECORD_CATEGORY_TYPE.toString()))
|
||||
{
|
||||
assertTrue(filePlanComponent.isIsCategory());
|
||||
assertFalse(filePlanComponent.isIsRecordFolder());
|
||||
assertTrue(filePlanComponent.getIsCategory());
|
||||
assertFalse(filePlanComponent.getIsRecordFolder());
|
||||
}
|
||||
else
|
||||
{
|
||||
assertTrue(filePlanComponent.isIsRecordFolder());
|
||||
assertFalse(filePlanComponent.isIsCategory());
|
||||
assertTrue(filePlanComponent.getIsRecordFolder());
|
||||
assertFalse(filePlanComponent.getIsCategory());
|
||||
}
|
||||
|
||||
// Does returned object have the same contents as the created one?
|
||||
@@ -348,8 +368,14 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), COMPONENT_NAME);
|
||||
|
||||
//Build node properties
|
||||
FilePlanComponent recordCategory = new FilePlanComponent(COMPONENT_NAME,nodeType,
|
||||
new FilePlanComponentProperties("Title for " + COMPONENT_NAME));
|
||||
FilePlanComponent recordCategory = FilePlanComponent.builder()
|
||||
.name(COMPONENT_NAME)
|
||||
.nodeType(nodeType)
|
||||
.properties(
|
||||
FilePlanComponentProperties.builder()
|
||||
.title("Title for " + COMPONENT_NAME)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
//create the invalid node type
|
||||
filePlanComponentAPI.createFilePlanComponent(recordCategory, category.getId());
|
||||
@@ -383,8 +409,14 @@ public class RecordCategoryTest extends BaseRestTest
|
||||
{
|
||||
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
//Build node properties
|
||||
FilePlanComponent component = new FilePlanComponent(componentName, componentType.toString(),
|
||||
new FilePlanComponentProperties("Title for " + componentName));
|
||||
FilePlanComponent component = FilePlanComponent.builder()
|
||||
.name(componentName)
|
||||
.nodeType(componentType.toString())
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title("Title for " + componentName)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
FilePlanComponent fpc = filePlanComponentAPI.createFilePlanComponent(component, parentComponentId);
|
||||
restWrapper.assertStatusCodeIs(CREATED);
|
||||
return fpc;
|
||||
|
@@ -93,8 +93,13 @@ public class RecordFolderTests extends BaseRestTest
|
||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||
FilePlanComponent filePlanComponent=createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY);
|
||||
|
||||
FilePlanComponentProperties filePlanComponentProperties = new FilePlanComponentProperties(FOLDER_TITLE);
|
||||
FilePlanComponent recordFolder = new FilePlanComponent(FOLDER_NAME,RECORD_FOLDER_TYPE.toString(), filePlanComponentProperties);
|
||||
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
||||
.name(FOLDER_NAME)
|
||||
.nodeType(RECORD_FOLDER_TYPE.toString())
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(FOLDER_TITLE)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
// Create the record folder
|
||||
FilePlanComponent folder = filePlanComponentAPI.createFilePlanComponent(recordFolder, filePlanComponent.getId());
|
||||
@@ -105,9 +110,9 @@ public class RecordFolderTests extends BaseRestTest
|
||||
// Check folder has been created within the category created
|
||||
assertEquals(filePlanComponent.getId(),folder.getParentId());
|
||||
// Verify the returned properties for the file plan component - record folder
|
||||
assertFalse(folder.isIsCategory());
|
||||
assertFalse(folder.isIsFile());
|
||||
assertTrue(folder.isIsRecordFolder());
|
||||
assertFalse(folder.getIsCategory());
|
||||
assertFalse(folder.getIsFile());
|
||||
assertTrue(folder.getIsRecordFolder());
|
||||
|
||||
assertEquals(folder.getName(), FOLDER_NAME);
|
||||
assertEquals(folder.getNodeType(), RECORD_FOLDER_TYPE.toString());
|
||||
@@ -138,8 +143,14 @@ public class RecordFolderTests extends BaseRestTest
|
||||
String componentID = filePlanComponentAPI.getFilePlanComponent(filePlanComponent).getId();
|
||||
|
||||
// Build the record category properties
|
||||
FilePlanComponent recordFolder= new FilePlanComponent(FOLDER_NAME,RECORD_FOLDER_TYPE.toString(),
|
||||
new FilePlanComponentProperties(FOLDER_TITLE));
|
||||
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
||||
.name(FOLDER_NAME)
|
||||
.nodeType(RECORD_FOLDER_TYPE.toString())
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(FOLDER_TITLE)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
// Create a record folder
|
||||
filePlanComponentAPI.createFilePlanComponent(recordFolder, componentID);
|
||||
|
||||
@@ -168,10 +179,10 @@ public class RecordFolderTests extends BaseRestTest
|
||||
|
||||
// Verify the returned properties for the file plan component - record folder
|
||||
assertEquals(RECORD_FOLDER_TYPE.toString(),folderDetails.getNodeType());
|
||||
assertTrue(folderDetails.isIsRecordFolder());
|
||||
assertFalse(folderDetails.isIsCategory());
|
||||
assertFalse(folderDetails.isIsFile());
|
||||
assertFalse(folderDetails.isClosed());
|
||||
assertTrue(folderDetails.getIsRecordFolder());
|
||||
assertFalse(folderDetails.getIsCategory());
|
||||
assertFalse(folderDetails.getIsFile());
|
||||
assertFalse(folderDetails.getIsClosed());
|
||||
|
||||
assertEquals(FOLDER_NAME,folderDetails.getName());
|
||||
assertEquals(dataUser.getAdminUser().getUsername(),folderDetails.getCreatedByUser().getId());
|
||||
@@ -210,11 +221,16 @@ public class RecordFolderTests extends BaseRestTest
|
||||
String location="Location"+getRandomAlphanumeric();
|
||||
|
||||
//Create the file plan component properties to update
|
||||
FilePlanComponentProperties filePlanComponentProperties= new FilePlanComponentProperties(folderTitle, folderDescription);
|
||||
filePlanComponentProperties.setVitalRecord(true);
|
||||
filePlanComponentProperties.setReviewPeriod( new ReviewPeriod("month","1"));
|
||||
filePlanComponentProperties.setLocation(location);
|
||||
FilePlanComponent recordFolder = new FilePlanComponent(folderName,filePlanComponentProperties);
|
||||
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
||||
.name(folderName)
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(folderTitle)
|
||||
.description(folderDescription)
|
||||
.vitalRecord(true)
|
||||
.reviewPeriod(new ReviewPeriod("month","1"))
|
||||
.location(location)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
// Update the record category
|
||||
FilePlanComponent folderUpdated = filePlanComponentAPI.updateFilePlanComponent(recordFolder, folder.getId());
|
||||
@@ -226,7 +242,7 @@ public class RecordFolderTests extends BaseRestTest
|
||||
assertEquals(folderName, folderUpdated.getName());
|
||||
assertEquals(folderDescription, folderUpdated.getProperties().getDescription());
|
||||
assertEquals(folderTitle, folderUpdated.getProperties().getTitle());
|
||||
assertTrue(folderUpdated.getProperties().isVitalRecord());
|
||||
assertTrue(folderUpdated.getProperties().getVitalRecord());
|
||||
assertEquals(location, folderUpdated.getProperties().getLocation());
|
||||
assertNotNull(folderUpdated.getProperties().getReviewPeriod().getPeriodType());
|
||||
assertNotNull(folderUpdated.getProperties().getReviewPeriod().getExpression());
|
||||
@@ -325,11 +341,11 @@ public class RecordFolderTests extends BaseRestTest
|
||||
|
||||
// Is parent Id set correctly
|
||||
assertEquals(filePlanComponent.getParentId(), category.getId());
|
||||
assertFalse(filePlanComponent.isIsFile());
|
||||
assertFalse(filePlanComponent.getIsFile());
|
||||
|
||||
// Boolean properties related to node type
|
||||
assertTrue(filePlanComponent.isIsRecordFolder());
|
||||
assertFalse(filePlanComponent.isIsCategory());
|
||||
assertTrue(filePlanComponent.getIsRecordFolder());
|
||||
assertFalse(filePlanComponent.getIsCategory());
|
||||
|
||||
assertEquals(createdComponent.getName(), filePlanComponent.getName());
|
||||
assertEquals(createdComponent.getNodeType(), filePlanComponent.getNodeType());
|
||||
|
@@ -107,8 +107,14 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
String folderDescription = folderName + " Description";
|
||||
|
||||
// Build unfiled records folder properties
|
||||
FilePlanComponent unfiledFolder=new FilePlanComponent(folderName,UNFILED_RECORD_FOLDER_TYPE.toString(),
|
||||
new FilePlanComponentProperties(folderTitle,folderDescription));
|
||||
FilePlanComponent unfiledFolder = FilePlanComponent.builder()
|
||||
.name(folderName)
|
||||
.nodeType(UNFILED_RECORD_FOLDER_TYPE.toString())
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(folderTitle)
|
||||
.description(folderDescription)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(unfiledFolder,
|
||||
UNFILED_RECORDS_CONTAINER_ALIAS.toString());
|
||||
@@ -117,9 +123,9 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
|
||||
|
||||
// Verify the returned file plan component
|
||||
assertFalse(filePlanComponent.isIsCategory());
|
||||
assertFalse(filePlanComponent.isIsFile());
|
||||
assertFalse(filePlanComponent.isIsRecordFolder()); // it is not a _normal_ record folder!
|
||||
assertFalse(filePlanComponent.getIsCategory());
|
||||
assertFalse(filePlanComponent.getIsFile());
|
||||
assertFalse(filePlanComponent.getIsRecordFolder()); // it is not a _normal_ record folder!
|
||||
|
||||
assertEquals(filePlanComponent.getName(), folderName);
|
||||
assertEquals(filePlanComponent.getNodeType(), UNFILED_RECORD_FOLDER_TYPE.toString());
|
||||
@@ -151,8 +157,14 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
logger.info("creating " + componentType.toString());
|
||||
|
||||
// Build unfiled records folder properties
|
||||
FilePlanComponent unfiledFolder = new FilePlanComponent(folderName, componentType.toString(),
|
||||
new FilePlanComponentProperties(folderTitle, folderDescription));
|
||||
FilePlanComponent unfiledFolder = FilePlanComponent.builder()
|
||||
.name(folderName)
|
||||
.nodeType(componentType.toString())
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(folderTitle)
|
||||
.description(folderDescription)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -189,8 +201,14 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
assertEquals(parentFolderName, parentFolder.getName());
|
||||
|
||||
// Build the unfiled records folder properties
|
||||
FilePlanComponent unfiledFolder = new FilePlanComponent(childFolderName, UNFILED_RECORD_FOLDER_TYPE.toString(),
|
||||
new FilePlanComponentProperties(childFolderTitle, childFolderDescription));
|
||||
FilePlanComponent unfiledFolder = FilePlanComponent.builder()
|
||||
.name(childFolderName)
|
||||
.nodeType(UNFILED_RECORD_FOLDER_TYPE.toString())
|
||||
.properties(FilePlanComponentProperties.builder()
|
||||
.title(childFolderTitle)
|
||||
.description(childFolderDescription)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
// Create it as a child of parentFolder
|
||||
FilePlanComponent childFolder = filePlanComponentAPI.createFilePlanComponent(unfiledFolder,
|
||||
@@ -200,9 +218,9 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
restWrapper.assertStatusCodeIs(CREATED);
|
||||
|
||||
// Verify the returned file plan component
|
||||
assertFalse(childFolder.isIsCategory());
|
||||
assertFalse(childFolder.isIsFile());
|
||||
assertFalse(childFolder.isIsRecordFolder()); // it is not a _normal_ record folder!
|
||||
assertFalse(childFolder.getIsCategory());
|
||||
assertFalse(childFolder.getIsFile());
|
||||
assertFalse(childFolder.getIsRecordFolder()); // it is not a _normal_ record folder!
|
||||
|
||||
assertEquals(childFolder.getName(), childFolderName);
|
||||
assertEquals(childFolder.getNodeType(), UNFILED_RECORD_FOLDER_TYPE.toString());
|
||||
@@ -251,9 +269,14 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
|
||||
assertEquals(folderName, folderToModify.getName());
|
||||
|
||||
// Build the properties which will be updated
|
||||
FilePlanComponent folderToUpdate=new FilePlanComponent(modified + folderToModify.getName(),
|
||||
new FilePlanComponentProperties(modified + folderToModify.getProperties().getTitle(),
|
||||
modified + folderToModify.getProperties().getDescription()));
|
||||
FilePlanComponent folderToUpdate = FilePlanComponent.builder()
|
||||
.name(modified + folderToModify.getName())
|
||||
.properties(FilePlanComponentProperties.builder().
|
||||
title(modified + folderToModify.getProperties().getTitle()).
|
||||
description(modified + folderToModify.getProperties().getDescription())
|
||||
.build())
|
||||
.build();
|
||||
|
||||
// Update the unfiled records folder
|
||||
filePlanComponentAPI.updateFilePlanComponent(folderToUpdate, folderToModify.getId());
|
||||
// Verify the status code
|
||||
|
Reference in New Issue
Block a user