Skip to content
This repository was archived by the owner on Nov 9, 2022. It is now read-only.

Commit c2e3c26

Browse files
author
Luis Martinez
committed
Included search for wf:user on Inbox and added test for dynamicUser and inbox
1 parent 3020dbb commit c2e3c26

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

src/test/suites/inclusive-gateway/inclusive-gateway-01.xqy

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ declare namespace ext = "http://marklogic.com/rest-api/resource/process";
3737

3838
declare variable $PROCESS-MODEL-NAME := test-constants:expected-model-id($test-constants:TEST-01-MODEL-NAME);
3939

40-
let $payload := element ext:createRequest{element ext:processName{$PROCESS-MODEL-NAME},element ext:data{element value{"A"}},element ext:attachments{}}
40+
let $payload := element ext:createRequest{element ext:processName{$PROCESS-MODEL-NAME},element ext:data{element value{"A"}, element assignTo{"admin"}},element ext:attachments{}}
4141
let $process-response := wrt:process-create($const:xml-options, $payload)[2]
4242
let $pid := $process-response/ext:createResponse/ext:processId/text()
4343
return
@@ -70,6 +70,44 @@ test:assert-equal(xs:string($process-state/ext:outcome/text()),"SUCCESS"),
7070
test:assert-equal("InclusiveGateway_1",fn:tokenize($current-state,"/")[fn:last()])
7171
)
7272
;
73+
74+
(: test inbox lists wf:user processinbox-read :)
75+
import module namespace test-constants = "http://marklogic.com/workflow/test-constants/inclusive-gateway" at "/test/suites/inclusive-gateway/lib/constants.xqy";
76+
import module namespace const="http://marklogic.com/roxy/workflow-constants" at "/test/workflow-constants.xqy";
77+
import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy";
78+
import module namespace test="http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy";
79+
declare namespace cpf = "http://marklogic.com/cpf";
80+
declare namespace ext = "http://marklogic.com/rest-api/resource/processinbox";
81+
declare namespace http = "xdmp:http";
82+
declare namespace prop = "http://marklogic.com/xdmp/property";
83+
declare namespace wf="http://marklogic.com/workflow";
84+
85+
let $_pause := xdmp:sleep(10000)
86+
let $test-pid := fn:doc(test-constants:test-pid-uri($test-constants:TEST-01-MODEL-NAME))/test-constants:pid/text()
87+
let $child-pid := /wf:process[fn:matches(wf:parent,$test-pid)]/@id/fn:string()
88+
let $result := wrt:test-08-processinbox-read($const:xml-options)
89+
return (
90+
test:assert-equal('200', xs:string($result[1]/http:code)),
91+
test:assert-equal('SUCCESS', xs:string($result[2]/ext:readResponse/ext:outcome)),
92+
test:assert-exists($result[2]/ext:readResponse/wf:inbox/wf:task[@processid=$child-pid]),
93+
let $task := $result[2]/ext:readResponse/wf:inbox/wf:task[@processid=$child-pid]
94+
return (
95+
test:assert-exists($task/wf:process-data/wf:process/wf:data),
96+
test:assert-exists($task/wf:process-data/wf:process/wf:attachments),
97+
test:assert-exists($task/wf:process-data/wf:process/wf:audit-trail),
98+
test:assert-exists($task/wf:process-data/wf:process/wf:metrics),
99+
test:assert-exists($task/wf:process-data/wf:process/wf:process-definition-name),
100+
let $properties := $task/wf:process-properties/prop:properties
101+
return (
102+
test:assert-equal('done', xs:string($properties/cpf:processing-status)),
103+
test:assert-equal('dynamicUser', xs:string($properties/wf:currentStep/wf:type)),
104+
test:assert-equal('admin', xs:string($properties/wf:currentStep/wf:user)),
105+
test:assert-equal('userTask', xs:string($properties/wf:currentStep/wf:step-type)),
106+
test:assert-equal('ENTERED', xs:string($properties/wf:currentStep/wf:step-status))
107+
)
108+
)
109+
);
110+
73111
(:
74112
Fork has not rendezvoused because there is a user task requiring completion. We therefore complete it
75113
:)
@@ -90,6 +128,7 @@ test:assert-equal(xs:string($update-response/ext:outcome/text()),"SUCCESS")
90128
(: Need to sleep to ensure asynchronous behaviour has completed :)
91129
xdmp:sleep(2000)
92130
;
131+
93132
(:
94133
Check process has rendezvoused and completed
95134
:)

src/test/suites/inclusive-gateway/test-data/InclusiveGatewayTest-01.bpmn

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<!-- origin at X=0.0 Y=0.0 -->
33
<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:xs="http://www.w3.org/2001/XMLSchema" id="_GqqWIBraEeiDzsBG-Hp4NA" exporter="org.eclipse.bpmn2.modeler.core" exporterVersion="1.4.2.Final-v20171109-1930-B1">
44
<bpmn2:itemDefinition id="ItemDefinition_18" isCollection="false" structureRef="xs:boolean"/>
5+
<bpmn2:itemDefinition id="ItemDefinition_922" isCollection="false" structureRef="xs:string"/>
6+
<bpmn2:resource id="Resource_1" name="DynamicUser"/>
57
<bpmn2:process id="Process_1" name="Process 1" isExecutable="false">
68
<bpmn2:startEvent id="StartEvent_1" name="Start">
79
<bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing>
@@ -22,6 +24,12 @@
2224
<bpmn2:userTask id="UserTask_1" name="TaskA">
2325
<bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
2426
<bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing>
27+
<bpmn2:humanPerformer id="HumanPerformer_1" name="Actor">
28+
<bpmn2:resourceRef>Resource_1</bpmn2:resourceRef>
29+
<bpmn2:resourceAssignmentExpression id="ResourceAssignmentExpression_1">
30+
<bpmn2:formalExpression id="FormalExpression_3" evaluatesToTypeRef="ItemDefinition_922" language="http://www.w3.org/1999/XPath">$wf:process/wf:data//assignTo/text()</bpmn2:formalExpression>
31+
</bpmn2:resourceAssignmentExpression>
32+
</bpmn2:humanPerformer>
2533
</bpmn2:userTask>
2634
<bpmn2:userTask id="UserTask_2" name="TaskB">
2735
<bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
@@ -55,13 +63,13 @@
5563
<bpmndi:BPMNShape id="BPMNShape_InclusiveGateway_1" bpmnElement="InclusiveGateway_1" isMarkerVisible="true">
5664
<dc:Bounds height="50.0" width="50.0" x="350.0" y="248.0"/>
5765
<bpmndi:BPMNLabel id="BPMNLabel_3" labelStyle="BPMNLabelStyle_1">
58-
<dc:Bounds height="48.0" width="58.0" x="346.0" y="298.0"/>
66+
<dc:Bounds height="22.0" width="76.0" x="337.0" y="298.0"/>
5967
</bpmndi:BPMNLabel>
6068
</bpmndi:BPMNShape>
6169
<bpmndi:BPMNShape id="BPMNShape_InclusiveGateway_2" bpmnElement="InclusiveGateway_2" isMarkerVisible="true">
6270
<dc:Bounds height="50.0" width="50.0" x="600.0" y="248.0"/>
6371
<bpmndi:BPMNLabel id="BPMNLabel_4" labelStyle="BPMNLabelStyle_1">
64-
<dc:Bounds height="48.0" width="69.0" x="591.0" y="298.0"/>
72+
<dc:Bounds height="22.0" width="76.0" x="587.0" y="298.0"/>
6573
</bpmndi:BPMNLabel>
6674
</bpmndi:BPMNShape>
6775
<bpmndi:BPMNShape id="BPMNShape_UserTask_1" bpmnElement="UserTask_1" isExpanded="true">

src/workflowengine/models/workflow-util.xqy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ declare function m:inbox($username as xs:string?) as element(wf:inbox) {
203203
(: TODO add cpf-active check, wf:status running check, wf:locked-user blank :)
204204
cts:properties-query(
205205
cts:element-query(xs:QName("wf:currentStep"),
206-
cts:element-value-query(xs:QName("wf:assignee"),($username,xdmp:get-current-user())[1])
206+
cts:element-value-query( ( xs:QName("wf:user"), xs:QName("wf:assignee")),($username,xdmp:get-current-user())[1])
207207
)
208208
)
209209
),("unfiltered") (: TODO ordering, prioritisation support, and so on :)

0 commit comments

Comments
 (0)