diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceService.java index c372d08d4f..a6752fdc8d 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceService.java @@ -50,6 +50,7 @@ public interface SecurityClearanceService * * @param userName The username of the user. * @param clearanceId The identifier for the new clearance level. + * @return the user's security clearance */ - void setUserSecurityClearance(String userName, String clearanceId); + SecurityClearance setUserSecurityClearance(String userName, String clearanceId); } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceServiceImpl.java index e801822beb..2b2a6b43f5 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceServiceImpl.java @@ -106,7 +106,7 @@ public class SecurityClearanceServiceImpl extends ServiceBaseImpl implements Sec } @Override - public void setUserSecurityClearance(String userName, String clearanceId) + public SecurityClearance setUserSecurityClearance(String userName, String clearanceId) { ParameterCheck.mandatoryString("userName", userName); ParameterCheck.mandatoryString("clearanceId", clearanceId); @@ -117,5 +117,7 @@ public class SecurityClearanceServiceImpl extends ServiceBaseImpl implements Sec classificationService.getClassificationLevelById(clearanceId); nodeService.setProperty(personNode, PROP_CLEARANCE_LEVEL, clearanceId); + + return getUserSecurityClearance(userName); } } diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceServiceImplUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceServiceImplUnitTest.java index 0cdf616d3c..615a02b1d2 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceServiceImplUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/SecurityClearanceServiceImplUnitTest.java @@ -41,9 +41,6 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import java.io.Serializable; -import java.util.Map; - /** * Unit tests for {@link SecurityClearanceServiceImpl}. * @@ -99,19 +96,31 @@ public class SecurityClearanceServiceImplUnitTest } /** Check that a user can have their clearance set. */ - @Test public void setUserSecurityClearance_updateClearance() + @Test public void setUserSecurityClearance_setClearance() { // Create the user. String userName = "User 1"; + NodeRef personNode = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, userName); + PersonInfo personInfo = new PersonInfo(personNode, userName, "user", "two"); + when(mockPersonService.getPerson(userName, false)).thenReturn(personNode); + when(mockPersonService.getPerson(personNode)).thenReturn(personInfo); + // Create the clearance. String clearanceId = "ClearanceId"; ClassificationLevel level = new ClassificationLevel(clearanceId, "TopSecretKey"); when(mockClassificationService.getClassificationLevelById(clearanceId)).thenReturn(level); + when(mockNodeService.hasAspect(personNode, ASPECT_SECURITY_CLEARANCE)).thenReturn(true); + when(mockNodeService.getProperty(personNode, PROP_CLEARANCE_LEVEL)).thenReturn(clearanceId); + + // Call the method under test. - securityClearanceServiceImpl.setUserSecurityClearance(userName, clearanceId); + SecurityClearance securityClearance = securityClearanceServiceImpl.setUserSecurityClearance(userName, clearanceId); + + assertEquals(personInfo, securityClearance.getPersonInfo()); + assertEquals(level, securityClearance.getClearanceLevel()); verify(mockNodeService).setProperty(personNode, PROP_CLEARANCE_LEVEL, clearanceId); }