mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-4312: changed implementation after review
This commit is contained in:
@@ -29,11 +29,13 @@ package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import java.security.InvalidParameterException;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
|
||||
@@ -48,47 +50,31 @@ public class HoldContainerTypeUnitTest extends BaseUnitTest
|
||||
/** test object */
|
||||
private @InjectMocks HoldContainerType holdContainerType;
|
||||
|
||||
/**
|
||||
* Having the Unfilled Record container and a folder having the aspect ASPECT_HIDDEN When adding a child association
|
||||
* between the folder and the container Then the folder type shouldn't be renamed
|
||||
*/
|
||||
@Test (expected = AlfrescoRuntimeException.class)
|
||||
public void testAddContentToHoldContainer()
|
||||
@Test (expected = InvalidParameterException.class)
|
||||
public void testAddNonHoldTypeToHoldContainer()
|
||||
{
|
||||
QName type = AlfMock.generateQName();
|
||||
when(mockedDictionaryService.isSubClass(type, TYPE_HOLD)).thenReturn(false);
|
||||
NodeRef nodeRef= AlfMock.generateNodeRef(mockedNodeService, type);
|
||||
|
||||
NodeRef holdContainer = createHoldContainer();
|
||||
|
||||
/*
|
||||
* When adding a child association between the folder and the container
|
||||
*/
|
||||
NodeRef record = generateNodeRef(ContentModel.TYPE_CONTENT);
|
||||
ChildAssociationRef childAssoc = new ChildAssociationRef( ContentModel.TYPE_CONTENT, holdContainer,
|
||||
ContentModel.TYPE_CONTENT, record);
|
||||
|
||||
holdContainerType.onCreateChildAssociation(childAssoc, true);
|
||||
}
|
||||
|
||||
@Test(expected = AlfrescoRuntimeException.class)
|
||||
public void testAddRecordFolderToHoldContainer()
|
||||
{
|
||||
NodeRef recordFolder = generateNodeRef(TYPE_RECORD_FOLDER, true);
|
||||
NodeRef holdContainer = createHoldContainer();
|
||||
NodeRef holdContainer = generateNodeRef(TYPE_HOLD_CONTAINER, true);
|
||||
ChildAssociationRef mockedChildAssoc = mock(ChildAssociationRef.class);
|
||||
when(mockedChildAssoc.getChildRef()).thenReturn(recordFolder);
|
||||
when(mockedChildAssoc.getChildRef()).thenReturn(nodeRef);
|
||||
when(mockedChildAssoc.getParentRef()).thenReturn(holdContainer);
|
||||
holdContainerType.onCreateChildAssociation(mockedChildAssoc, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a record management container
|
||||
*
|
||||
* @return reference to the generated container
|
||||
*/
|
||||
private NodeRef createHoldContainer()
|
||||
@Test
|
||||
public void testAddHoldTypeToHoldContainer()
|
||||
{
|
||||
QName type = AlfMock.generateQName();
|
||||
when(mockedDictionaryService.isSubClass(type, TYPE_HOLD)).thenReturn(true);
|
||||
NodeRef holdFolder= AlfMock.generateNodeRef(mockedNodeService, type);
|
||||
|
||||
NodeRef holdContainer = generateNodeRef(TYPE_HOLD_CONTAINER, true);
|
||||
|
||||
return holdContainer;
|
||||
ChildAssociationRef mockedChildAssoc = mock(ChildAssociationRef.class);
|
||||
when(mockedChildAssoc.getChildRef()).thenReturn(holdFolder);
|
||||
when(mockedChildAssoc.getParentRef()).thenReturn(holdContainer);
|
||||
holdContainerType.onCreateChildAssociation(mockedChildAssoc, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -29,16 +29,18 @@ package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import java.security.InvalidParameterException;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
|
||||
/**
|
||||
* Unit test for TransferContainerTypeTest
|
||||
* Unit test for TransferContainerType
|
||||
*
|
||||
* @author Mihai Cozma
|
||||
* @since 2.4
|
||||
@@ -48,47 +50,32 @@ public class TransferContainerTypeUnitTest extends BaseUnitTest
|
||||
/** test object */
|
||||
private @InjectMocks TransferContainerType transferContainerType;
|
||||
|
||||
/**
|
||||
* Having the Unfilled Record container and a folder having the aspect ASPECT_HIDDEN When adding a child association
|
||||
* between the folder and the container Then the folder type shouldn't be renamed
|
||||
*/
|
||||
@Test(expected = AlfrescoRuntimeException.class)
|
||||
public void testAddContentToTransferContainerTest()
|
||||
@Test(expected = InvalidParameterException.class)
|
||||
public void testAddNonTransferTypeToTransferContainerTest()
|
||||
{
|
||||
NodeRef transferContainer = generateNodeRef(TYPE_TRANSFER_CONTAINER, true);
|
||||
|
||||
NodeRef transferContainer = createTransferContainer();
|
||||
QName type = AlfMock.generateQName();
|
||||
when(mockedDictionaryService.isSubClass(type, TYPE_TRANSFER)).thenReturn(false);
|
||||
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type);
|
||||
|
||||
/*
|
||||
* When adding a child association between the folder and the container
|
||||
*/
|
||||
NodeRef record = generateNodeRef(ContentModel.TYPE_CONTENT);
|
||||
ChildAssociationRef childAssoc = new ChildAssociationRef(ContentModel.TYPE_CONTENT, transferContainer,
|
||||
ContentModel.TYPE_CONTENT, record);
|
||||
|
||||
transferContainerType.onCreateChildAssociation(childAssoc, true);
|
||||
}
|
||||
|
||||
@Test(expected = AlfrescoRuntimeException.class)
|
||||
public void testAddRecordFolderToTransferContainer()
|
||||
{
|
||||
NodeRef recordFolder = generateNodeRef(TYPE_RECORD_FOLDER, true);
|
||||
NodeRef holdContainer = generateNodeRef(TYPE_TRANSFER_CONTAINER, true);
|
||||
ChildAssociationRef mockedChildAssoc = mock(ChildAssociationRef.class);
|
||||
when(mockedChildAssoc.getChildRef()).thenReturn(recordFolder);
|
||||
when(mockedChildAssoc.getParentRef()).thenReturn(holdContainer);
|
||||
when(mockedChildAssoc.getChildRef()).thenReturn(nodeRef);
|
||||
when(mockedChildAssoc.getParentRef()).thenReturn(transferContainer);
|
||||
transferContainerType.onCreateChildAssociation(mockedChildAssoc, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a record management container
|
||||
*
|
||||
* @return reference to the generated container
|
||||
*/
|
||||
private NodeRef createTransferContainer()
|
||||
@Test
|
||||
public void testAddTransferFolderToTransferContainer()
|
||||
{
|
||||
NodeRef holdContainer = generateNodeRef(TYPE_TRANSFER, true);
|
||||
QName type = AlfMock.generateQName();
|
||||
when(mockedDictionaryService.isSubClass(type, TYPE_TRANSFER)).thenReturn(true);
|
||||
NodeRef transferFolder= AlfMock.generateNodeRef(mockedNodeService, type);
|
||||
|
||||
return holdContainer;
|
||||
NodeRef transferContainer = generateNodeRef(TYPE_TRANSFER_CONTAINER, true);
|
||||
ChildAssociationRef mockedChildAssoc = mock(ChildAssociationRef.class);
|
||||
when(mockedChildAssoc.getChildRef()).thenReturn(transferFolder);
|
||||
when(mockedChildAssoc.getParentRef()).thenReturn(transferContainer);
|
||||
transferContainerType.onCreateChildAssociation(mockedChildAssoc, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -30,10 +30,14 @@ package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import java.security.InvalidParameterException;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
|
||||
@@ -48,14 +52,71 @@ public class UnfiledRecordContainerTypeUnitTest extends BaseUnitTest
|
||||
@InjectMocks
|
||||
private UnfiledRecordContainerType unfiledRecordContainerType;
|
||||
|
||||
@Test(expected = AlfrescoRuntimeException.class)
|
||||
public void testAddRecordFolderToTransferContainer()
|
||||
@Test(expected = InvalidParameterException.class)
|
||||
public void testAddNonAcceptedTypeToUnfiledRecordContainer()
|
||||
{
|
||||
NodeRef recordFolder = generateNodeRef(TYPE_RECORD_FOLDER, true);
|
||||
NodeRef holdContainer = generateNodeRef(TYPE_UNFILED_RECORD_CONTAINER, true);
|
||||
QName type = AlfMock.generateQName();
|
||||
when(mockedDictionaryService.isSubClass(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(false);
|
||||
when(mockedDictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)).thenReturn(false);
|
||||
when(mockedDictionaryService.isSubClass(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(false);
|
||||
|
||||
NodeRef nodeRef= AlfMock.generateNodeRef(mockedNodeService, type);
|
||||
|
||||
NodeRef unfiledRecordContainer = generateNodeRef(TYPE_UNFILED_RECORD_CONTAINER, true);
|
||||
ChildAssociationRef mockedChildAssoc = mock(ChildAssociationRef.class);
|
||||
when(mockedChildAssoc.getChildRef()).thenReturn(recordFolder);
|
||||
when(mockedChildAssoc.getParentRef()).thenReturn(holdContainer);
|
||||
when(mockedChildAssoc.getChildRef()).thenReturn(nodeRef);
|
||||
when(mockedChildAssoc.getParentRef()).thenReturn(unfiledRecordContainer);
|
||||
unfiledRecordContainerType.onCreateChildAssociation(mockedChildAssoc, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddUnfiledRecordFolderTypeToUnfiledRecordContainer()
|
||||
{
|
||||
QName type = AlfMock.generateQName();
|
||||
when(mockedDictionaryService.isSubClass(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(true);
|
||||
when(mockedDictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)).thenReturn(false);
|
||||
when(mockedDictionaryService.isSubClass(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(false);
|
||||
|
||||
NodeRef nodeRef= AlfMock.generateNodeRef(mockedNodeService, type);
|
||||
|
||||
NodeRef unfiledRecordContainer = generateNodeRef(TYPE_UNFILED_RECORD_CONTAINER, true);
|
||||
ChildAssociationRef mockedChildAssoc = mock(ChildAssociationRef.class);
|
||||
when(mockedChildAssoc.getChildRef()).thenReturn(nodeRef);
|
||||
when(mockedChildAssoc.getParentRef()).thenReturn(unfiledRecordContainer);
|
||||
unfiledRecordContainerType.onCreateChildAssociation(mockedChildAssoc, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddContentTypeToUnfiledRecordContainer()
|
||||
{
|
||||
QName type = AlfMock.generateQName();
|
||||
when(mockedDictionaryService.isSubClass(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(false);
|
||||
when(mockedDictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)).thenReturn(true);
|
||||
when(mockedDictionaryService.isSubClass(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(false);
|
||||
|
||||
NodeRef nodeRef= AlfMock.generateNodeRef(mockedNodeService, type);
|
||||
|
||||
NodeRef unfiledRecordContainer = generateNodeRef(TYPE_UNFILED_RECORD_CONTAINER, true);
|
||||
ChildAssociationRef mockedChildAssoc = mock(ChildAssociationRef.class);
|
||||
when(mockedChildAssoc.getChildRef()).thenReturn(nodeRef);
|
||||
when(mockedChildAssoc.getParentRef()).thenReturn(unfiledRecordContainer);
|
||||
unfiledRecordContainerType.onCreateChildAssociation(mockedChildAssoc, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonElectronicDocumentTypeToUnfiledRecordContainer()
|
||||
{
|
||||
QName type = AlfMock.generateQName();
|
||||
when(mockedDictionaryService.isSubClass(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(false);
|
||||
when(mockedDictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)).thenReturn(false);
|
||||
when(mockedDictionaryService.isSubClass(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(true);
|
||||
|
||||
NodeRef nodeRef= AlfMock.generateNodeRef(mockedNodeService, type);
|
||||
|
||||
NodeRef unfiledRecordContainer = generateNodeRef(TYPE_UNFILED_RECORD_CONTAINER, true);
|
||||
ChildAssociationRef mockedChildAssoc = mock(ChildAssociationRef.class);
|
||||
when(mockedChildAssoc.getChildRef()).thenReturn(nodeRef);
|
||||
when(mockedChildAssoc.getParentRef()).thenReturn(unfiledRecordContainer);
|
||||
unfiledRecordContainerType.onCreateChildAssociation(mockedChildAssoc, true);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user