Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BZ-1169161 - [JBPM-4518] JBossUserGroupCallbackImpl should support "o…
…rg.jbpm.ht.user.separator" property to customize "Group Id" separator for groups (cherry picked from commit 0cfaa5e)
- Loading branch information
1 parent
23a0e88
commit 9716261
Showing
4 changed files
with
245 additions
and
2 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
99 changes: 99 additions & 0 deletions
99
jbpm-test/src/test/java/org/jbpm/test/tasks/identity/JBossUserGroupCallbackTest.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,99 @@ | ||
package org.jbpm.test.tasks.identity; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Properties; | ||
|
||
import org.jbpm.services.task.identity.JBossUserGroupCallbackImpl; | ||
import org.jbpm.test.JbpmJUnitBaseTestCase; | ||
import org.junit.AfterClass; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.kie.api.runtime.KieSession; | ||
import org.kie.api.runtime.manager.RuntimeEngine; | ||
import org.kie.api.runtime.manager.RuntimeManager; | ||
import org.kie.api.runtime.process.ProcessInstance; | ||
import org.kie.api.task.TaskService; | ||
import org.kie.api.task.model.TaskSummary; | ||
import org.kie.internal.runtime.manager.context.EmptyContext; | ||
|
||
/** | ||
* This JUnit test is testing JBossUserGroupCallbackImpl with "," included in a Group ID of User Task | ||
*/ | ||
public class JBossUserGroupCallbackTest extends JbpmJUnitBaseTestCase { | ||
|
||
public JBossUserGroupCallbackTest() { | ||
super(true, true); | ||
} | ||
|
||
@BeforeClass | ||
public static void setupOnce() { | ||
System.setProperty("org.jbpm.ht.user.separator", "#"); | ||
} | ||
|
||
@AfterClass | ||
public static void cleanupOnce() { | ||
System.clearProperty("org.jbpm.ht.user.separator"); | ||
} | ||
|
||
@Before | ||
public void configure() { | ||
Properties properties = new Properties(); | ||
properties.setProperty("krisv", "krisvgg"); | ||
properties.setProperty("mary", "maryg,g"); | ||
properties.setProperty("john", "johngg"); | ||
|
||
userGroupCallback = new JBossUserGroupCallbackImpl(properties); | ||
} | ||
|
||
@Test | ||
public void testProcess() throws Exception { | ||
|
||
RuntimeManager manager = createRuntimeManager(Strategy.PROCESS_INSTANCE, "default", "CustomSeparatorGroupIdUserTaskTest.bpmn"); | ||
RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get()); | ||
KieSession ksession = runtime.getKieSession(); | ||
|
||
// start a new process instance | ||
Map<String, Object> params = new HashMap<String, Object>(); | ||
ProcessInstance pi = ksession.startProcess("com.sample.bpmn.hello", params); | ||
System.out.println("A process instance started : pid = " + pi.getId()); | ||
|
||
Assert.assertEquals(ProcessInstance.STATE_ACTIVE, pi.getState()); | ||
|
||
TaskService taskService = runtime.getTaskService(); | ||
|
||
List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK"); | ||
System.out.println("Listing if the there are any tasks for john to complete: list= " + list); | ||
Assert.assertEquals(1, list.size()); | ||
|
||
for (TaskSummary taskSummary : list) { | ||
System.out.println("john starts a task : taskId = " + taskSummary.getId()); | ||
taskService.start(taskSummary.getId(), "john"); | ||
System.out.println("john started the task : taskId = " + taskSummary.getId() + ", which had assigned to Group/Owner: " + taskService.getTaskById(taskSummary.getId()).getPeopleAssignments().getPotentialOwners()); | ||
taskService.complete(taskSummary.getId(), "john", null); | ||
System.out.println("john completed the task ."); | ||
} | ||
|
||
List<TaskSummary> taskList = taskService.getTasksAssignedAsPotentialOwner("mary", "en-UK"); | ||
Assert.assertEquals(1, taskList.size()); | ||
for (TaskSummary taskSummary : taskList) { | ||
System.out.println("mary starts a task : taskId = " + taskSummary.getId() + ", which had assigned to Group/Owner: " + taskService.getTaskById(taskSummary.getId()).getPeopleAssignments().getPotentialOwners()); | ||
taskService.start(taskSummary.getId(), "mary"); | ||
System.out.println("mary started the task : taskId = " + taskSummary.getId()); | ||
taskService.complete(taskSummary.getId(), "mary", null); | ||
System.out.println("mary completed the task ."); | ||
} | ||
|
||
assertProcessInstanceCompleted(pi.getId(), ksession); | ||
System.out.println("Process Instance with id: '" + pi.getId() + "' , got completed successfully."); | ||
|
||
manager.disposeRuntimeEngine(runtime); | ||
|
||
|
||
} | ||
|
||
|
||
} |
136 changes: 136 additions & 0 deletions
136
jbpm-test/src/test/resources/CustomSeparatorGroupIdUserTaskTest.bpmn
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,136 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:g="http://www.jboss.org/drools/flow/gpd" xmlns:tns="http://www.jboss.org/drools" xmlns="http://www.jboss.org/drools" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd http://www.jboss.org/drools drools.xsd http://www.bpsim.org/schemas/1.0 bpsim.xsd" id="Definition" expressionLanguage="http://www.mvel.org/2.0" targetNamespace="http://www.jboss.org/drools" typeLanguage="http://www.java.com/javaTypes"> | ||
<bpmn2:process id="com.sample.bpmn.hello" tns:version="1" tns:packageName="defaultPackage" tns:adHoc="false" name="Sample Process" isExecutable="true" processType="Private"> | ||
<bpmn2:startEvent id="_1" name="Start"> | ||
<bpmn2:outgoing>_1-UserTask_1</bpmn2:outgoing> | ||
</bpmn2:startEvent> | ||
<bpmn2:userTask id="UserTask_1" name="UserTask 1"> | ||
<bpmn2:extensionElements> | ||
<tns:onEntry-script scriptFormat="http://www.java.com/java"> | ||
<tns:script>System.out.println("UserTask1 Entered...");</tns:script> | ||
</tns:onEntry-script> | ||
<tns:onExit-script scriptFormat="http://www.java.com/java"> | ||
<tns:script>System.out.println("UserTask1 Completed...");</tns:script> | ||
</tns:onExit-script> | ||
</bpmn2:extensionElements> | ||
<bpmn2:incoming>_1-UserTask_1</bpmn2:incoming> | ||
<bpmn2:outgoing>UserTask_1-UserTask_2</bpmn2:outgoing> | ||
<bpmn2:ioSpecification id="InputOutputSpecification_1"> | ||
<bpmn2:dataInput id="UserTask_1_TaskNameInput" name="TaskName"/> | ||
<bpmn2:dataInput id="UserTask_1_GroupIdInput" name="GroupId"/> | ||
<bpmn2:dataInput id="UserTask_1_NodeNameInput" name="NodeName"/> | ||
<bpmn2:inputSet id="InputSet_1"> | ||
<bpmn2:dataInputRefs>UserTask_1_TaskNameInput</bpmn2:dataInputRefs> | ||
<bpmn2:dataInputRefs>UserTask_1_GroupIdInput</bpmn2:dataInputRefs> | ||
<bpmn2:dataInputRefs>UserTask_1_NodeNameInput</bpmn2:dataInputRefs> | ||
</bpmn2:inputSet> | ||
<bpmn2:outputSet id="OutputSet_1"/> | ||
</bpmn2:ioSpecification> | ||
<bpmn2:dataInputAssociation id="DataInputAssociation_1"> | ||
<bpmn2:targetRef>UserTask_1_TaskNameInput</bpmn2:targetRef> | ||
<bpmn2:assignment id="Assignment_1"> | ||
<bpmn2:from xsi:type="bpmn2:tFormalExpression" id="FormalExpression_1">UserTask 1</bpmn2:from> | ||
<bpmn2:to xsi:type="bpmn2:tFormalExpression" id="FormalExpression_2">UserTask_1_TaskNameInput</bpmn2:to> | ||
</bpmn2:assignment> | ||
</bpmn2:dataInputAssociation> | ||
<bpmn2:dataInputAssociation id="DataInputAssociation_2"> | ||
<bpmn2:targetRef>UserTask_1_GroupIdInput</bpmn2:targetRef> | ||
<bpmn2:assignment id="Assignment_2"> | ||
<bpmn2:from xsi:type="bpmn2:tFormalExpression" id="FormalExpression_3">test#johngg#marym</bpmn2:from> | ||
<bpmn2:to xsi:type="bpmn2:tFormalExpression" id="FormalExpression_4">UserTask_1_GroupIdInput</bpmn2:to> | ||
</bpmn2:assignment> | ||
</bpmn2:dataInputAssociation> | ||
<bpmn2:dataInputAssociation id="DataInputAssociation_3"> | ||
<bpmn2:targetRef>UserTask_1_NodeNameInput</bpmn2:targetRef> | ||
<bpmn2:assignment id="Assignment_3"> | ||
<bpmn2:from xsi:type="bpmn2:tFormalExpression" id="FormalExpression_5">UserTask 1</bpmn2:from> | ||
<bpmn2:to xsi:type="bpmn2:tFormalExpression" id="FormalExpression_6">UserTask_1_NodeNameInput</bpmn2:to> | ||
</bpmn2:assignment> | ||
</bpmn2:dataInputAssociation> | ||
</bpmn2:userTask> | ||
<bpmn2:userTask id="UserTask_2" name="User Task 2"> | ||
<bpmn2:extensionElements> | ||
<tns:onEntry-script scriptFormat="http://www.java.com/java"> | ||
<tns:script>System.out.println("UserTask2 Entered...");</tns:script> | ||
</tns:onEntry-script> | ||
<tns:onExit-script scriptFormat="http://www.java.com/java"> | ||
<tns:script>System.out.println("UserTask2 Completed...");</tns:script> | ||
</tns:onExit-script> | ||
</bpmn2:extensionElements> | ||
<bpmn2:incoming>UserTask_1-UserTask_2</bpmn2:incoming> | ||
<bpmn2:outgoing>UserTask_2-EndEvent_1</bpmn2:outgoing> | ||
<bpmn2:ioSpecification id="InputOutputSpecification_2"> | ||
<bpmn2:dataInput id="UserTask_2_TaskNameInput" name="TaskName"/> | ||
<bpmn2:dataInput id="UserTask_2_GroupIdInput" name="GroupId"/> | ||
<bpmn2:dataInput id="UserTask_2_NodeNameInput" name="NodeName"/> | ||
<bpmn2:inputSet id="InputSet_2"> | ||
<bpmn2:dataInputRefs>UserTask_2_TaskNameInput</bpmn2:dataInputRefs> | ||
<bpmn2:dataInputRefs>UserTask_2_GroupIdInput</bpmn2:dataInputRefs> | ||
<bpmn2:dataInputRefs>UserTask_2_NodeNameInput</bpmn2:dataInputRefs> | ||
</bpmn2:inputSet> | ||
<bpmn2:outputSet id="OutputSet_2"/> | ||
</bpmn2:ioSpecification> | ||
<bpmn2:dataInputAssociation id="DataInputAssociation_4"> | ||
<bpmn2:targetRef>UserTask_2_TaskNameInput</bpmn2:targetRef> | ||
<bpmn2:assignment id="Assignment_4"> | ||
<bpmn2:from xsi:type="bpmn2:tFormalExpression" id="FormalExpression_7">UserTask 2</bpmn2:from> | ||
<bpmn2:to xsi:type="bpmn2:tFormalExpression" id="FormalExpression_8">UserTask_2_TaskNameInput</bpmn2:to> | ||
</bpmn2:assignment> | ||
</bpmn2:dataInputAssociation> | ||
<bpmn2:dataInputAssociation id="DataInputAssociation_5"> | ||
<bpmn2:targetRef>UserTask_2_GroupIdInput</bpmn2:targetRef> | ||
<bpmn2:assignment id="Assignment_5"> | ||
<bpmn2:from xsi:type="bpmn2:tFormalExpression" id="FormalExpression_9">johngg#maryg,g#test</bpmn2:from> | ||
<bpmn2:to xsi:type="bpmn2:tFormalExpression" id="FormalExpression_10">UserTask_2_GroupIdInput</bpmn2:to> | ||
</bpmn2:assignment> | ||
</bpmn2:dataInputAssociation> | ||
<bpmn2:dataInputAssociation id="DataInputAssociation_6"> | ||
<bpmn2:targetRef>UserTask_2_NodeNameInput</bpmn2:targetRef> | ||
<bpmn2:assignment id="Assignment_6"> | ||
<bpmn2:from xsi:type="bpmn2:tFormalExpression" id="FormalExpression_11">User Task 2</bpmn2:from> | ||
<bpmn2:to xsi:type="bpmn2:tFormalExpression" id="FormalExpression_12">UserTask_2_NodeNameInput</bpmn2:to> | ||
</bpmn2:assignment> | ||
</bpmn2:dataInputAssociation> | ||
</bpmn2:userTask> | ||
<bpmn2:endEvent id="EndEvent_1" name="End"> | ||
<bpmn2:incoming>UserTask_2-EndEvent_1</bpmn2:incoming> | ||
</bpmn2:endEvent> | ||
<bpmn2:sequenceFlow id="_1-UserTask_1" tns:priority="1" name="" sourceRef="_1" targetRef="UserTask_1"/> | ||
<bpmn2:sequenceFlow id="UserTask_1-UserTask_2" tns:priority="1" name="" sourceRef="UserTask_1" targetRef="UserTask_2"/> | ||
<bpmn2:sequenceFlow id="UserTask_2-EndEvent_1" tns:priority="1" name="" sourceRef="UserTask_2" targetRef="EndEvent_1"/> | ||
</bpmn2:process> | ||
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> | ||
<bpmndi:BPMNPlane id="BPMNPlane_Process_1" bpmnElement="com.sample.bpmn.hello"> | ||
<bpmndi:BPMNShape id="BPMNShape_StartEvent_1" bpmnElement="_1"> | ||
<dc:Bounds height="48.0" width="48.0" x="39.0" y="39.0"/> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="BPMNShape_UserTask_1" bpmnElement="UserTask_1"> | ||
<dc:Bounds height="50.0" width="110.0" x="186.0" y="38.0"/> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="BPMNShape_UserTask_2" bpmnElement="UserTask_2"> | ||
<dc:Bounds height="50.0" width="110.0" x="401.0" y="38.0"/> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="BPMNShape_EndEvent_1" bpmnElement="EndEvent_1"> | ||
<dc:Bounds height="48.0" width="48.0" x="573.0" y="39.0"/> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="_1-UserTask_1" sourceElement="BPMNShape_StartEvent_1" targetElement="BPMNShape_UserTask_1"> | ||
<di:waypoint xsi:type="dc:Point" x="63.0" y="63.0"/> | ||
<di:waypoint xsi:type="dc:Point" x="177.0" y="63.0"/> | ||
<di:waypoint xsi:type="dc:Point" x="177.0" y="63.0"/> | ||
<di:waypoint xsi:type="dc:Point" x="241.0" y="63.0"/> | ||
</bpmndi:BPMNEdge> | ||
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="UserTask_1-UserTask_2" sourceElement="BPMNShape_UserTask_1" targetElement="BPMNShape_UserTask_2"> | ||
<di:waypoint xsi:type="dc:Point" x="241.0" y="63.0"/> | ||
<di:waypoint xsi:type="dc:Point" x="392.0" y="63.0"/> | ||
<di:waypoint xsi:type="dc:Point" x="392.0" y="63.0"/> | ||
<di:waypoint xsi:type="dc:Point" x="456.0" y="63.0"/> | ||
</bpmndi:BPMNEdge> | ||
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="UserTask_2-EndEvent_1" sourceElement="BPMNShape_UserTask_2" targetElement="BPMNShape_EndEvent_1"> | ||
<di:waypoint xsi:type="dc:Point" x="456.0" y="63.0"/> | ||
<di:waypoint xsi:type="dc:Point" x="559.0" y="63.0"/> | ||
<di:waypoint xsi:type="dc:Point" x="559.0" y="63.0"/> | ||
<di:waypoint xsi:type="dc:Point" x="597.0" y="63.0"/> | ||
</bpmndi:BPMNEdge> | ||
</bpmndi:BPMNPlane> | ||
</bpmndi:BPMNDiagram> | ||
</bpmn2:definitions> |