Skip to content

Commit 3fa553f

Browse files
authored
Fix typo in IdentityService binding name in VariableScopeResolver (#4242)
1 parent 2221ac2 commit 3fa553f

3 files changed

Lines changed: 57 additions & 0 deletions

File tree

‎modules/flowable-engine/src/main/java/org/flowable/engine/impl/scripting/VariableScopeResolver.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public class VariableScopeResolver implements Resolver {
4444
"managementService", ProcessEngineConfiguration::getManagementService,
4545
"historyService", ProcessEngineConfiguration::getHistoryService,
4646
"formService", ProcessEngineConfiguration::getFormService,
47+
"identityService", ProcessEngineConfiguration::getIdentityService,
48+
// the identity service was historically exposed under this name, kept for backwards compatibility
4749
"identityServiceKey", ProcessEngineConfiguration::getIdentityService
4850
);
4951

‎modules/flowable-engine/src/test/java/org/flowable/examples/bpmn/scripttask/ScriptTaskTest.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@ public void testAutoStoreVariables() {
8080
assertThat(((Number) runtimeService.getVariable(id, "sum")).intValue()).isEqualTo(42);
8181
}
8282

83+
@Test
84+
@Deployment
85+
public void testIdentityServiceAvailableInScript() {
86+
identityService.saveUser(identityService.newUser("kermit"));
87+
try {
88+
String id = runtimeService.startProcessInstanceByKey("identityServiceInScript").getId();
89+
assertThat(runtimeService.getVariable(id, "userCount")).isEqualTo(1L);
90+
// the identity service is still available under its former name
91+
assertThat(runtimeService.getVariable(id, "legacyUserCount")).isEqualTo(1L);
92+
} finally {
93+
identityService.deleteUser("kermit");
94+
}
95+
}
96+
8397
@Test
8498
@Deployment
8599
public void testInputVariables() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed under the Apache License, Version 2.0 (the "License");
4+
~ you may not use this file except in compliance with the License.
5+
~ You may obtain a copy of the License at
6+
~
7+
~ http://www.apache.org/licenses/LICENSE-2.0
8+
~
9+
~ Unless required by applicable law or agreed to in writing, software
10+
~ distributed under the License is distributed on an "AS IS" BASIS,
11+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
~ See the License for the specific language governing permissions and
13+
~ limitations under the License.
14+
-->
15+
16+
<definitions id="definitions"
17+
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
18+
xmlns:flowable="http://flowable.org/bpmn"
19+
targetNamespace="Examples">
20+
21+
<process id="identityServiceInScript">
22+
23+
<startEvent id="theStart"/>
24+
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="script1"/>
25+
26+
<scriptTask id="script1" scriptFormat="groovy" flowable:autoStoreVariables="false">
27+
<script><![CDATA[
28+
execution.setVariable('userCount', identityService.createUserQuery().count());
29+
execution.setVariable('legacyUserCount', identityServiceKey.createUserQuery().count());
30+
]]></script>
31+
</scriptTask>
32+
<sequenceFlow id="flow2" sourceRef="script1" targetRef="theTask"/>
33+
34+
<userTask id="theTask" name="keep-alive task"/>
35+
<sequenceFlow id="flow3" sourceRef="theTask" targetRef="theEnd"/>
36+
37+
<endEvent id="theEnd"/>
38+
39+
</process>
40+
41+
</definitions>

0 commit comments

Comments
 (0)