Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
158 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
...orkflow-impl/src/test/java/com/evolveum/midpoint/wf/impl/policy/other/TestDelegation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* | ||
* Copyright (c) 2010-2017 Evolveum | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.evolveum.midpoint.wf.impl.policy.other; | ||
|
||
import com.evolveum.midpoint.model.api.WorkflowService; | ||
import com.evolveum.midpoint.prism.PrismObject; | ||
import com.evolveum.midpoint.prism.PrismReferenceValue; | ||
import com.evolveum.midpoint.schema.SearchResultList; | ||
import com.evolveum.midpoint.schema.constants.ObjectTypes; | ||
import com.evolveum.midpoint.schema.result.OperationResult; | ||
import com.evolveum.midpoint.schema.util.ObjectTypeUtil; | ||
import com.evolveum.midpoint.task.api.Task; | ||
import com.evolveum.midpoint.test.util.TestUtil; | ||
import com.evolveum.midpoint.util.exception.ConfigurationException; | ||
import com.evolveum.midpoint.util.exception.ObjectNotFoundException; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
import com.evolveum.midpoint.util.exception.SecurityViolationException; | ||
import com.evolveum.midpoint.wf.impl.activiti.ActivitiEngine; | ||
import com.evolveum.midpoint.wf.impl.policy.AbstractWfTestPolicy; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.Collections; | ||
|
||
import static com.evolveum.midpoint.test.util.TestUtil.assertSuccess; | ||
import static com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemDelegationMethodType.DEPUTY; | ||
import static org.testng.AssertJUnit.assertEquals; | ||
|
||
/** | ||
* @author mederly | ||
*/ | ||
@ContextConfiguration(locations = {"classpath:ctx-workflow-test-main.xml"}) | ||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) | ||
public class TestDelegation extends AbstractWfTestPolicy { | ||
|
||
@Override | ||
protected PrismObject<UserType> getDefaultActor() { | ||
return userAdministrator; | ||
} | ||
|
||
@Autowired | ||
private ActivitiEngine activitiEngine; | ||
|
||
@Autowired | ||
private WorkflowService workflowService; | ||
|
||
String workItemId; | ||
|
||
@Test | ||
public void test100CreateTask() throws Exception { | ||
final String TEST_NAME = "test100CreateTask"; | ||
TestUtil.displayTestTile(this, TEST_NAME); | ||
login(userAdministrator); | ||
|
||
Task task = createTask(TEST_NAME); | ||
OperationResult result = task.getResult(); | ||
|
||
assignRole(userJackOid, roleRole1aOid, task, result); // should start approval process | ||
assertNotAssignedRole(userJackOid, roleRole1aOid, task, result); | ||
|
||
WorkItemType workItem = getWorkItem(task, result); | ||
workItemId = workItem.getWorkItemId(); | ||
|
||
assertRefEquals("Wrong assigneeRef", ort(userLead1Oid), workItem.getAssigneeRef()); | ||
assertEquals("Wrong # of delegates", 0, workItem.getDelegateRef().size()); | ||
} | ||
|
||
private WorkItemType getWorkItem(Task task, OperationResult result) | ||
throws SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException { | ||
SearchResultList<WorkItemType> itemsAll = modelService.searchContainers(WorkItemType.class, null, null, task, result); | ||
assertEquals("Wrong # of total work items", 1, itemsAll.size()); | ||
return itemsAll.get(0); | ||
} | ||
|
||
@Test | ||
public void test110DelegateToUser2() throws Exception { | ||
final String TEST_NAME = "test110DelegateToUser2"; | ||
TestUtil.displayTestTile(this, TEST_NAME); | ||
login(userAdministrator); | ||
|
||
Task task = createTask(TEST_NAME); | ||
OperationResult result = task.getResult(); | ||
|
||
workflowService.delegateWorkItem(workItemId, Collections.singletonList(prv(userLead2Oid)), DEPUTY, result); | ||
|
||
result.computeStatus(); | ||
assertSuccess(result); | ||
|
||
WorkItemType workItem = getWorkItem(task, result); | ||
assertRefEquals("Wrong assigneeRef", ort(userLead1Oid), workItem.getAssigneeRef()); | ||
assertEquals("Wrong # of delegates", 1, workItem.getDelegateRef().size()); | ||
assertRefEquals("Wrong delegateRef", ort(userLead2Oid), workItem.getDelegateRef().get(0)); | ||
|
||
} | ||
|
||
private ObjectReferenceType ort(String oid) { | ||
return ObjectTypeUtil.createObjectRef(oid, ObjectTypes.USER); | ||
} | ||
|
||
private PrismReferenceValue prv(String oid) { | ||
return ObjectTypeUtil.createObjectRef(oid, ObjectTypes.USER).asReferenceValue(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters