本文整理汇总了Java中org.kuali.rice.kew.api.WorkflowDocument.switchPrincipal方法的典型用法代码示例。如果您正苦于以下问题:Java WorkflowDocument.switchPrincipal方法的具体用法?Java WorkflowDocument.switchPrincipal怎么用?Java WorkflowDocument.switchPrincipal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kuali.rice.kew.api.WorkflowDocument
的用法示例。
在下文中一共展示了WorkflowDocument.switchPrincipal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: routeTestDocs
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
* Routes some test docs for searching
* @return String[] of doc ids
*/
protected String[] routeTestDocs() {
// Route some test documents.
String[] docIds = new String[TestDocData.titles.length];
for (int i = 0; i < TestDocData.titles.length; i++) {
WorkflowDocument workflowDocument = WorkflowDocumentFactory.createDocument(
getPrincipalId(TestDocData.principalNames[i]), TestDocData.docTypeName);
workflowDocument.setTitle(TestDocData.titles[i]);
workflowDocument.setApplicationDocumentId(TestDocData.appDocIds[i]);
workflowDocument.route("routing this document.");
docIds[i] = workflowDocument.getDocumentId();
if (TestDocData.approverNames[i] != null) {
workflowDocument.switchPrincipal(getPrincipalId(TestDocData.approverNames[i]));
workflowDocument.approve("approving this document.");
}
workflowDocument.setApplicationDocumentStatus(TestDocData.appDocStatuses[i]);
workflowDocument.saveDocumentData();
}
return docIds;
}
示例2: test_SinglePeopleFlow_Parallel_Approve
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test
public void test_SinglePeopleFlow_Parallel_Approve() throws Exception {
createSimplePeopleFlow();
// now route a document to it
WorkflowDocument document = WorkflowDocumentFactory.createDocument(user3, SINGLE_PEOPLE_FLOW_PARALLEL_APPROVE);
document.route("");
assertTrue("Document should be enroute.", document.isEnroute());
// user3 should not have an approval request since they initiated the document
document.switchPrincipal(user3);
// user1, user2, and TestWorkgroup (of which ewestfal is a member) should have the request
assertApproveRequested(document, user1, user2, ewestfal);
// now approve as each, the document should be FINAL at the end
document.switchPrincipal(ewestfal);
document.approve("approving as ewestfal");
assertTrue("Document should still be enroute.", document.isEnroute());
document.switchPrincipal(user1);
document.approve("approving as user1");
assertTrue("Document should still be enroute.", document.isEnroute());
document.switchPrincipal(user2);
document.approve("approving as user2");
assertTrue("Document should now be FINAL.", document.isFinal());
}
示例3: test_SinglePeopleFlow_forceActionTrue
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
* Test to verify that when forceAction=true for a PeopleFlow member, even if they've already approved this
* workflow, they still get an approval request.
*
* <p>Simple PeopleFlow with the same member at 2 stops - </p>
*
* <pre>
*
* Priority 1:
* -> user1
* Priority 2:
* -> user2
* Priority3:
* -> user1 (forceAction = true)
*
* </pre>
*/
@Test
public void test_SinglePeopleFlow_forceActionTrue() throws Exception {
PeopleFlowDefinition.Builder peopleFlowBuilder = PeopleFlowDefinition.Builder.create(NAMESPACE_CODE, PEOPLE_FLOW_2);
peopleFlowBuilder.addPrincipal(user1).setPriority(1);
peopleFlowBuilder.addPrincipal(user2).setPriority(2);
peopleFlowBuilder.addPrincipal(user1).setPriority(3);
PeopleFlowDefinition peopleFlow = peopleFlowService.createPeopleFlow(peopleFlowBuilder.build());
RulesEngineExecutorMock.setPeopleFlowId(peopleFlow.getId());
// now route a document to it
WorkflowDocument document = WorkflowDocumentFactory.createDocument(user3, RULESENGINE_PEOPLEFLOW_PRIORITYPARALLEL_APPROVE);
document.route("");
assertTrue("Document should be enroute.", document.isEnroute());
assertApproveRequested(document, user1);
assertApproveNotRequested(document, user2, user3);
// approve as user1
document.switchPrincipal(user1);
document.approve("");
assertApproveRequested(document, user2);
assertApproveNotRequested(document, user1, user3);
document.switchPrincipal(user2);
document.approve("");
assertTrue(document.isEnroute());
// now user1 should have an approve request since forceAction is true
assertApproveRequested(document, user1);
assertApproveNotRequested(document, user2, user2);
// approve as user1
document.switchPrincipal(user1);
document.approve("");
assertTrue(document.isFinal());
}
示例4: testSimpleKrmsPeopleFlowRules
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test
public void testSimpleKrmsPeopleFlowRules() throws Exception {
WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("user3"), SIMPLE_DOCUMENT_TYPE);
document.route("");
assertTrue(document.isEnroute());
String user1 = getPrincipalIdForName("user1");
String user2 = getPrincipalIdForName("user2");
String ewestfal = getPrincipalIdForName("ewestfal"); // ewestfal is a member of TestWorkgroup
// at this point, the PeopleFlow should have triggered requests to user1, user2, and TestWorkgroup, in that order
// but only the request to user1 should be activated
document.switchPrincipal(ewestfal);
assertFalse(document.isApprovalRequested());
document.switchPrincipal(user2);
assertFalse(document.isApprovalRequested());
document.switchPrincipal(user1);
assertTrue(document.isApprovalRequested());
// now approve as user1
document.approve("");
assertTrue(document.isEnroute());
// should now be activated to user2
document.switchPrincipal(user2);
assertTrue(document.isApprovalRequested());
document.approve("");
assertTrue(document.isEnroute());
// should now be activated to TestWorkgroup, of which ewestfal is a member
document.switchPrincipal(ewestfal);
assertTrue(document.isApprovalRequested());
document.approve("");
// all approvals have been taken, document should now be final
assertTrue(document.isFinal());
}
示例5: testDocumentStatusSearching
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
* Tests searching on document status and document status category
*/
@Test public void testDocumentStatusSearching() {
String dt = "SearchDocType";
String pid = getPrincipalIdForName("quickstart");
WorkflowDocument initiated = WorkflowDocumentFactory.createDocument(pid, dt);
WorkflowDocument saved = WorkflowDocumentFactory.createDocument(pid, dt);
saved.saveDocument("saved");
assertEquals(DocumentStatus.SAVED, saved.getStatus());
WorkflowDocument enroute = WorkflowDocumentFactory.createDocument(pid, dt);
enroute.route("routed");
assertEquals(DocumentStatus.ENROUTE, enroute.getStatus());
WorkflowDocument exception = WorkflowDocumentFactory.createDocument(pid, dt);
exception.route("routed");
exception.placeInExceptionRouting("placed in exception routing");
assertEquals(DocumentStatus.EXCEPTION, exception.getStatus());
// no acks on this doc, can't test?
//WorkflowDocument processed = WorkflowDocumentFactory.createDocument(pid, dt);
//processed.route("routed");
WorkflowDocument finl = WorkflowDocumentFactory.createDocument(pid, dt);
finl.route("routed");
finl.switchPrincipal(getPrincipalId("jhopf"));
finl.approve("approved");
assertEquals(DocumentStatus.FINAL, finl.getStatus());
WorkflowDocument canceled = WorkflowDocumentFactory.createDocument(pid, dt);
canceled.cancel("canceled");
assertEquals(DocumentStatus.CANCELED, canceled.getStatus());
WorkflowDocument disapproved = WorkflowDocumentFactory.createDocument(pid, dt);
disapproved.route("routed");
disapproved.switchPrincipal(getPrincipalId("jhopf"));
RequestedActions ra = disapproved.getRequestedActions();
disapproved.disapprove("disapproved");
assertEquals(DocumentStatus.DISAPPROVED, disapproved.getStatus());
assertDocumentStatuses(dt, pid, 1, 1, 1, 1, 0, 1, 1, 1);
}
示例6: test_SinglePeopleFlow_Sequential_Approve
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test
public void test_SinglePeopleFlow_Sequential_Approve() throws Exception {
createSimplePeopleFlow();
// now route a document to it
WorkflowDocument document = WorkflowDocumentFactory.createDocument(user3, SINGLE_PEOPLE_FLOW_SEQUENTIAL_APPROVE);
document.route("");
assertTrue("Document should be enroute.", document.isEnroute());
// user3 should not have an approval request since they initiated the document
document.switchPrincipal(user3);
// document should be routed to user1, user2, and TestWorkgroup (of which "ewestfal" is a member) but only
// user1 request should be activated
List<ActionRequest> rootActionRequests = document.getRootActionRequests();
assertEquals("Should have 3 root action requests", 3, rootActionRequests.size());
ActionRequest user1Request = null;
ActionRequest user2Request = null;
ActionRequest testWorkgroupRequest = null;
for (ActionRequest actionRequest : rootActionRequests) {
RecipientType recipientType = actionRequest.getRecipientType();
if (recipientType == RecipientType.PRINCIPAL) {
if (user1.equals(actionRequest.getPrincipalId())) {
user1Request = actionRequest;
} else if (user2.equals(actionRequest.getPrincipalId())) {
user2Request = actionRequest;
}
} else if (recipientType == RecipientType.GROUP) {
if (testWorkgroup.equals(actionRequest.getGroupId())) {
testWorkgroupRequest = actionRequest;
}
}
}
// now let's ensure we got the requests we wanted
assertNotNull(user1Request);
assertEquals(ActionRequestStatus.ACTIVATED, user1Request.getStatus());
assertNotNull(user2Request);
assertEquals(ActionRequestStatus.INITIALIZED, user2Request.getStatus());
assertNotNull(testWorkgroupRequest);
assertEquals(ActionRequestStatus.INITIALIZED, testWorkgroupRequest.getStatus());
// let's double-check that before we start approving
assertApproveNotRequested(document, user2, ewestfal);
// user1 should have the request for approval, however
assertApproveRequested(document, user1);
// approve as user1
document.switchPrincipal(user1);
document.approve("");
// should still be enroute
assertTrue(document.isEnroute());
// now user1 should no longer have it, it should be activated approve to user2 with TestWorkgroup still initialized but not activated
assertApproveNotRequested(document, user1, ewestfal);
assertApproveRequested(document, user2);
// approve as user2
document.switchPrincipal(user2);
document.approve("");
// should still be enroute
assertTrue(document.isEnroute());
// now user1 and user2 have approved, should be activated to TestWorkgroup of which ewestfal is a member
assertApproveNotRequested(document, user2, user1);
// ewestfal should have an approve request because he is a member of TestWorkgroup
assertApproveRequested(document, ewestfal);
document.switchPrincipal(ewestfal);
document.approve("");
// now document should be final!
assertTrue(document.isFinal());
}
示例7: test_SinglePeopleFlow_forceActionFalse
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
* Test to verify that when forceAction=false for a PeopleFlow member, if they've already approved this
* workflow previously, they won't get another approval request.
*
* <p>Simple PeopleFlow with the same member at 2 stops - </p>
*
* <pre>
*
* Priority 1:
* -> user1
* Priority 2:
* -> user2
* Priority3:
* -> user1 (forceAction = false)
*
* </pre>
*/
@Test
public void test_SinglePeopleFlow_forceActionFalse() throws Exception {
PeopleFlowDefinition.Builder peopleFlowBuilder = PeopleFlowDefinition.Builder.create(NAMESPACE_CODE, PEOPLE_FLOW_2);
PeopleFlowMember.Builder member1 = peopleFlowBuilder.addPrincipal(user1);
member1.setPriority(1);
member1.setForceAction(false);
PeopleFlowMember.Builder member2 = peopleFlowBuilder.addPrincipal(user2);
member2.setPriority(2);
member2.setForceAction(false);
PeopleFlowMember.Builder member3 = peopleFlowBuilder.addPrincipal(user1);
member3.setPriority(3);
member3.setForceAction(false);
PeopleFlowDefinition peopleFlow = peopleFlowService.createPeopleFlow(peopleFlowBuilder.build());
RulesEngineExecutorMock.setPeopleFlowId(peopleFlow.getId());
// now route a document to it
// WorkflowDocument document = WorkflowDocumentFactory.createDocument(user3, SINGLE_PEOPLE_FLOW_PRIORITY_PARALLEL_APPROVE);
WorkflowDocument document = WorkflowDocumentFactory.createDocument(user3, RULESENGINE_PEOPLEFLOW_PRIORITYPARALLEL_APPROVE);
document.route("");
assertTrue("Document should be enroute.", document.isEnroute());
assertApproveRequested(document, user1);
assertApproveNotRequested(document, user2, user3);
// approve as user1
document.switchPrincipal(user1);
document.approve("");
assertApproveRequested(document, user2);
assertApproveNotRequested(document, user1, user3);
document.switchPrincipal(user2);
document.approve("");
// Since user1 already approved, and forceAction=false, the doc should go right to final
assertTrue(document.isFinal());
}
示例8: test_PrincipalMember_roleDelegate
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
* Defines a PeopleFlow as follows:
*
* <pre>
*
* Priority 1:
* -> testuser3
* ----> ppfTestRole2 - primary delegate
*
* </pre>
*
* this test will ensure that the delegate, a role, is properly delegated to when the primary responsible party is
* a principal.
*/
@Test
public void test_PrincipalMember_roleDelegate() throws Exception {
PeopleFlowMember.Builder member = PeopleFlowMember.Builder.create(testuser3, MemberType.PRINCIPAL);
PeopleFlowDelegate.Builder delegate = PeopleFlowDelegate.Builder.create(ppfTestRole2, MemberType.ROLE);
delegate.setDelegationType(DelegationType.PRIMARY);
delegate.setActionRequestPolicy(ActionRequestPolicy.FIRST);
createSimplePeopleFlow(PEOPLE_FLOW_8, member, delegate);
// now route a document to it
WorkflowDocument document = WorkflowDocumentFactory.createDocument(user3, ROLE_DELEGATE_PEOPLE_FLOW_PRINCIPAL_MEMBER_HAS_ROLE_DELEGATE);
document.route("");
assertTrue("Document should be enroute.", document.isEnroute());
// testuser3 and delegate user2 (as member of ppfTestRole2) should have
// activated requests, make sure the requests look correct
List<ActionRequest> rootActionRequests = document.getRootActionRequests();
assertEquals("Should have 1 root action requests", 1, rootActionRequests.size());
ActionRequest testuser3Request = null;
for (ActionRequest actionRequest : rootActionRequests) {
RecipientType recipientType = actionRequest.getRecipientType();
if (recipientType == RecipientType.PRINCIPAL) {
if (testuser3.equals(actionRequest.getPrincipalId())) {
testuser3Request = actionRequest;
}
}
}
// now let's ensure we got the requests we wanted
assertNotNull(testuser3Request);
assertEquals(ActionRequestStatus.ACTIVATED, testuser3Request.getStatus());
// check delegate requests on testuser3Request now
assertEquals(1, testuser3Request.getChildRequests().size());
ActionRequest user2Request = testuser3Request.getChildRequests().get(0);
assertEquals(user2, user2Request.getPrincipalId());
assertEquals(DelegationType.PRIMARY, user2Request.getDelegationType());
assertEquals(ActionRequestStatus.ACTIVATED, user2Request.getStatus());
// let's run through the approvals for this peopleflow
assertApproveRequested(document, user2, testuser3);
assertApproveNotRequested(document, user1, user3, testuser1, testuser2, ewestfal);
// approve as user2 who is the lone member of testrole2
document.switchPrincipal(user2);
document.approve("");
// at this point all priorty1 folks should have approvals
assertApproveNotRequested(document, user2, testuser3);
// document should now be FINAL!
assertTrue(document.isFinal());
}
示例9: test_RoleMember_principalDelegate
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
* Defines a PeopleFlow as follows:
*
* <pre>
*
* Priority 1:
* -> ppfTestRole2
* ----> testuser3 - primary delegate
*
* </pre>
*
* ensure that the delegate, a principal, gets the requests when the member is a role
*/
@Test
public void test_RoleMember_principalDelegate() throws Exception {
PeopleFlowMember.Builder member = PeopleFlowMember.Builder.create(ppfTestRole2, MemberType.ROLE);
member.setActionRequestPolicy(ActionRequestPolicy.FIRST);
PeopleFlowDelegate.Builder delegate = PeopleFlowDelegate.Builder.create(testuser3, MemberType.PRINCIPAL);
delegate.setDelegationType(DelegationType.PRIMARY);
createSimplePeopleFlow(PEOPLE_FLOW_9, member, delegate);
// now route a document to it
WorkflowDocument document = WorkflowDocumentFactory.createDocument(user3, ROLE_DELEGATE_PEOPLE_FLOW_ROLE_MEMBER_HAS_PRINCIPAL_DELEGATE);
document.route("");
assertTrue("Document should be enroute.", document.isEnroute());
// user2 (as member of ppfTestRole2) and delegate testuser3 should have
// activated requests, make sure the requests look correct
List<ActionRequest> rootActionRequests = document.getRootActionRequests();
assertEquals("Should have 1 root action requests", 1, rootActionRequests.size());
ActionRequest user2Request = null;
for (ActionRequest actionRequest : rootActionRequests) {
RecipientType recipientType = actionRequest.getRecipientType();
if (recipientType == RecipientType.PRINCIPAL) {
if (user2.equals(actionRequest.getPrincipalId())) {
user2Request = actionRequest;
}
}
}
// now let's ensure we got the requests we wanted
assertNotNull(user2Request);
assertEquals(ActionRequestStatus.ACTIVATED, user2Request.getStatus());
// check delegate requests on testuser3Request now
assertEquals(1, user2Request.getChildRequests().size());
ActionRequest testuser3Request = user2Request.getChildRequests().get(0);
assertEquals(testuser3, testuser3Request.getPrincipalId());
assertEquals(DelegationType.PRIMARY, testuser3Request.getDelegationType());
assertEquals(ActionRequestStatus.ACTIVATED, testuser3Request.getStatus());
// let's run through the approvals for this peopleflow
assertApproveRequested(document, user2, testuser3);
assertApproveNotRequested(document, user1, user3, testuser1, testuser2, ewestfal);
// approve as testuser3, the delegate
document.switchPrincipal(testuser3);
document.approve("");
// at this point all priorty1 folks should have approvals
assertApproveNotRequested(document, user2, testuser3);
// document should now be FINAL!
assertTrue(document.isFinal());
}
示例10: test_RoleDelegate_justKimDelegate
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
* Defines a PeopleFlow as follows:
*
* <pre>
*
* Priority 1:
* -> ppfTestRole1 (has delegate ewestfal defined in KIM)
*
* </pre>
*
* The desired behavior is that the KIM delegate gets requests
*/
@Test
public void test_RoleDelegate_justKimDelegate() throws Exception {
createSimpleRoleDelegatePeopleFlow(PEOPLE_FLOW_4, // PeopleFlow name
ppfTestRole1, // member role ID
null, // no delegate
null // ^^ so no DelegationType
);
// now route a document to it
WorkflowDocument document = WorkflowDocumentFactory.createDocument(user3, ROLE_DELEGATE_PEOPLE_FLOW_JUST_KIM_DELEGATE);
document.route("");
assertTrue("Document should be enroute.", document.isEnroute());
// user1 (as member of ppfTestRole1) and ewestfal (as user1's primary KIM delegate for ppfTestRole1) should have
// activated requests, make sure the requests look correct
List<ActionRequest> rootActionRequests = document.getRootActionRequests();
assertEquals("Should have 1 root action requests", 1, rootActionRequests.size());
ActionRequest user1Request = null;
for (ActionRequest actionRequest : rootActionRequests) {
RecipientType recipientType = actionRequest.getRecipientType();
if (recipientType == RecipientType.PRINCIPAL) {
if (user1.equals(actionRequest.getPrincipalId())) {
user1Request = actionRequest;
}
}
}
// now let's ensure we got the requests we wanted
assertNotNull(user1Request);
assertEquals(ActionRequestStatus.ACTIVATED, user1Request.getStatus());
// check delegate requests on user1Request now
assertEquals(1, user1Request.getChildRequests().size());
ActionRequest ewestfalDelegateRequest = user1Request.getChildRequests().get(0);
assertEquals(ewestfal, ewestfalDelegateRequest.getPrincipalId());
assertEquals(DelegationType.PRIMARY, ewestfalDelegateRequest.getDelegationType());
assertEquals(ActionRequestStatus.ACTIVATED, ewestfalDelegateRequest.getStatus());
// let's run through the approvals for this peopleflow
assertApproveRequested(document, user1, ewestfal);
assertApproveNotRequested(document, user2, user3, testuser1, testuser2, testuser3);
// approve as ewestfal who is user1's primary KIM delegate for testrole1
document.switchPrincipal(ewestfal);
document.approve("");
// at this point all priorty1 folks should have approvals
assertApproveNotRequested(document, user1, ewestfal);
// document should now be FINAL!
assertTrue(document.isFinal());
}
示例11: test_RoleDelegate_primaryDelegateRole
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
* Defines a PeopleFlow as follows:
*
* <pre>
*
* Priority 1:
* -> ppfTestRole1 (has delegate ewestfal defined in KIM)
* ----> ppfTestRole2 - primary delegate
*
* </pre>
*
* The desired behavior is that the delegate defined in the PeopleFlow gets the requests, overriding the KIM
* delegate which gets ignored. Since the delegation type is 'primary', only ppfTestRole2's member gets requests.
*/
@Test
public void test_RoleDelegate_primaryDelegateRole() throws Exception {
createSimpleRoleDelegatePeopleFlow(PEOPLE_FLOW_5, // PeopleFlow name
ppfTestRole1, // member role ID
ppfTestRole2, // delegate role ID
DelegationType.PRIMARY);
// now route a document to it
WorkflowDocument document = WorkflowDocumentFactory.createDocument(user3, ROLE_DELEGATE_PEOPLE_FLOW_PRIMARY_DELEGATE);
document.route("");
assertTrue("Document should be enroute.", document.isEnroute());
// user1 (as member of ppfTestRole1) and user2 (as a member of user1's primary delegate role for ppfTestRole1)
// should have activated requests, make sure the requests look correct
List<ActionRequest> rootActionRequests = document.getRootActionRequests();
assertEquals("Should have 1 root action requests", 1, rootActionRequests.size());
ActionRequest user1Request = null;
for (ActionRequest actionRequest : rootActionRequests) {
RecipientType recipientType = actionRequest.getRecipientType();
if (recipientType == RecipientType.PRINCIPAL) {
if (user1.equals(actionRequest.getPrincipalId())) {
user1Request = actionRequest;
}
}
}
// now let's ensure we got the requests we wanted
assertNotNull(user1Request);
assertEquals(ActionRequestStatus.ACTIVATED, user1Request.getStatus());
// check delegate requests on user1Request now
assertEquals(1, user1Request.getChildRequests().size());
ActionRequest user2DelegateRequest = user1Request.getChildRequests().get(0);
assertEquals(user2, user2DelegateRequest.getPrincipalId());
assertEquals(DelegationType.PRIMARY, user2DelegateRequest.getDelegationType());
assertEquals(ActionRequestStatus.ACTIVATED, user2DelegateRequest.getStatus());
// let's run through the approvals for this peopleflow
assertApproveRequested(document, user1, user2);
assertApproveNotRequested(document, user3, testuser1, testuser2, testuser3, ewestfal);
// approve as user2 who is user1's primary PPF delegate for testrole1
document.switchPrincipal(user2);
document.approve("");
// at this point all priorty1 folks should have approvals
assertApproveNotRequested(document, user1, user2);
// document should now be FINAL!
assertTrue(document.isFinal());
}
示例12: test_RoleDelegate_secondaryDelegateRole
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
* Defines a PeopleFlow as follows:
*
* <pre>
*
* Priority 1:
* -> ppfTestRole1 (has delegate ewestfal defined in KIM)
* ----> ppfTestRole2 - secondary delegate
*
* </pre>
*
* The desired behavior is that the delegate defined in the PeopleFlow gets the requests, overriding the KIM
* delegate which gets ignored. Since the delegation type is 'secondary', both ppfTestRole1 and ppfTestRole2 get
* requests.
*/
@Test
public void test_RoleDelegate_secondaryDelegateRole() throws Exception {
createSimpleRoleDelegatePeopleFlow(
PEOPLE_FLOW_6, // PeopleFlow name
ppfTestRole1, // member role ID
ppfTestRole2, // delegate role ID
DelegationType.SECONDARY
);
// now route a document to it
WorkflowDocument document = WorkflowDocumentFactory.createDocument(user3, ROLE_DELEGATE_PEOPLE_FLOW_SECONDARY_DELEGATE);
document.route("");
assertTrue("Document should be enroute.", document.isEnroute());
// user1 (as member of ppfTestRole1) and user2 (as a member of user1's primary delegate role for ppfTestRole1)
// should have activated requests, make sure the requests look correct
List<ActionRequest> rootActionRequests = document.getRootActionRequests();
assertEquals("Should have 1 root action requests", 1, rootActionRequests.size());
ActionRequest user1Request = null;
for (ActionRequest actionRequest : rootActionRequests) {
RecipientType recipientType = actionRequest.getRecipientType();
if (recipientType == RecipientType.PRINCIPAL) {
if (user1.equals(actionRequest.getPrincipalId())) {
user1Request = actionRequest;
}
}
}
// now let's ensure we got the requests we wanted
assertNotNull(user1Request);
assertEquals(ActionRequestStatus.ACTIVATED, user1Request.getStatus());
// check delegate requests on user1Request now
assertEquals(1, user1Request.getChildRequests().size());
ActionRequest user2DelegateRequest = user1Request.getChildRequests().get(0);
assertEquals(user2, user2DelegateRequest.getPrincipalId());
assertEquals(DelegationType.SECONDARY, user2DelegateRequest.getDelegationType());
assertEquals(ActionRequestStatus.ACTIVATED, user2DelegateRequest.getStatus());
// let's run through the approvals for this peopleflow
assertApproveRequested(document, user1, user2);
assertApproveNotRequested(document, user3, testuser1, testuser2, testuser3, ewestfal);
// approve as user2 who is user1's primary PPF delegate for testrole1
document.switchPrincipal(user2);
document.approve("");
// at this point all priorty1 folks should have approvals
assertApproveNotRequested(document, user1, user2);
// document should now be FINAL!
assertTrue(document.isFinal());
}
示例13: test_RoleDelegate_delegateRoleHasKimDelegate
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
* Defines a PeopleFlow as follows:
*
* <pre>
*
* Priority 1:
* -> ppfTestRole2
* ----> ppfTestRole1 - primary delegate (+ has delegate ewestfal defined in KIM)
*
* </pre>
*
* KEW is limited to only one level of delegation, so the behavior will be to respect the delegate defined in the
* PeopleFlow, but ignore the KIM delegate otherwise we'd have to add support for multi-level delegation. Since
* the PeopleFlow delegation is 'primary', ppfTestRole1 will get the requests.
*/
@Test
public void test_RoleDelegate_delegateRoleHasKimDelegate() throws Exception {
createSimpleRoleDelegatePeopleFlow(PEOPLE_FLOW_7, // PeopleFlow name
ppfTestRole2, // member role ID
ppfTestRole1, // delegate role ID
DelegationType.PRIMARY);
// now route a document to it
WorkflowDocument document = WorkflowDocumentFactory.createDocument(user3, ROLE_DELEGATE_PEOPLE_FLOW_DELEGATE_ROLE_HAS_KIM_DELEGATE);
document.route("");
assertTrue("Document should be enroute.", document.isEnroute());
// user2 (as member of ppfTestRole2) and user1 (as a member of user1's primary delegate role for ppfTestRole2)
// should have activated requests, make sure the requests look correct
List<ActionRequest> rootActionRequests = document.getRootActionRequests();
assertEquals("Should have 1 root action requests", 1, rootActionRequests.size());
ActionRequest user2Request = null;
for (ActionRequest actionRequest : rootActionRequests) {
RecipientType recipientType = actionRequest.getRecipientType();
if (recipientType == RecipientType.PRINCIPAL) {
if (user2.equals(actionRequest.getPrincipalId())) {
user2Request = actionRequest;
}
}
}
// now let's ensure we got the requests we wanted
assertNotNull(user2Request);
assertEquals(ActionRequestStatus.ACTIVATED, user2Request.getStatus());
// check delegate requests on user1Request now
assertEquals(1, user2Request.getChildRequests().size());
ActionRequest user1DelegateRequest = user2Request.getChildRequests().get(0);
assertEquals(user1, user1DelegateRequest.getPrincipalId());
assertEquals(DelegationType.PRIMARY, user1DelegateRequest.getDelegationType());
assertEquals(ActionRequestStatus.ACTIVATED, user1DelegateRequest.getStatus());
// let's run through the approvals for this peopleflow
assertApproveRequested(document, user1, user2);
assertApproveNotRequested(document, user3, testuser1, testuser2, testuser3, ewestfal);
// approve as user1 who is user2's primary PPF delegate for testrole2
document.switchPrincipal(user1);
document.approve("");
// at this point all priorty1 folks should have approvals
assertApproveNotRequested(document, user1, user2);
// document should now be FINAL!
assertTrue(document.isFinal());
}
示例14: test_FirstApproveRolePeopleFlow
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test
public void test_FirstApproveRolePeopleFlow() throws Exception {
createFirstApproveRolePeopleFlow();
WorkflowDocument document = WorkflowDocumentFactory.createDocument(user3, SINGLE_PEOPLE_FLOW_PRIORITY_PARALLEL_APPROVE);
document.route("");
assertTrue("Document should be enroute.", document.isEnroute());
// should have 1 root requests which is a role request with 2 children, one a principal request to the "admin"
// principal, and one a group request to the WorkflowAdmin group
List<ActionRequest> rootActionRequests = document.getRootActionRequests();
assertEquals(1, rootActionRequests.size());
ActionRequest roleRequest = rootActionRequests.get(0);
assertEquals(ActionRequestPolicy.FIRST, roleRequest.getRequestPolicy());
assertEquals(roleId, roleRequest.getRoleName());
assertEquals(RecipientType.ROLE, roleRequest.getRecipientType());
assertEquals(2, roleRequest.getChildRequests().size());
for (ActionRequest childRequest : roleRequest.getChildRequests()) {
if (RecipientType.PRINCIPAL.equals(childRequest.getRecipientType())) {
assertEquals(getPrincipalIdForName("admin"), childRequest.getPrincipalId());
} else if (RecipientType.GROUP.equals(childRequest.getRecipientType())) {
assertEquals(getGroupIdForName("KR-WKFLW", "WorkflowAdmin"), childRequest.getGroupId());
} else {
fail("Found a child request i didn't expect with a recipient type of: " + childRequest.getRecipientType());
}
}
// should be able to approve as a member of the group on Technical Administrator role (which is WorkflowAdmin) as
// well as the 'admin' principal
document.switchPrincipal(getPrincipalNameForId("admin"));
assertTrue(document.isApprovalRequested());
document.switchPrincipal(getPrincipalIdForName("bmcgough"));
assertTrue(document.isApprovalRequested());
// now approve as a member of WorkflowAdmin
document.approve("");
// document should now be final because it's first approve
assertTrue(document.isFinal());
// now try it by approving as admin, and ensure that the first approval works as well in that case
document = WorkflowDocumentFactory.createDocument(user3, SINGLE_PEOPLE_FLOW_PRIORITY_PARALLEL_APPROVE);
document.route("");
assertTrue("Document should be enroute.", document.isEnroute());
document.switchPrincipal(getPrincipalIdForName("bmcgough"));
assertTrue(document.isApprovalRequested());
document.switchPrincipal(getPrincipalNameForId("admin"));
assertTrue(document.isApprovalRequested());
// now approve as admin
document.approve("");
// document should now be final because it's first approve
assertTrue(document.isFinal());
}
示例15: test_AllApproveRolePeopleFlow
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test
public void test_AllApproveRolePeopleFlow() throws Exception {
createAllApproveRolePeopleFlow();
WorkflowDocument document = WorkflowDocumentFactory.createDocument(user3, SINGLE_PEOPLE_FLOW_PRIORITY_PARALLEL_APPROVE);
document.route("");
assertTrue("Document should be enroute.", document.isEnroute());
// should have 1 root requests which is a role request with 2 children, one a principal request to the "admin"
// principal, and one a group request to the WorkflowAdmin group
List<ActionRequest> rootActionRequests = document.getRootActionRequests();
assertEquals(1, rootActionRequests.size());
ActionRequest roleRequest = rootActionRequests.get(0);
assertEquals(ActionRequestPolicy.ALL, roleRequest.getRequestPolicy());
assertEquals(roleId, roleRequest.getRoleName());
assertEquals(RecipientType.ROLE, roleRequest.getRecipientType());
assertEquals(2, roleRequest.getChildRequests().size());
for (ActionRequest childRequest : roleRequest.getChildRequests()) {
if (RecipientType.PRINCIPAL.equals(childRequest.getRecipientType())) {
assertEquals(getPrincipalIdForName("admin"), childRequest.getPrincipalId());
} else if (RecipientType.GROUP.equals(childRequest.getRecipientType())) {
assertEquals(getGroupIdForName("KR-WKFLW", "WorkflowAdmin"), childRequest.getGroupId());
} else {
fail("Found a child request i didn't expect with a recipient type of: " + childRequest.getRecipientType());
}
}
// should be able to approve as a member of the group on Technical Administrator role (which is WorkflowAdmin) as
// well as the 'admin' principal
document.switchPrincipal(getPrincipalNameForId("admin"));
assertTrue(document.isApprovalRequested());
document.switchPrincipal(getPrincipalIdForName("bmcgough"));
assertTrue(document.isApprovalRequested());
// now approve as a member of WorkflowAdmin
document.approve("");
// document should still be enroute because this is an all approve situation and both the group and admin need to approve
assertTrue(document.isEnroute());
assertFalse(document.isApprovalRequested());
document.switchPrincipal(getPrincipalNameForId("admin"));
assertTrue(document.isApprovalRequested());
document.approve("");
// after approving as admin, the last of the two role requests have been completed, document should be final
assertTrue(document.isFinal());
}