mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
addressed code review comments
This commit is contained in:
@@ -37,6 +37,7 @@ import static org.mockito.Mockito.when;
|
|||||||
import static org.mockito.MockitoAnnotations.initMocks;
|
import static org.mockito.MockitoAnnotations.initMocks;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
||||||
import org.alfresco.repo.policy.BehaviourFilter;
|
import org.alfresco.repo.policy.BehaviourFilter;
|
||||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
@@ -75,6 +76,8 @@ public class RecordAspectUnitTest
|
|||||||
private ContentReader mockContentReader;
|
private ContentReader mockContentReader;
|
||||||
@Mock
|
@Mock
|
||||||
private ContentWriter mockContentWriter;
|
private ContentWriter mockContentWriter;
|
||||||
|
@Mock
|
||||||
|
private ExtendedSecurityService mockExtendedSecurityService;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp()
|
public void setUp()
|
||||||
@@ -84,7 +87,7 @@ public class RecordAspectUnitTest
|
|||||||
|
|
||||||
/** Check that the bin is duplicated before adding the aspect if the file has a copy. */
|
/** Check that the bin is duplicated before adding the aspect if the file has a copy. */
|
||||||
@Test
|
@Test
|
||||||
public void testDuplicateBinForFileWithCopy()
|
public void testDuplicateBinBeforeAddingAspectForFileWithCopy()
|
||||||
{
|
{
|
||||||
when(mockNodeService.getSourceAssocs(NODE_REF, ContentModel.ASSOC_ORIGINAL)).thenReturn(asList(SOURCE_ASSOC_REF));
|
when(mockNodeService.getSourceAssocs(NODE_REF, ContentModel.ASSOC_ORIGINAL)).thenReturn(asList(SOURCE_ASSOC_REF));
|
||||||
when(mockContentService.getReader(NODE_REF, ContentModel.PROP_CONTENT)).thenReturn(mockContentReader);
|
when(mockContentService.getReader(NODE_REF, ContentModel.PROP_CONTENT)).thenReturn(mockContentReader);
|
||||||
@@ -103,7 +106,7 @@ public class RecordAspectUnitTest
|
|||||||
|
|
||||||
/** Check that the bin is duplicated before adding the aspect if the file is a copy. */
|
/** Check that the bin is duplicated before adding the aspect if the file is a copy. */
|
||||||
@Test
|
@Test
|
||||||
public void testDuplicateBinForCopy()
|
public void testDuplicateBinBeforeAddingAspectForCopy()
|
||||||
{
|
{
|
||||||
when(mockNodeService.getTargetAssocs(NODE_REF, ContentModel.ASSOC_ORIGINAL)).thenReturn(asList(TARGET_ASSOC_REF));
|
when(mockNodeService.getTargetAssocs(NODE_REF, ContentModel.ASSOC_ORIGINAL)).thenReturn(asList(TARGET_ASSOC_REF));
|
||||||
when(mockContentService.getReader(NODE_REF, ContentModel.PROP_CONTENT)).thenReturn(mockContentReader);
|
when(mockContentService.getReader(NODE_REF, ContentModel.PROP_CONTENT)).thenReturn(mockContentReader);
|
||||||
@@ -136,4 +139,21 @@ public class RecordAspectUnitTest
|
|||||||
verify(mockBehaviorFilter, times(1)).enableBehaviour(eq(ContentModel.ASPECT_AUDITABLE));
|
verify(mockBehaviorFilter, times(1)).enableBehaviour(eq(ContentModel.ASPECT_AUDITABLE));
|
||||||
verify(mockBehaviorFilter, times(1)).enableBehaviour(eq(ContentModel.ASPECT_VERSIONABLE));
|
verify(mockBehaviorFilter, times(1)).enableBehaviour(eq(ContentModel.ASPECT_VERSIONABLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Check that the bin is duplicated when copying a record. */
|
||||||
|
@Test
|
||||||
|
public void testDuplicateBinWhenCopyingRecord()
|
||||||
|
{
|
||||||
|
when(mockNodeService.exists(COPY_REF)).thenReturn(true);
|
||||||
|
when(mockNodeService.hasAspect(COPY_REF, ASPECT_RECORD)).thenReturn(true);
|
||||||
|
when(mockContentService.getReader(COPY_REF, ContentModel.PROP_CONTENT)).thenReturn(mockContentReader);
|
||||||
|
when(mockContentService.getWriter(COPY_REF, ContentModel.PROP_CONTENT, true)).thenReturn(mockContentWriter);
|
||||||
|
|
||||||
|
recordAspect.onCopyComplete(null, NODE_REF, COPY_REF, true, null);
|
||||||
|
|
||||||
|
verify(mockExtendedSecurityService, times(1)).remove(COPY_REF);
|
||||||
|
verify(mockContentService, times(1)).getReader(COPY_REF, ContentModel.PROP_CONTENT);
|
||||||
|
verify(mockContentService, times(1)).getWriter(COPY_REF, ContentModel.PROP_CONTENT, true);
|
||||||
|
verify(mockContentWriter, times(1)).putContent(mockContentReader);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user