Merge remote-tracking branch 'remotes/origin/feature/RM-6792_AddLocnParamToDeclareAsRec' into feature/RM-6796_DeclareAndFileTests

This commit is contained in:
cagache
2019-05-21 15:38:47 +03:00
2 changed files with 12 additions and 9 deletions

View File

@@ -905,19 +905,20 @@ public class RecordServiceImpl extends BaseBehaviourBean
// if optional location not specified, use the unfiledContainer
if (newRecordContainer == null)
{
// get the new record container for the file plan
// get the unfiled record container node for the file plan
newRecordContainer = filePlanService.getUnfiledContainer(checkedFilePlan);
if (newRecordContainer == null)
{
throw new AlfrescoRuntimeException("Unable to create record, because record container could not be found.");
}
}
// if optional location supplied, check that it is a valid record folder
// if optional location supplied, check that it is a valid record folder, unfiled record container or folder
else
{
QName nodeType = nodeService.getType(newRecordContainer);
final QName nodeType = nodeService.getType(newRecordContainer);
if(!(nodeType.equals(RecordsManagementModel.TYPE_RECORD_FOLDER) ||
nodeType.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER)))
nodeType.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER) ||
nodeType.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER)))
{
throw new AlfrescoRuntimeException("Unable to create record, because container is not a valid type for new record.");
}

View File

@@ -73,6 +73,7 @@ public class RecordServiceImplUnitTest extends BaseUnitTest
private NodeRef nonStandardFilePlanComponent;
private NodeRef nonStandardFilePlan;
private NodeRef dmNodeRef;
private NodeRef unfiledRecordContainer;
private NodeRef unfiledRecordFolder;
private ChildAssociationRef parentAssoc;
@@ -91,6 +92,7 @@ public class RecordServiceImplUnitTest extends BaseUnitTest
nonStandardFilePlanComponent = generateNodeRef(TYPE_RECORD_CATEGORY);
nonStandardFilePlan = generateNodeRef(TYPE_MY_FILE_PLAN);
dmNodeRef = generateNodeRef(TYPE_CONTENT);
unfiledRecordContainer = generateNodeRef(TYPE_UNFILED_RECORD_CONTAINER);
unfiledRecordFolder = generateNodeRef(TYPE_UNFILED_RECORD_FOLDER);
parentAssoc = mock(ChildAssociationRef.class);
@@ -483,12 +485,12 @@ public class RecordServiceImplUnitTest extends BaseUnitTest
mocksForRecordCreation();
// create the record
recordService.createRecord(nonStandardFilePlan, dmNodeRef);
recordService.createRecord(filePlan, dmNodeRef);
// verify record was created in unfiled record container
verify(mockedNodeService, times(1)).moveNode(
dmNodeRef,
unfiledRecordFolder,
unfiledRecordContainer,
ContentModel.ASSOC_CONTAINS,
parentAssoc.getQName());
}
@@ -504,12 +506,12 @@ public class RecordServiceImplUnitTest extends BaseUnitTest
mocksForRecordCreation();
// create the record
recordService.createRecord(filePlan, dmNodeRef, unfiledRecordFolder);
recordService.createRecord(filePlan, dmNodeRef, unfiledRecordContainer);
// verify record was created in specified unfiled record container
verify(mockedNodeService, times(1)).moveNode(
dmNodeRef,
unfiledRecordFolder,
unfiledRecordContainer,
ContentModel.ASSOC_CONTAINS,
parentAssoc.getQName());
}
@@ -566,7 +568,7 @@ public class RecordServiceImplUnitTest extends BaseUnitTest
doNothing().when(recordService).invokeBeforeRecordDeclaration(dmNodeRef);
doNothing().when(recordService).invokeOnRecordDeclaration(dmNodeRef);
when(mockedFilePlanService.getUnfiledContainer(nonStandardFilePlan)).thenReturn(unfiledRecordFolder);
when(mockedFilePlanService.getUnfiledContainer(filePlan)).thenReturn(unfiledRecordContainer);
when(mockedVersionService.getVersionHistory(dmNodeRef)).thenReturn(null);
}