当前位置: 首页>>代码示例>>Java>>正文


Java DerivedRoleTypeServiceBase类代码示例

本文整理汇总了Java中org.kuali.rice.kns.kim.role.DerivedRoleTypeServiceBase的典型用法代码示例。如果您正苦于以下问题:Java DerivedRoleTypeServiceBase类的具体用法?Java DerivedRoleTypeServiceBase怎么用?Java DerivedRoleTypeServiceBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DerivedRoleTypeServiceBase类属于org.kuali.rice.kns.kim.role包,在下文中一共展示了DerivedRoleTypeServiceBase类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testHasApplicationRole

import org.kuali.rice.kns.kim.role.DerivedRoleTypeServiceBase; //导入依赖的package包/类
@Test public void testHasApplicationRole() throws Exception {
	WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), "ActionRequestDerivedRoleTypeServiceImplTest");
	
	// let's send an adhoc request to rkirkend
	document.adHocToPrincipal(ActionRequestType.APPROVE, "", getPrincipalIdForName("rkirkend"), "", true);
	document.route("");
	
	DerivedRoleTypeServiceBase roleTypeService = new ActionRequestDerivedRoleTypeServiceImpl();
	
	Map<String, String> qualifications = Collections
               .singletonMap(KimConstants.AttributeConstants.DOCUMENT_NUMBER, "" + document.getDocumentId());
	
	// rkirkend should have role as an approver
	assertTrue("rkirkend should have role.", roleTypeService.hasDerivedRole(getPrincipalIdForName("rkirkend"), null, null, APPROVE_REQUEST_RECIPIENT_ROLE_NAME, qualifications));
	
	// now verify it returns false for the non-adhoc case since we created request to rkirkend as an adhoc request
	assertFalse("rkirkend should not have role for non-adhoc (since this was an adhoc request)", roleTypeService.hasDerivedRole(getPrincipalIdForName("rkirkend"), null, null, NON_AD_HOC_APPROVE_REQUEST_RECIPIENT_ROLE_NAME, qualifications));
	
	// switch to bmcgough and send an acknowledge
	document = TestUtilities.switchByPrincipalName("bmcgough", document);
	document.adHocToPrincipal(ActionRequestType.ACKNOWLEDGE, "", getPrincipalIdForName("bmcgough"), "", true);
	assertTrue("bmcgough should have ack", document.isAcknowledgeRequested());
	
	// bmcgough should not have role as an approver
	assertFalse("bmcgough should not have role", roleTypeService.hasDerivedRole(getPrincipalIdForName("bmcgough"), null, null, APPROVE_REQUEST_RECIPIENT_ROLE_NAME, qualifications));
	// bmcgough should have role as an ack
	assertTrue("bmcgough should have role", roleTypeService.hasDerivedRole(getPrincipalIdForName("bmcgough"), null, null, ACKNOWLEDGE_REQUEST_RECIPIENT_ROLE_NAME, qualifications));
	// bmcgough should not have role as an fyi
	assertFalse("bmcgough should not have role", roleTypeService.hasDerivedRole(getPrincipalIdForName("bmcgough"), null, null, FYI_REQUEST_RECIPIENT_ROLE_NAME, qualifications));
	
	// now approve as "rkirkend", should generate a requeest to jhopf
	document = TestUtilities.switchByPrincipalName("rkirkend", document);
	assertTrue(document.isApprovalRequested());
	document.approve("");
	
	// jhopf should now have approve request, not as the result of an adhoc request
	document = TestUtilities.switchByPrincipalName("jhopf", document);
	assertTrue(document.isApprovalRequested());
	assertTrue("jhopf should have role", roleTypeService.hasDerivedRole(getPrincipalIdForName("jhopf"), null, null, APPROVE_REQUEST_RECIPIENT_ROLE_NAME, qualifications));
	assertTrue("jhopf should have role", roleTypeService.hasDerivedRole(getPrincipalIdForName("jhopf"), null, null, NON_AD_HOC_APPROVE_REQUEST_RECIPIENT_ROLE_NAME, qualifications));
	
	// send an fyi to "pmckown"
	document.adHocToPrincipal(ActionRequestType.FYI, "", getPrincipalIdForName("pmckown"), "", true);
	document = TestUtilities.switchByPrincipalName("pmckown", document);
	assertTrue(document.isFYIRequested());
	assertTrue("pmckown should have role", roleTypeService.hasDerivedRole(getPrincipalIdForName("pmckown"), null, null, FYI_REQUEST_RECIPIENT_ROLE_NAME, qualifications));
			
	// create a new doc and "save" as ewestfal, this should generate a "complete" request to ewestfal
	document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), "ActionRequestDerivedRoleTypeServiceImplTest");
	document.saveDocument("");
	assertTrue(document.isSaved());
	assertTrue(document.isCompletionRequested());
	assertTrue(document.isApprovalRequested());
	
	// the ActionRequestDerivedRoleTypeService does not consider COMPLETE and APPROVE to be the same, let's verify that's the case
	assertFalse("ewestfal should not have role", roleTypeService.hasDerivedRole(getPrincipalIdForName("ewestfal"), null, null, APPROVE_REQUEST_RECIPIENT_ROLE_NAME, qualifications));
	assertFalse("ewestfal should not have role", roleTypeService.hasDerivedRole(getPrincipalIdForName("ewestfal"), null, null, NON_AD_HOC_APPROVE_REQUEST_RECIPIENT_ROLE_NAME, qualifications));
	
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:60,代码来源:ActionRequestDerivedRoleTypeServiceImplTest.java


注:本文中的org.kuali.rice.kns.kim.role.DerivedRoleTypeServiceBase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。