/** Test the getPersonsInRole() service method. */ @Test public void testGetPersonsInRole() throws Exception { ProposalDevelopmentDocument doc = createProposal("Proposal-9", "000001"); PrincipalContract userChew = identityManagementService.getPrincipalByPrincipalName("chew"); kraAuthService.addDocumentLevelRole(userChew.getPrincipalId(), RoleConstants.AGGREGATOR, doc); List<String> persons = kraAuthService.getPrincipalsInRole(RoleConstants.AGGREGATOR, doc); assertEquals(2, persons.size()); }
/** Test the hasRole() service method. */ @Test public void testHasRole() throws Exception { ProposalDevelopmentDocument doc = createProposal("Proposal-7", "000001"); PrincipalContract userChew = identityManagementService.getPrincipalByPrincipalName("chew"); kraAuthService.addDocumentLevelRole( userChew.getPrincipalId(), RoleConstants.BUDGET_CREATOR, doc); assertTrue( kraAuthService.hasDocumentLevelRole( userChew.getPrincipalId(), RoleConstants.BUDGET_CREATOR, doc)); }
/** Test the hasPermission() service method. */ @Test public void testHasPermission() throws Exception { PrincipalContract userChew = identityManagementService.getPrincipalByPrincipalName("chew"); ProposalDevelopmentDocument doc = createProposal("Proposal-6", "000001"); kraAuthService.addDocumentLevelRole( userChew.getPrincipalId(), RoleConstants.NARRATIVE_WRITER, doc); assertTrue( kraAuthService.hasPermission( userChew.getPrincipalId(), doc, PermissionConstants.MODIFY_NARRATIVE)); assertFalse( kraAuthService.hasPermission( userChew.getPrincipalId(), doc, PermissionConstants.MODIFY_BUDGET)); }