Skip to content
This repository was archived by the owner on Nov 9, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ return (
return (
test:assert-equal('done', xs:string($properties/processingStatus)),
test:assert-equal('user', xs:string($properties/currentStep/type)),
test:assert-equal('admin', xs:string($properties/currentStep/assignee)),
test:assert-equal('admin', xs:string($properties/currentStep/user)),
test:assert-equal('userTask', xs:string($properties/currentStep/stepType)),
test:assert-equal('ENTERED', xs:string($properties/currentStep/stepStatus))
)
Expand Down
14 changes: 7 additions & 7 deletions src/test/suites/e2e-rest-process-xml/015-processmodel-xml.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ declare namespace http = "xdmp:http";

let $process := wrt:processmodel-create ($const:xml-options, "015-restapi-tests.bpmn")
let $_testlog := xdmp:log("E2E XML TEST: 01-processmodel-create")
return (
return (
test:assert-equal('200', xs:string($process[1]/http:code)),
test:assert-equal('SUCCESS', xs:string($process[2]/ext:createResponse/ext:outcome)),
test:assert-equal('015-restapi-tests__1__0', xs:string($process[2]/ext:createResponse/ext:modelId))
test:assert-equal('015-restapi-tests__1__0', xs:string($process[2]/ext:createResponse/ext:modelId))
);
(:
<ext:createResponse xmlns:ext="http://marklogic.com/rest-api/resource/processmodel">
Expand Down Expand Up @@ -46,10 +46,10 @@ declare namespace http = "xdmp:http";

let $result := wrt:test-03-processmodel-update($const:xml-options)
let $_testlog := xdmp:log("E2E XML TEST: 03-processmodel-update")
return (
return (
test:assert-equal('200', xs:string($result[1]/http:code)),
test:assert-equal('SUCCESS', xs:string($result[2]/ext:createResponse/ext:outcome)),
test:assert-equal('015-restapi-tests__1__2', xs:string($result[2]/ext:createResponse/ext:modelId))
test:assert-equal('015-restapi-tests__1__2', xs:string($result[2]/ext:createResponse/ext:modelId))
);
(:
<ext:createResponse xmlns:ext="http://marklogic.com/rest-api/resource/processmodel">
Expand All @@ -68,10 +68,10 @@ declare namespace http = "xdmp:http";
let $_testlog := xdmp:log("E2E XML TEST: 04-processmodel-publish")
(: not working with XML ? :)
let $result := wrt:processmodel-publish($const:xml-options, "015-restapi-tests__1__2")
return (
return (
test:assert-equal('200', xs:string($result[1]/http:code)),
test:assert-equal('SUCCESS', xs:string($result[2]/ext:updateResponse/ext:outcome)),
test:assert-exists(xs:string($result[2]/ext:updateResponse/ext:domainId))
test:assert-exists(xs:string($result[2]/ext:updateResponse/ext:domainId))
);
(:
<ext:updateResponse xmlns:ext="http://marklogic.com/rest-api/resource/processmodel">
Expand Down Expand Up @@ -153,7 +153,7 @@ return (
return (
test:assert-equal('done', xs:string($properties/cpf:processing-status)),
test:assert-equal('user', xs:string($properties/wf:currentStep/wf:type)),
test:assert-equal('admin', xs:string($properties/wf:currentStep/wf:assignee)),
test:assert-equal('admin', xs:string($properties/wf:currentStep/wf:user)),
test:assert-equal('userTask', xs:string($properties/wf:currentStep/wf:step-type)),
test:assert-equal('ENTERED', xs:string($properties/wf:currentStep/wf:step-status))
)
Expand Down
59 changes: 51 additions & 8 deletions src/test/suites/inclusive-gateway/inclusive-gateway-01.xqy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(:
This test checks that for an inclusive gateway with two downstream routes, only one of which is activated,
This test checks that for an inclusive gateway with two downstream routes, only one of which is activated,
rendezvousing is conditional only on the activated task being completed.
:)
:)
(:
Create process model for Inclusive Gateway Test 01, and check it has been created correctly
:)
Expand All @@ -23,7 +23,7 @@ return
(
test:assert-equal(xs:string($model-response/model:createResponse/model:outcome/text()),"SUCCESS"),
test:assert-equal(xs:string($model-response/model:createResponse/model:modelId/text()),test-constants:expected-model-id($test-constants:TEST-01-MODEL-NAME))
)
)
;
(:
Create process for Inclusive Gateway Test 01. Check success. Check pid exists and save.
Expand All @@ -37,7 +37,7 @@ declare namespace ext = "http://marklogic.com/rest-api/resource/process";

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

let $payload := element ext:createRequest{element ext:processName{$PROCESS-MODEL-NAME},element ext:data{element value{"A"}},element ext:attachments{}}
let $payload := element ext:createRequest{element ext:processName{$PROCESS-MODEL-NAME},element ext:data{element value{"A"}, element assignTo{"admin"}},element ext:attachments{}}
let $process-response := wrt:process-create($const:xml-options, $payload)[2]
let $pid := $process-response/ext:createResponse/ext:processId/text()
return
Expand All @@ -48,7 +48,7 @@ return
)
;
(: Need to sleep to ensure asynchronous behaviour has completed :)
xdmp:sleep(2000)
xdmp:sleep(5000)
;
(:
Check process has entered the first gateway ( and effectively stopped there )
Expand All @@ -66,10 +66,51 @@ let $process-state := wrt:process-read($const:xml-options,$test-pid)[2]/ext:read
let $current-state := ($process-state/ext:document/wf:process/wf:audit-trail/wf:audit)[fn:last()]/wf:state/text()
return
(
test:assert-equal(xs:string($process-state/ext:outcome/text()),"SUCCESS"),
test:assert-equal("InclusiveGateway_1",fn:tokenize($current-state,"/")[fn:last()])
test:assert-equal(xs:string($process-state/ext:outcome/text()),"SUCCESS"),
test:assert-equal("InclusiveGateway_1",fn:tokenize($current-state,"/")[fn:last()])
)
;
(: Need to sleep to ensure asynchronous behaviour has completed :)
xdmp:sleep(10000)
;

(: test inbox lists wf:user processinbox-read :)
import module namespace test-constants = "http://marklogic.com/workflow/test-constants/inclusive-gateway" at "/test/suites/inclusive-gateway/lib/constants.xqy";
import module namespace const="http://marklogic.com/roxy/workflow-constants" at "/test/workflow-constants.xqy";
import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy";
import module namespace test="http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy";
declare namespace cpf = "http://marklogic.com/cpf";
declare namespace ext = "http://marklogic.com/rest-api/resource/processinbox";
declare namespace http = "xdmp:http";
declare namespace prop = "http://marklogic.com/xdmp/property";
declare namespace wf="http://marklogic.com/workflow";

let $test-pid := fn:doc(test-constants:test-pid-uri($test-constants:TEST-01-MODEL-NAME))/test-constants:pid/text()
let $test-pid := fn:substring-before($test-pid, "+") (: some platforms not handling timezone well :)
let $child-pid := /wf:process[fn:matches(wf:parent,$test-pid)]/@id/fn:string()
let $result := wrt:test-08-processinbox-read($const:xml-options)
return (
test:assert-equal('200', xs:string($result[1]/http:code)),
test:assert-equal('SUCCESS', xs:string($result[2]/ext:readResponse/ext:outcome)),
test:assert-exists($result[2]/ext:readResponse/wf:inbox/wf:task[@processid=$child-pid]),
let $task := $result[2]/ext:readResponse/wf:inbox/wf:task[@processid=$child-pid]
return (
test:assert-exists($task/wf:process-data/wf:process/wf:data),
test:assert-exists($task/wf:process-data/wf:process/wf:attachments),
test:assert-exists($task/wf:process-data/wf:process/wf:audit-trail),
test:assert-exists($task/wf:process-data/wf:process/wf:metrics),
test:assert-exists($task/wf:process-data/wf:process/wf:process-definition-name),
let $properties := $task/wf:process-properties/prop:properties
return (
test:assert-equal('done', xs:string($properties/cpf:processing-status)),
test:assert-equal('dynamicUser', xs:string($properties/wf:currentStep/wf:type)),
test:assert-equal('admin', xs:string($properties/wf:currentStep/wf:user)),
test:assert-equal('userTask', xs:string($properties/wf:currentStep/wf:step-type)),
test:assert-equal('ENTERED', xs:string($properties/wf:currentStep/wf:step-status))
)
)
);

(:
Fork has not rendezvoused because there is a user task requiring completion. We therefore complete it
:)
Expand All @@ -82,14 +123,16 @@ declare namespace wf = "http://marklogic.com/workflow";
declare namespace ext = "http://marklogic.com/rest-api/resource/process";

let $test-pid := fn:doc(test-constants:test-pid-uri($test-constants:TEST-01-MODEL-NAME))/test-constants:pid/text()
let $test-pid := fn:substring-before($test-pid, "+") (: some platforms not handling timezone well :)
let $child-pid := /wf:process[fn:matches(wf:parent,$test-pid)]/@id/fn:string()
let $update-response := wrt:call-complete-on-pid($const:xml-options,$child-pid)/ext:updateResponse
return
test:assert-equal(xs:string($update-response/ext:outcome/text()),"SUCCESS")
test:assert-equal(xs:string($update-response/ext:outcome/text()),"SUCCESS")
;
(: Need to sleep to ensure asynchronous behaviour has completed :)
xdmp:sleep(2000)
;

(:
Check process has rendezvoused and completed
:)
Expand Down
29 changes: 14 additions & 15 deletions src/test/suites/inclusive-gateway/inclusive-gateway-02.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ return
(
test:assert-equal(xs:string($model-response/model:createResponse/model:outcome/text()),"SUCCESS"),
test:assert-equal(xs:string($model-response/model:createResponse/model:modelId/text()),test-constants:expected-model-id($test-constants:TEST-02-MODEL-NAME))
)
)
;
(:
Create process for Inclusive Gateway Test 02. Check success. Check pid exists and save.
Expand All @@ -47,9 +47,7 @@ return
)
;
(: Need to sleep to ensure asynchronous behaviour has completed :)
import module namespace test-config = "http://marklogic.com/roxy/test-config" at "/test/test-config.xqy";

test-config:test-sleep()
xdmp:sleep(10000)
;
(:
Check process has entered the first gateway ( and effectively stopped there )
Expand All @@ -67,10 +65,9 @@ let $process-state := wrt:process-read($const:xml-options,$test-pid)[2]/ext:read
let $current-state := ($process-state/ext:document/wf:process/wf:audit-trail/wf:audit)[fn:last()]/wf:state/text()
return
(
test:assert-equal(xs:string($process-state/ext:outcome/text()),"SUCCESS"),
test:assert-equal("InclusiveGateway_1",fn:tokenize($current-state,"/")[fn:last()])
)
;
test:assert-equal("SUCCESS", xs:string($process-state/ext:outcome/text())),
test:assert-equal("InclusiveGateway_1", fn:tokenize($current-state,"/")[fn:last()])
);
(:
Fork has not rendezvoused because there are user tasks requiring completion. We complete the first one.
:)
Expand All @@ -83,10 +80,11 @@ declare namespace wf = "http://marklogic.com/workflow";
declare namespace ext = "http://marklogic.com/rest-api/resource/process";

let $test-pid := fn:doc(test-constants:test-pid-uri($test-constants:TEST-02-MODEL-NAME))/test-constants:pid/text()
let $test-pid := fn:substring-before($test-pid, "+") (: some platforms not handling timezone well :)
let $child-pid := (/wf:process[fn:matches(wf:parent,$test-pid)]/@id/fn:string())[1]
let $update-response := wrt:call-complete-on-pid($const:xml-options,$child-pid)/ext:updateResponse
return
test:assert-equal(xs:string($update-response/ext:outcome/text()),"SUCCESS")
test:assert-equal(xs:string($update-response/ext:outcome/text()),"SUCCESS")
;
(: Need to sleep to ensure asynchronous behaviour has completed :)
import module namespace test-config = "http://marklogic.com/roxy/test-config" at "/test/test-config.xqy";
Expand All @@ -110,8 +108,8 @@ let $penultimate-state := ($process-state/ext:document/wf:process/wf:audit-trail
let $current-state := ($process-state/ext:document/wf:process/wf:audit-trail/wf:audit)[fn:last()]/wf:state/text()
return
(
test:assert-equal(xs:string($process-state/ext:outcome/text()),"SUCCESS"),
test:assert-equal("InclusiveGateway_1",fn:tokenize($current-state,"/")[fn:last()])
test:assert-equal(xs:string($process-state/ext:outcome/text()),"SUCCESS"),
test:assert-equal("InclusiveGateway_1",fn:tokenize($current-state,"/")[fn:last()])
)
;
(:
Expand All @@ -126,10 +124,11 @@ declare namespace wf = "http://marklogic.com/workflow";
declare namespace ext = "http://marklogic.com/rest-api/resource/process";

let $test-pid := fn:doc(test-constants:test-pid-uri($test-constants:TEST-02-MODEL-NAME))/test-constants:pid/text()
let $test-pid := fn:substring-before($test-pid, "+") (: some platforms not handling timezone well :)
let $child-pid := (/wf:process[fn:matches(wf:parent,$test-pid)]/@id/fn:string())[2]
let $update-response := wrt:call-complete-on-pid($const:xml-options,$child-pid)/ext:updateResponse
return
test:assert-equal(xs:string($update-response/ext:outcome/text()),"SUCCESS")
test:assert-equal(xs:string($update-response/ext:outcome/text()),"SUCCESS")
;
(: Need to sleep to ensure asynchronous behaviour has completed :)
import module namespace test-config = "http://marklogic.com/roxy/test-config" at "/test/test-config.xqy";
Expand All @@ -153,8 +152,8 @@ let $penultimate-state := ($process-state/ext:document/wf:process/wf:audit-trail
let $current-state := ($process-state/ext:document/wf:process/wf:audit-trail/wf:audit)[fn:last()]/wf:state/text()
return
(
test:assert-equal(xs:string($process-state/ext:outcome/text()),"SUCCESS"),
test:assert-equal("EndEvent_1",fn:tokenize($current-state,"/")[fn:last()]),
test:assert-equal("InclusiveGateway_1__rv",fn:tokenize($penultimate-state,"/")[fn:last()])
test:assert-equal(xs:string($process-state/ext:outcome/text()),"SUCCESS"),
test:assert-equal("EndEvent_1",fn:tokenize($current-state,"/")[fn:last()]),
test:assert-equal("InclusiveGateway_1__rv",fn:tokenize($penultimate-state,"/")[fn:last()])
)
;
2 changes: 1 addition & 1 deletion src/test/suites/inclusive-gateway/lib/constants.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ declare function test-pid-uri($model-name as xs:string) as xs:string{
declare function save-pid($pid,$model-name){
let $pid-content := element test-constants:pid{$pid}
return
xdmp:document-insert(test-pid-uri($model-name),$pid-content)
xdmp:document-insert(test-pid-uri($model-name),$pid-content)
};

29 changes: 4 additions & 25 deletions src/test/suites/inclusive-gateway/suite-teardown.xqy
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
import module namespace test-constants = "http://marklogic.com/workflow/test-constants/inclusive-gateway" at "/test/suites/inclusive-gateway/lib/constants.xqy";
import module namespace const="http://marklogic.com/roxy/workflow-constants" at "/test/workflow-constants.xqy";
import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy";
import module namespace test = "http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy";

declare namespace ext = "http://marklogic.com/rest-api/resource/process";
declare namespace wf = "http://marklogic.com/workflow";
declare namespace p = "http://marklogic.com/cpf/pipelines";


for $process-model-name in $test-constants:TEST-MODEL-NAMES
return
xquery version "1.0-ml";
(
(: Delete processes generated by these tests :)
/wf:process[wf:process-definition-name = $process-model-name] ! xdmp:document-delete(fn:base-uri(.)),
(: Remove children of these processes :)
let $test-pid := fn:doc(test-constants:test-pid-uri($process-model-name))/test-constants:pid/text()
return
/wf:process[fn:matches(wf:process-definition-name,$process-model-name)] ! xdmp:document-delete(fn:base-uri(.)),
(: Delete test pid document :)
xdmp:document-delete(test-constants:test-pid-uri($process-model-name)),
(: Delete model files :)
cts:uris()[fn:matches(.,test-constants:file-name-for-model($process-model-name))] ! xdmp:document-delete(.),
(: Delete associated pipelines :)
//p:pipeline-name[fn:matches(.,$process-model-name)] ! xdmp:document-delete(fn:base-uri(.))
)
xdmp:directory-delete("/"),
xdmp:collection-delete("http://marklogic.com/cpf/pipelines")
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!-- origin at X=0.0 Y=0.0 -->
<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">
<bpmn2:itemDefinition id="ItemDefinition_18" isCollection="false" structureRef="xs:boolean"/>
<bpmn2:itemDefinition id="ItemDefinition_922" isCollection="false" structureRef="xs:string"/>
<bpmn2:resource id="Resource_1" name="DynamicUser"/>
<bpmn2:process id="Process_1" name="Process 1" isExecutable="false">
<bpmn2:startEvent id="StartEvent_1" name="Start">
<bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing>
Expand All @@ -22,6 +24,12 @@
<bpmn2:userTask id="UserTask_1" name="TaskA">
<bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing>
<bpmn2:humanPerformer id="HumanPerformer_1" name="Actor">
<bpmn2:resourceRef>Resource_1</bpmn2:resourceRef>
<bpmn2:resourceAssignmentExpression id="ResourceAssignmentExpression_1">
<bpmn2:formalExpression id="FormalExpression_3" evaluatesToTypeRef="ItemDefinition_922" language="http://www.w3.org/1999/XPath">$wf:process/wf:data//assignTo/text()</bpmn2:formalExpression>
</bpmn2:resourceAssignmentExpression>
</bpmn2:humanPerformer>
</bpmn2:userTask>
<bpmn2:userTask id="UserTask_2" name="TaskB">
<bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
Expand Down Expand Up @@ -55,13 +63,13 @@
<bpmndi:BPMNShape id="BPMNShape_InclusiveGateway_1" bpmnElement="InclusiveGateway_1" isMarkerVisible="true">
<dc:Bounds height="50.0" width="50.0" x="350.0" y="248.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_3" labelStyle="BPMNLabelStyle_1">
<dc:Bounds height="48.0" width="58.0" x="346.0" y="298.0"/>
<dc:Bounds height="22.0" width="76.0" x="337.0" y="298.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_InclusiveGateway_2" bpmnElement="InclusiveGateway_2" isMarkerVisible="true">
<dc:Bounds height="50.0" width="50.0" x="600.0" y="248.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_4" labelStyle="BPMNLabelStyle_1">
<dc:Bounds height="48.0" width="69.0" x="591.0" y="298.0"/>
<dc:Bounds height="22.0" width="76.0" x="587.0" y="298.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_UserTask_1" bpmnElement="UserTask_1" isExpanded="true">
Expand Down
4 changes: 2 additions & 2 deletions src/test/test-config.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ declare variable $LOCAL-TEST-DATA-DIR := "/raw/bpmn/";
declare variable $SLEEP-FOR-ASYNC := 5; (: Sleep period required, in seconds, for async tasks :)

declare function local-uri-for-test-file($test-file-name as xs:string){
$LOCAL-TEST-DATA-DIR||$test-file-name
$LOCAL-TEST-DATA-DIR||$test-file-name
};

declare function test-sleep(){
xdmp:sleep($SLEEP-FOR-ASYNC * 1000)
};
};
2 changes: 1 addition & 1 deletion src/workflowengine/models/workflow-import.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ declare function m:b2userTask($rootName as xs:string,$parentStep as xs:string?,$
<p:options xmlns:p="http:marklogic.com/cpf/pipelines">
<wf:type>{$type}</wf:type>
{
if (fn:not(fn:empty($user))) then <wf:assignee>{$user}</wf:assignee> else ()
if (fn:not(fn:empty($user))) then <wf:user>{$user}</wf:user> else ()
}
{
if (fn:not(fn:empty($queue))) then <wf:queue>{$queue}</wf:queue> else ()
Expand Down
2 changes: 1 addition & 1 deletion src/workflowengine/models/workflow-util.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ declare function m:inbox($username as xs:string?) as element(wf:inbox) {
(: TODO add cpf-active check, wf:status running check, wf:locked-user blank :)
cts:properties-query(
cts:element-query(xs:QName("wf:currentStep"),
cts:element-value-query(xs:QName("wf:assignee"),($username,xdmp:get-current-user())[1])
cts:element-value-query( ( xs:QName("wf:user"), xs:QName("wf:assignee")),($username,xdmp:get-current-user())[1])
)
)
),("unfiltered") (: TODO ordering, prioritisation support, and so on :)
Expand Down