Revert "Minor changes to make Eclipse happy."

This reverts commit 807b74b023.
This commit is contained in:
Tom Page
2015-12-17 11:43:27 +00:00
parent 4b1dafada6
commit 340b3d09d5

View File

@@ -53,7 +53,7 @@ import org.springframework.extensions.webscripts.GUID;
/** /**
* Extended versionable aspect unit test. * Extended versionable aspect unit test.
* *
* @author Roy Wetherall * @author Roy Wetherall
* @since 2.3.1 * @since 2.3.1
*/ */
@@ -61,29 +61,29 @@ public class ExtendedVersionableAspectUnitTest implements RecordsManagementModel
{ {
/** Transaction resource key */ /** Transaction resource key */
private static final String KEY_VERSIONED_NODEREFS = "versioned_noderefs"; private static final String KEY_VERSIONED_NODEREFS = "versioned_noderefs";
/** test data */ /** test data */
private NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, GUID.generate()); private NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, GUID.generate());
private NodeRef anotherNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, GUID.generate()); private NodeRef anotherNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, GUID.generate());
private QName oldType = QName.createQName(RM_URI, GUID.generate()); private QName oldType = QName.createQName(RM_URI, GUID.generate());
private QName newType = QName.createQName(RM_URI, GUID.generate()); private QName newType = QName.createQName(RM_URI, GUID.generate());
/** service mocks */ /** service mocks */
private @Mock NodeService mockedNodeService; private @Mock NodeService mockedNodeService;
private @Mock VersionService mockedVersionService; private @Mock VersionService mockedVersionService;
private @Mock LockService mockedLockService; private @Mock LockService mockedLockService;
private @Mock AlfrescoTransactionSupport mockedAlfrescoTransactionSupport; private @Mock AlfrescoTransactionSupport mockedAlfrescoTransactionSupport;
private @Mock AuthenticationUtil mockedAuthenticationUtil; private @Mock AuthenticationUtil mockedAuthenticationUtil;
/** test instance of extended versionable aspect behaviour bean */ /** test instance of extended versionable aspect behaviour bean */
private @InjectMocks ExtendedVersionableAspect extendedVersionableAspect; private @InjectMocks ExtendedVersionableAspect extendedVersionableAspect;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Before @Before
public void testSetup() public void testSetup()
{ {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
// just do the work // just do the work
doAnswer(new Answer<Object>() doAnswer(new Answer<Object>()
{ {
@@ -95,10 +95,10 @@ public class ExtendedVersionableAspectUnitTest implements RecordsManagementModel
return work.doWork(); return work.doWork();
} }
}).when(mockedAuthenticationUtil).runAsSystem((RunAsWork<Object>) any(RunAsWork.class)); }).when(mockedAuthenticationUtil).runAsSystem(any(RunAsWork.class));
} }
/** /**
* given that autoversion on type change is configured off * given that autoversion on type change is configured off
* when the type set behvaiour is executed * when the type set behvaiour is executed
* then a new version is not created * then a new version is not created
@@ -109,14 +109,14 @@ public class ExtendedVersionableAspectUnitTest implements RecordsManagementModel
{ {
// auto version off // auto version off
extendedVersionableAspect.setAutoVersionOnTypeChange(false); extendedVersionableAspect.setAutoVersionOnTypeChange(false);
// execute behaviour // execute behaviour
extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType);
// assert the version was not created // assert the version was not created
verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class));
} }
/** /**
* given the node doesn't exist * given the node doesn't exist
* when the type set behaviour is executed * when the type set behaviour is executed
@@ -128,18 +128,18 @@ public class ExtendedVersionableAspectUnitTest implements RecordsManagementModel
{ {
// auto version on // auto version on
extendedVersionableAspect.setAutoVersionOnTypeChange(true); extendedVersionableAspect.setAutoVersionOnTypeChange(true);
// node does not exist // node does not exist
when(mockedNodeService.exists(nodeRef)) when(mockedNodeService.exists(nodeRef))
.thenReturn(false); .thenReturn(false);
// execute behaviour // execute behaviour
extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType);
// assert the version was not created // assert the version was not created
verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class));
} }
/** /**
* given that the node is locked * given that the node is locked
* when the type set behaviour is executed * when the type set behaviour is executed
@@ -151,25 +151,25 @@ public class ExtendedVersionableAspectUnitTest implements RecordsManagementModel
{ {
// auto version on // auto version on
extendedVersionableAspect.setAutoVersionOnTypeChange(true); extendedVersionableAspect.setAutoVersionOnTypeChange(true);
// node does exists // node does exists
when(mockedNodeService.exists(nodeRef)) when(mockedNodeService.exists(nodeRef))
.thenReturn(true); .thenReturn(true);
// node is locked // node is locked
when(mockedLockService.getLockStatus(nodeRef)) when(mockedLockService.getLockStatus(nodeRef))
.thenReturn(LockStatus.LOCKED); .thenReturn(LockStatus.LOCKED);
// execute behaviour // execute behaviour
extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType);
// verify other // verify other
verify(mockedNodeService).exists(nodeRef); verify(mockedNodeService).exists(nodeRef);
// assert the version was not created // assert the version was not created
verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class));
} }
/** /**
* given that the node does not have the versionable aspect * given that the node does not have the versionable aspect
* when the type set behaviour is executed * when the type set behaviour is executed
@@ -181,31 +181,31 @@ public class ExtendedVersionableAspectUnitTest implements RecordsManagementModel
{ {
// auto version on // auto version on
extendedVersionableAspect.setAutoVersionOnTypeChange(true); extendedVersionableAspect.setAutoVersionOnTypeChange(true);
// node does exists // node does exists
when(mockedNodeService.exists(nodeRef)) when(mockedNodeService.exists(nodeRef))
.thenReturn(true); .thenReturn(true);
// node is not locked // node is not locked
when(mockedLockService.getLockStatus(nodeRef)) when(mockedLockService.getLockStatus(nodeRef))
.thenReturn(LockStatus.NO_LOCK); .thenReturn(LockStatus.NO_LOCK);
// node does not have the versionable aspect // node does not have the versionable aspect
when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE))
.thenReturn(false); .thenReturn(false);
// execute behaviour // execute behaviour
extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType);
// verify other // verify other
verify(mockedNodeService).exists(nodeRef); verify(mockedNodeService).exists(nodeRef);
verify(mockedLockService).getLockStatus(nodeRef); verify(mockedLockService).getLockStatus(nodeRef);
// assert the version was not created // assert the version was not created
verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class));
} }
/** /**
* given that the node has the temporary aspect * given that the node has the temporary aspect
* when the type set behaviour is executed * when the type set behaviour is executed
* then a new version is not created * then a new version is not created
@@ -216,36 +216,36 @@ public class ExtendedVersionableAspectUnitTest implements RecordsManagementModel
{ {
// auto version on // auto version on
extendedVersionableAspect.setAutoVersionOnTypeChange(true); extendedVersionableAspect.setAutoVersionOnTypeChange(true);
// node does exists // node does exists
when(mockedNodeService.exists(nodeRef)) when(mockedNodeService.exists(nodeRef))
.thenReturn(true); .thenReturn(true);
// node is not locked // node is not locked
when(mockedLockService.getLockStatus(nodeRef)) when(mockedLockService.getLockStatus(nodeRef))
.thenReturn(LockStatus.NO_LOCK); .thenReturn(LockStatus.NO_LOCK);
// node has the versionable aspect // node has the versionable aspect
when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE))
.thenReturn(true); .thenReturn(true);
// node has the temporary aspect // node has the temporary aspect
when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY)) when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY))
.thenReturn(true); .thenReturn(true);
// execute behaviour // execute behaviour
extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType);
// verify other // verify other
verify(mockedNodeService).exists(nodeRef); verify(mockedNodeService).exists(nodeRef);
verify(mockedLockService).getLockStatus(nodeRef); verify(mockedLockService).getLockStatus(nodeRef);
verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE); verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE);
// assert the version was not created // assert the version was not created
verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class));
} }
/** /**
* given that the node is already being versioned * given that the node is already being versioned
* when the type set behvaiour is executed * when the type set behvaiour is executed
* then a new version is not created * then a new version is not created
@@ -256,40 +256,40 @@ public class ExtendedVersionableAspectUnitTest implements RecordsManagementModel
{ {
// auto version on // auto version on
extendedVersionableAspect.setAutoVersionOnTypeChange(true); extendedVersionableAspect.setAutoVersionOnTypeChange(true);
// node does exists // node does exists
when(mockedNodeService.exists(nodeRef)) when(mockedNodeService.exists(nodeRef))
.thenReturn(true); .thenReturn(true);
// node is not locked // node is not locked
when(mockedLockService.getLockStatus(nodeRef)) when(mockedLockService.getLockStatus(nodeRef))
.thenReturn(LockStatus.NO_LOCK); .thenReturn(LockStatus.NO_LOCK);
// node has the versionable aspect // node has the versionable aspect
when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE))
.thenReturn(true); .thenReturn(true);
// node does not have the temporary aspect // node does not have the temporary aspect
when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY)) when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY))
.thenReturn(false); .thenReturn(false);
// node is currently being processed for versioning // node is currently being processed for versioning
when(mockedAlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS)) when(mockedAlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS))
.thenReturn(Collections.singletonMap(nodeRef, nodeRef)); .thenReturn(Collections.singletonMap(nodeRef, nodeRef));
// execute behaviour // execute behaviour
extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType);
// verify other // verify other
verify(mockedNodeService).exists(nodeRef); verify(mockedNodeService).exists(nodeRef);
verify(mockedLockService).getLockStatus(nodeRef); verify(mockedLockService).getLockStatus(nodeRef);
verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE); verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE);
verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY); verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY);
// assert the version was not created // assert the version was not created
verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class));
} }
/** /**
* given that the node has the auto version property set to false * given that the node has the auto version property set to false
* when the type set behaviour is executed * when the type set behaviour is executed
@@ -301,41 +301,41 @@ public class ExtendedVersionableAspectUnitTest implements RecordsManagementModel
{ {
// auto version on // auto version on
extendedVersionableAspect.setAutoVersionOnTypeChange(true); extendedVersionableAspect.setAutoVersionOnTypeChange(true);
// node does exists // node does exists
when(mockedNodeService.exists(nodeRef)) when(mockedNodeService.exists(nodeRef))
.thenReturn(true); .thenReturn(true);
// node is not locked // node is not locked
when(mockedLockService.getLockStatus(nodeRef)) when(mockedLockService.getLockStatus(nodeRef))
.thenReturn(LockStatus.NO_LOCK); .thenReturn(LockStatus.NO_LOCK);
// node has the versionable aspect // node has the versionable aspect
when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE))
.thenReturn(true); .thenReturn(true);
// node does not have the temporary aspect // node does not have the temporary aspect
when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY)) when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY))
.thenReturn(false); .thenReturn(false);
// node is not being processed for versioning // node is not being processed for versioning
when(mockedAlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS)) when(mockedAlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS))
.thenReturn(Collections.singletonMap(anotherNodeRef, anotherNodeRef)); .thenReturn(Collections.singletonMap(anotherNodeRef, anotherNodeRef));
// auto version false // auto version false
when(mockedNodeService.getProperty(nodeRef, ContentModel.PROP_AUTO_VERSION)) when(mockedNodeService.getProperty(nodeRef, ContentModel.PROP_AUTO_VERSION))
.thenReturn(Boolean.FALSE); .thenReturn(Boolean.FALSE);
// execute behaviour // execute behaviour
extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType);
// verify other // verify other
verify(mockedNodeService).exists(nodeRef); verify(mockedNodeService).exists(nodeRef);
verify(mockedLockService).getLockStatus(nodeRef); verify(mockedLockService).getLockStatus(nodeRef);
verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE); verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE);
verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY); verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY);
verify(mockedAlfrescoTransactionSupport).getResource(KEY_VERSIONED_NODEREFS); verify(mockedAlfrescoTransactionSupport).getResource(KEY_VERSIONED_NODEREFS);
// assert the version was not created // assert the version was not created
verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class)); verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class));
} }
@@ -357,34 +357,34 @@ public class ExtendedVersionableAspectUnitTest implements RecordsManagementModel
{ {
// auto version on // auto version on
extendedVersionableAspect.setAutoVersionOnTypeChange(true); extendedVersionableAspect.setAutoVersionOnTypeChange(true);
// node does exists // node does exists
when(mockedNodeService.exists(nodeRef)) when(mockedNodeService.exists(nodeRef))
.thenReturn(true); .thenReturn(true);
// node is not locked // node is not locked
when(mockedLockService.getLockStatus(nodeRef)) when(mockedLockService.getLockStatus(nodeRef))
.thenReturn(LockStatus.NO_LOCK); .thenReturn(LockStatus.NO_LOCK);
// node has the versionable aspect // node has the versionable aspect
when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE))
.thenReturn(true); .thenReturn(true);
// node does not have the temporary aspect // node does not have the temporary aspect
when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY)) when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY))
.thenReturn(false); .thenReturn(false);
// node is not being processed for versioning // node is not being processed for versioning
when(mockedAlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS)) when(mockedAlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS))
.thenReturn(new HashMap<NodeRef, NodeRef>(Collections.singletonMap(anotherNodeRef, anotherNodeRef))); .thenReturn(new HashMap<NodeRef, NodeRef>(Collections.singletonMap(anotherNodeRef, anotherNodeRef)));
// auto version false // auto version false
when(mockedNodeService.getProperty(nodeRef, ContentModel.PROP_AUTO_VERSION)) when(mockedNodeService.getProperty(nodeRef, ContentModel.PROP_AUTO_VERSION))
.thenReturn(Boolean.TRUE); .thenReturn(Boolean.TRUE);
// execute behaviour // execute behaviour
extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType); extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType);
// verify other // verify other
verify(mockedNodeService).exists(nodeRef); verify(mockedNodeService).exists(nodeRef);
verify(mockedLockService).getLockStatus(nodeRef); verify(mockedLockService).getLockStatus(nodeRef);
@@ -392,9 +392,9 @@ public class ExtendedVersionableAspectUnitTest implements RecordsManagementModel
verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY); verify(mockedNodeService).hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY);
verify(mockedAlfrescoTransactionSupport, times(2)).getResource(KEY_VERSIONED_NODEREFS); verify(mockedAlfrescoTransactionSupport, times(2)).getResource(KEY_VERSIONED_NODEREFS);
verify(mockedNodeService).getProperty(nodeRef, ContentModel.PROP_AUTO_VERSION); verify(mockedNodeService).getProperty(nodeRef, ContentModel.PROP_AUTO_VERSION);
// assert the version was not created // assert the version was not created
verify(mockedVersionService).createVersion(eq(nodeRef), any(Map.class)); verify(mockedVersionService).createVersion(eq(nodeRef), any(Map.class));
} }
} }