RM-4326: allow creation in transfer container only from

TransferServiceImpl
This commit is contained in:
Silviu Dinuta
2016-11-08 17:26:07 +02:00
parent c28e0d5338
commit fce705ff72
7 changed files with 73 additions and 118 deletions

View File

@@ -68,22 +68,4 @@ public class TransferContainerTypeUnitTest extends BaseUnitTest
when(mockedChildAssoc.getParentRef()).thenReturn(transferContainer);
transferContainerType.onCreateChildAssociation(mockedChildAssoc, true);
}
/**
* Given that we try to add "rma:transfer" type to transfer container,
* Then the operation is successful.
*/
@Test
public void testAddTransferFolderToTransferContainer()
{
QName type = AlfMock.generateQName();
when(mockedDictionaryService.isSubClass(type, TYPE_TRANSFER)).thenReturn(true);
NodeRef transferFolder= AlfMock.generateNodeRef(mockedNodeService, type);
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);
}
}

View File

@@ -755,22 +755,6 @@ public class RMNodesImplUnitTest extends BaseUnitTest
rmNodesImpl.checkPostPermission(parentNodeRef.getId());
}
@Test
public void testCheckPostPermissionForTransferContainer() throws Exception
{
NodeRef parentNodeRef = AlfMock.generateNodeRef(mockedNodeService);
when(mockedNodeService.getType(parentNodeRef)).thenReturn(RecordsManagementModel.TYPE_TRANSFER_CONTAINER);
try
{
rmNodesImpl.checkPostPermission(parentNodeRef.getId());
fail("Expected ecxeption as post should not be permitted on the Transfer Container");
}
catch(PermissionDeniedException ex)
{
assertEquals("POST request not allowed in Transfer Container.", ex.getMsgId());
}
}
@Test
public void testCheckPostPermissionForTransferFolder() throws Exception
{

View File

@@ -122,29 +122,6 @@ public class FileplanComponentChildrenRelationUnitTest extends BaseUnitTest
verify(mockedRMNodes, never()).createNode(parentNodeRef.getId(), nodeInfos.get(0), mockedParameters);
}
@Test
public void testCreateOnTransferContainer() throws Exception
{
Parameters mockedParameters = mock(Parameters.class);
NodeRef parentNodeRef = AlfMock.generateNodeRef(mockedNodeService);
List<Node> nodeInfos = new ArrayList<Node>();
Node mokedNodeInfo = mock(Node.class);
nodeInfos.add(mokedNodeInfo);
Mockito.doThrow(new PermissionDeniedException("POST request not allowed in Transfer Container.")).when(mockedRMNodes).checkPostPermission(parentNodeRef.getId());
try
{
filePlanComponentChildrenRelation.create(parentNodeRef.getId(), nodeInfos, mockedParameters);
fail("Expected ecxeption as POST request is not allowed in Transfer Container.");
}
catch(PermissionDeniedException ex)
{
assertEquals("POST request not allowed in Transfer Container.", ex.getMsgId());
}
verify(mockedRMNodes, never()).createNode(parentNodeRef.getId(), nodeInfos.get(0), mockedParameters);
}
@Test
public void testCreateOnHoldFolder() throws Exception
{
@@ -223,27 +200,6 @@ public class FileplanComponentChildrenRelationUnitTest extends BaseUnitTest
verify(mockedRMNodes, never()).upload(parentNodeRef.getId(), mockedFormData, mockedParameters);
}
@Test
public void testUploadOnTransferContainer() throws Exception
{
Parameters mockedParameters = mock(Parameters.class);
NodeRef parentNodeRef = AlfMock.generateNodeRef(mockedNodeService);
FormData mockedFormData = mock(FormData.class);
WithResponse mockedWithResponse = mock(WithResponse.class);
Mockito.doThrow(new PermissionDeniedException("POST request not allowed in Transfer Container.")).when(mockedRMNodes).checkPostPermission(parentNodeRef.getId());
try
{
filePlanComponentChildrenRelation.create(parentNodeRef.getId(), mockedFormData, mockedParameters, mockedWithResponse);
fail("Expected ecxeption as POST request is not allowed in Transfer Container.");
}
catch(PermissionDeniedException ex)
{
assertEquals("POST request not allowed in Transfer Container.", ex.getMsgId());
}
verify(mockedRMNodes, never()).upload(parentNodeRef.getId(), mockedFormData, mockedParameters);
}
@Test
public void testUploadOnHoldFolder() throws Exception
{