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

Commit 028e485

Browse files
committed
fixes for tests ; debug logging
1 parent 0fc45da commit 028e485

File tree

4 files changed

+83
-37
lines changed

4 files changed

+83
-37
lines changed

rest-api/ext/process.xqy

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,21 +150,23 @@ function ext:post(
150150
$params as map:map,
151151
$input as document-node()*
152152
) as document-node()* {
153+
let $_ := xdmp:log(fn:concat("REST EXT params=", xdmp:quote($params)), "debug")
154+
let $preftype := if ("application/xml" = map:get($context,"accept-types")) then "application/xml" else "application/json"
155+
let $_ := xdmp:log(fn:concat("REST EXT preftype: " , $preftype), "debug")
156+
157+
let $part := (map:get($params,"part"),"document")[1]
158+
let $_ := xdmp:log(fn:concat("REST EXT part: ", $part), "debug")
153159

154-
let $preftype := if ("application/xml" = map:get($context,"accept-types")) then "application/xml" else "application/json"
160+
let $_ := xdmp:log(fn:concat("REST EXT input: ", $input), "debug")
161+
let $pid := map:get($params,"processid") (: this is stripping the '+' symbol if sent unencoded :)
162+
(:let $proc := wfu:get($pid):)
163+
let $_ := xdmp:log(fn:concat("REST EXT ProcessId: ", $pid), "debug")
164+
let $props := wfu:getProperties($pid)
155165

156-
let $part := (map:get($params,"part"),"document")[1]
166+
let $_ := xdmp:log("CURRENT STEP INFO", "debug")
167+
let $_ := xdmp:log($props (: /wf:currentStep :) , "debug")
157168

158-
let $_ := xdmp:log($input)
159-
let $pid := map:get($params,"processid")
160-
(:let $proc := wfu:get($pid):)
161-
let $_ := xdmp:log("REST EXT ProcessId: " || $pid)
162-
let $props := wfu:getProperties($pid)
163-
(:
164-
let $_ := xdmp:log("CURRENT STEP INFO")
165-
let $_ := xdmp:log($props/wf:currentStep)
166-
:)
167-
let $res :=
169+
let $res :=
168170
if ("true" = map:get($params,"complete")) then
169171
(: sanity check that the specified process' status is on a user task :)
170172
if ("userTask" = $props/wf:currentStep/wf:step-type) then
@@ -187,6 +189,7 @@ function ext:post(
187189

188190
if ("true" = map:get($params,"lock")) then
189191
(: Lock the work item, and return its details as if get had been called. If already locked, instead return an error :)
192+
let $_ := xdmp:log("REST EXT call to lock work item", "debug")
190193
let $feedback := wfu:lock($pid)
191194
let $update :=
192195
if (fn:empty($feedback)) then

src/app/models/workflow-util.xqy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ declare function m:lock($processId as xs:string) as xs:string? {
281281
(: when it works, should return empty-sequence() :)
282282
(: Check that this is a human queue task or user task :)
283283
let $props := m:getProperties($processId)
284+
let $_ := xdmp:log(fn:concat("WF Utils lock pid=", $processId), "debug")
285+
let $_ := xdmp:log(fn:concat("WF Utils props=", xdmp:quote($props)), "debug")
284286
return
285287
if ($props/wf:currentStep/wf:step-type = "userTask" and $props/wf:currentStep/wf:step-status = "ENTERED") then
286288
if ($props/wf:currentStep/wf:type = "user" or $props/wf:currentStep/wf:type = "queue" or $props/wf:currentStep/wf:type = "role") then

src/test/suites/shtests-json/015-processmodel-json.xqy

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ declare namespace ext = "http://marklogic.com/rest-api/resource/process";
153153
declare namespace http = "xdmp:http";
154154
declare namespace wf="http://marklogic.com/workflow";
155155

156+
let $_pause := xdmp:sleep(5000)
156157
let $pid := xs:string(doc("/test/processId.xml")/test/processId)
157158
let $result := wrt:test-11-process-update-lock($c:json-options, $pid)
158159
return (
159160
test:assert-equal('200', xs:string($result[1]/http:code)),
160-
(: to do - is this supposed to fail ? :)
161-
test:assert-equal('FAILURE', xs:string($result[2]/updateResponse/outcome)),
162-
test:assert-exists($result[2]/updateResponse/message)
161+
test:assert-equal('SUCCESS', xs:string($result[2]//outcome)),
162+
test:assert-exists($result[2]/readResponse/document)
163163
);
164164

165165
(: 12-process-update-lock-fail :)
@@ -170,15 +170,16 @@ declare namespace ext = "http://marklogic.com/rest-api/resource/process";
170170
declare namespace http = "xdmp:http";
171171
declare namespace error="http://marklogic.com/xdmp/error";
172172

173+
let $_pause := xdmp:sleep(5000)
173174
let $pid := xs:string(doc("/test/processId.xml")/test/processId)
174175
let $result := wrt:test-12-process-update-lock-fail($c:json-options, $pid)
175176
return (
176177
test:assert-equal('200', xs:string($result[1]/http:code)),
177-
test:assert-equal('FAILURE', xs:string($result[2]/updateResponse/outcome)),
178-
test:assert-exists($result[2]/updateResponse/message)
178+
test:assert-equal('FAILURE', xs:string($result[2]//outcome)), (: this is currently passing :)
179+
test:assert-exists($result[2]/readResponse/message)
179180
);
180181

181-
(: 13-process-update-unlock :) (: definitely broken :)
182+
(: 13-process-update-unlock :)
182183
import module namespace c="http://marklogic.com/roxy/test-config" at "/test/test-config.xqy";
183184
import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy";
184185
import module namespace test="http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy";
@@ -190,8 +191,8 @@ let $pid := xs:string(doc("/test/processId.xml")/test/processId)
190191
let $result := wrt:test-13-process-update-unlock($c:json-options, $pid)
191192
return (
192193
test:assert-equal('200', xs:string($result[1]/http:code)),
193-
test:assert-equal('FAILURE', xs:string($result[2]/updateResponse/outcome)),
194-
test:assert-exists($result[2]/updateResponse/message)
194+
test:assert-equal('SUCCESS', xs:string($result[2]/readResponse/outcome)),
195+
test:assert-exists($result[2]/readResponse/document)
195196
);
196197

197198
(: 14-process-update-lock :)
@@ -207,8 +208,8 @@ let $result := wrt:test-14-process-update-lock($c:json-options, $pid)
207208
return (
208209
test:assert-equal('200', xs:string($result[1]/http:code)),
209210
(: to do - is this supposed to fail ? :)
210-
test:assert-equal('FAILURE', xs:string($result[2]/updateResponse/outcome)),
211-
test:assert-exists($result[2]/updateResponse/message)
211+
test:assert-equal('SUCCESS', xs:string($result[2]/updateResponse/outcome)),
212+
test:assert-exists($result[2]/updateResponse/document)
212213
);
213214

214215
(: 15-process-update :)

src/test/workflow-rest-tests.xqy

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ declare function wrt:test-14-15-xml-payload ($pid)
3636

3737
declare function wrt:test-01-processmodel-create ($options)
3838
{
39-
let $uri := fn:concat("http://", $c:RESTHOST, ':', $c:RESTPORT, "/v1/resources/processmodel?rs:name=015-restapi-tests.bpmn&enable=true")
39+
let $uri := fn:concat(
40+
"http://", $c:RESTHOST, ':', $c:RESTPORT,
41+
"/v1/resources/processmodel?rs:name=015-restapi-tests.bpmn&enable=true")
4042
let $file := doc("/raw/data/015-restapi-tests.bpmn")
4143
(: let $process := xdmp:http-put($uri, $options, $file)
4244
:)
@@ -45,94 +47,132 @@ declare function wrt:test-01-processmodel-create ($options)
4547

4648
declare function wrt:test-02-processmodel-read ($options)
4749
{
48-
let $uri := fn:concat("http://", $c:RESTHOST, ':', $c:RESTPORT, "/v1/resources/processmodel?rs:publishedId=015-restapi-tests.bpmn")
50+
let $uri := fn:concat(
51+
"http://", $c:RESTHOST, ':', $c:RESTPORT,
52+
"/v1/resources/processmodel?rs:publishedId=015-restapi-tests.bpmn")
4953
return xdmp:http-get($uri, $options)
5054
};
5155

5256
declare function wrt:test-03-processmodel-update ($options)
5357
{
54-
let $uri := fn:concat("http://", $c:RESTHOST, ':', $c:RESTPORT, "/v1/resources/processmodel?rs:name=015-restapi-tests.bpmn&rs:major=1&rs:minor=2")
58+
let $uri := fn:concat(
59+
"http://", $c:RESTHOST, ':', $c:RESTPORT,
60+
"/v1/resources/processmodel?rs:name=015-restapi-tests.bpmn&rs:major=1&rs:minor=2")
5561
let $file := doc("/raw/data/015-restapi-tests.bpmn")
5662
return xdmp:http-put($uri, $options, $file)
5763
};
5864

5965
declare function wrt:test-04-processmodel-publish ($options)
6066
{
61-
let $uri := fn:concat("http://", $c:RESTHOST, ':', $c:RESTPORT, "/v1/resources/processmodel?rs:publishedId=015-restapi-tests__1__2")
67+
let $uri := fn:concat(
68+
"http://", $c:RESTHOST, ':', $c:RESTPORT,
69+
"/v1/resources/processmodel?rs:publishedId=015-restapi-tests__1__2")
6270
let $file := <somexml/>
6371
return xdmp:http-post($uri, $options, $file)
6472
};
6573

6674
declare function wrt:test-06-process-create ($options)
6775
{
68-
let $uri := fn:concat("http://", $c:RESTHOST, ':', $c:RESTPORT, "/v1/resources/process")
76+
let $uri := fn:concat(
77+
"http://", $c:RESTHOST, ':', $c:RESTPORT,
78+
"/v1/resources/process")
6979
let $file := doc("/raw/data/06-payload.xml")
7080
return xdmp:http-put($uri, $options, $file)
7181
};
7282

7383
declare function wrt:test-07-process-read ($options, $pid)
7484
{
75-
let $uri := fn:concat("http://", $c:RESTHOST, ':', $c:RESTPORT, "/v1/resources/process?rs:processid=", $pid)
85+
let $uri := fn:concat(
86+
"http://", $c:RESTHOST, ':', $c:RESTPORT,
87+
"/v1/resources/process?rs:processid=", fn:encode-for-uri($pid))
7688
return xdmp:http-get($uri, $options)
7789
};
7890

7991
declare function wrt:test-08-processinbox-read ($options)
8092
{
81-
let $uri := fn:concat("http://", $c:RESTHOST, ':', $c:RESTPORT, "/v1/resources/processinbox")
93+
let $uri := fn:concat(
94+
"http://", $c:RESTHOST, ':', $c:RESTPORT,
95+
"/v1/resources/processinbox")
8296
return xdmp:http-get($uri, $options)
8397
};
8498

8599
declare function wrt:test-09-process-update ($options, $pid)
86100
{
87-
let $uri := fn:concat("http://", $c:RESTHOST, ':', $c:RESTPORT, "/v1/resources/process?rs:processid=", $pid, "&amp;rs:complete=true")
101+
let $_ := xdmp:log(fn:concat("options=", xdmp:quote($options)))
102+
let $_ := xdmp:log(fn:concat("pid=", $pid))
103+
let $uri := fn:concat(
104+
"http://", $c:RESTHOST, ':', $c:RESTPORT,
105+
"/v1/resources/process?rs:processid=",
106+
fn:encode-for-uri($pid), "&amp;rs:complete=true")
107+
let $_ := xdmp:log(fn:concat("uri=", $uri))
88108
let $file := wrt:test-09-11-12-xml-payload($pid)
109+
let $_ := xdmp:log(fn:concat("file=", xdmp:quote($file)))
89110
return xdmp:http-post($uri, $options, $file)
90111
};
91112

92113
declare function wrt:test-10-processqueue-read ($options)
93114
{
94-
let $uri := fn:concat("http://", $c:RESTHOST, ':', $c:RESTPORT, "/v1/resources/processqueue?rs:queue=Editors")
115+
let $uri := fn:concat(
116+
"http://", $c:RESTHOST, ':', $c:RESTPORT,
117+
"/v1/resources/processqueue?rs:queue=Editors")
95118
return xdmp:http-get($uri, $options)
96119
};
97120

98121
declare function wrt:test-11-process-update-lock ($options, $pid)
99122
{
100-
let $uri := fn:concat("http://", $c:RESTHOST, ':', $c:RESTPORT, "/v1/resources/process?rs:processid=", $pid, "&amp;rs:lock=true")
123+
let $uri := fn:concat(
124+
"http://", $c:RESTHOST, ':', $c:RESTPORT,
125+
"/v1/resources/process?rs:processid=", fn:encode-for-uri($pid),
126+
"&amp;rs:lock=true")
101127
let $file := wrt:test-09-11-12-xml-payload($pid)
102128
return xdmp:http-post($uri, $options, $file)
103129
};
104130

105131
declare function wrt:test-12-process-update-lock-fail ($options, $pid)
106132
{
107-
let $uri := fn:concat("http://", $c:RESTHOST, ':', $c:RESTPORT, "/v1/resources/process?rs:processid=", $pid, "&amp;rs:lock=true")
133+
let $uri := fn:concat(
134+
"http://", $c:RESTHOST, ':', $c:RESTPORT,
135+
"/v1/resources/process?rs:processid=", fn:encode-for-uri($pid),
136+
"&amp;rs:lock=true")
108137
let $file := wrt:test-09-11-12-xml-payload($pid)
109138
return xdmp:http-post($uri, $options, $file)
110139
};
111140

112141
declare function wrt:test-13-process-update-unlock ($options, $pid)
113142
{
114-
let $uri := fn:concat("http://", $c:RESTHOST, ':', $c:RESTPORT, "/v1/resources/process?rs:processid=", $pid, "&amp;rs:unlock=true")
143+
let $uri := fn:concat(
144+
"http://", $c:RESTHOST, ':', $c:RESTPORT,
145+
"/v1/resources/process?rs:processid=", fn:encode-for-uri($pid),
146+
"&amp;rs:unlock=true")
115147
let $file := wrt:test-13-xml-payload($pid)
116148
return xdmp:http-post($uri, $options, $file)
117149
};
118150

119151
declare function wrt:test-14-process-update-lock ($options, $pid)
120152
{
121-
let $uri := fn:concat("http://", $c:RESTHOST, ':', $c:RESTPORT, "/v1/resources/process?rs:processid=", $pid, "&amp;rs:lock=true")
153+
let $uri := fn:concat(
154+
"http://", $c:RESTHOST, ':', $c:RESTPORT,
155+
"/v1/resources/process?rs:processid=", fn:encode-for-uri($pid),
156+
"&amp;rs:lock=true")
122157
let $file := wrt:test-14-15-xml-payload($pid)
123158
return xdmp:http-post($uri, $options, $file)
124159
};
125160

126161
declare function wrt:test-15-process-update ($options, $pid)
127162
{
128-
let $uri := fn:concat("http://", $c:RESTHOST, ':', $c:RESTPORT, "/v1/resources/process?rs:processid=", $pid, "&amp;rs:complete=true")
163+
let $uri := fn:concat(
164+
"http://", $c:RESTHOST, ':', $c:RESTPORT,
165+
"/v1/resources/process?rs:processid=", fn:encode-for-uri($pid),
166+
"&amp;rs:complete=true")
129167
let $file := wrt:test-14-15-xml-payload($pid)
130168
return xdmp:http-post($uri, $options, $file)
131169
};
132170

133171
declare function wrt:test-16-process-read ($options, $pid)
134172
{
135-
let $uri := fn:concat("http://", $c:RESTHOST, ':', $c:RESTPORT, "/v1/resources/process?rs:processid=", $pid)
173+
let $uri := fn:concat(
174+
"http://", $c:RESTHOST, ':', $c:RESTPORT,
175+
"/v1/resources/process?rs:processid=", fn:encode-for-uri($pid))
136176
return xdmp:http-get($uri, $options)
137177
};
138178

0 commit comments

Comments
 (0)