|
| 1 | +xquery version "1.0-ml"; |
| 2 | + |
| 3 | +(: 21-processmodel-create :) |
| 4 | +import module namespace c="http://marklogic.com/roxy/test-config" at "/test/test-config.xqy"; |
| 5 | +import module namespace test="http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 6 | +import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy"; |
| 7 | +declare namespace ext = "http://marklogic.com/rest-api/resource/processmodel"; |
| 8 | +declare namespace http = "xdmp:http"; |
| 9 | + |
| 10 | +let $process := wrt:processmodel-create ($c:json-options, "022-email-test.bpmn") |
| 11 | +(: not working with XML ? :) |
| 12 | +return ( (: |
| 13 | + test:assert-equal('200', xs:string($process[1]/http:code)), |
| 14 | + test:assert-equal('SUCCESS', xs:string($process[2]/ext:createResponse/ext:outcome)), |
| 15 | + test:assert-equal('015-restapi-tests__1__0', xs:string($process[2]/ext:createResponse/ext:modelId)) :) |
| 16 | + test:assert-equal('200', xs:string($process[1]/http:code)), |
| 17 | + test:assert-equal('SUCCESS', xs:string($process[2]/createResponse/outcome)), |
| 18 | + test:assert-equal('022-email-test__1__0', xs:string($process[2]/createResponse/modelId)) |
| 19 | +); |
| 20 | + |
| 21 | +(: 22-processmodel-publish :) |
| 22 | +import module namespace c="http://marklogic.com/roxy/test-config" at "/test/test-config.xqy"; |
| 23 | +import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy"; |
| 24 | +import module namespace test="http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 25 | +declare namespace ext = "http://marklogic.com/rest-api/resource/processmodel"; |
| 26 | +declare namespace http = "xdmp:http"; |
| 27 | + |
| 28 | +(: not working with XML ? :) |
| 29 | +let $result := wrt:processmodel-publish($c:json-options, "022-email-test__1__0") |
| 30 | +return ( (: |
| 31 | + test:assert-equal('200', xs:string($result[1]/http:code)), |
| 32 | + test:assert-equal('SUCCESS', xs:string($result[2]/ext:updateResponse/ext:outcome)), |
| 33 | + test:assert-exists(xs:string($result[2]/ext:updateResponse/ext:domainId)) :) |
| 34 | + test:assert-equal('200', xs:string($result[1]/http:code)), |
| 35 | + test:assert-equal('SUCCESS', xs:string($result[2]/updateResponse/outcome)), |
| 36 | + test:assert-exists(xs:string($result[2]/updateResponse/domainId)) |
| 37 | +); |
| 38 | + |
| 39 | +(: 23-process-create :) |
| 40 | +import module namespace c="http://marklogic.com/roxy/test-config" at "/test/test-config.xqy"; |
| 41 | +import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy"; |
| 42 | +import module namespace test="http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 43 | +declare namespace ext = "http://marklogic.com/rest-api/resource/process"; |
| 44 | +declare namespace http = "xdmp:http"; |
| 45 | + |
| 46 | +let $payload := doc("/raw/data/23-payload.xml") |
| 47 | +let $result := wrt:process-create($c:xml-options, $payload) |
| 48 | +return ( |
| 49 | + test:assert-equal('200', xs:string($result[1]/http:code)), |
| 50 | + test:assert-equal('SUCCESS', xs:string($result[2]/ext:createResponse/ext:outcome)), |
| 51 | + test:assert-exists(xs:string($result[2]/ext:createResponse/ext:processId)), |
| 52 | + xdmp:document-insert("/test/processId.xml", <test><processId>{xs:string($result[2]/ext:createResponse/ext:processId)}</processId></test>), |
| 53 | + xdmp:log(fn:concat("processId:", xdmp:quote($result[2]))) |
| 54 | +); |
| 55 | + |
| 56 | +(: 24-process-read :) |
| 57 | +import module namespace c="http://marklogic.com/roxy/test-config" at "/test/test-config.xqy"; |
| 58 | +import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy"; |
| 59 | +import module namespace test="http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 60 | +declare namespace ext = "http://marklogic.com/rest-api/resource/process"; |
| 61 | +declare namespace http = "xdmp:http"; |
| 62 | + |
| 63 | +let $pid := xs:string(doc("/test/processId.xml")/test/processId) |
| 64 | +let $result := wrt:process-read($c:xml-options, $pid) |
| 65 | +return ( |
| 66 | + test:assert-equal('200', xs:string($result[1]/http:code)), |
| 67 | + test:assert-equal('SUCCESS', xs:string($result[2]/ext:readResponse/ext:outcome)), |
| 68 | + test:assert-exists($result[2]/ext:readResponse/ext:document) |
| 69 | +); |
| 70 | + |
| 71 | +(: 25-processsubscription-create :) |
| 72 | +import module namespace c="http://marklogic.com/roxy/test-config" at "/test/test-config.xqy"; |
| 73 | +import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy"; |
| 74 | +import module namespace test="http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 75 | +declare namespace ext = "http://marklogic.com/rest-api/resource/processsubscription"; |
| 76 | +declare namespace http = "xdmp:http"; |
| 77 | + |
| 78 | +let $result := wrt:test-25-processsubscription-create ($c:xml-options) |
| 79 | +return ( |
| 80 | + test:assert-equal('200', xs:string($result[1]/http:code)), |
| 81 | + test:assert-equal('SUCCESS', xs:string($result[2]/ext:createResponse/ext:outcome)), |
| 82 | + test:assert-equal('/config/alerts/email-sub-test', xs:string($result[2]/ext:createResponse/ext:subscriptionId)) |
| 83 | +); |
| 84 | + |
| 85 | +(: 26-processsubscription-read :) |
| 86 | +import module namespace c="http://marklogic.com/roxy/test-config" at "/test/test-config.xqy"; |
| 87 | +import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy"; |
| 88 | +import module namespace test="http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 89 | +declare namespace alert = "http://marklogic.com/xdmp/alert"; |
| 90 | +declare namespace ext = "http://marklogic.com/rest-api/resource/processsubscription"; |
| 91 | +declare namespace http = "xdmp:http"; |
| 92 | + |
| 93 | +let $result := wrt:test-26-processsubscription-read ($c:xml-options) |
| 94 | +return ( |
| 95 | + test:assert-equal('200', xs:string($result[1]/http:code)), |
| 96 | + test:assert-equal('SUCCESS', xs:string($result[2]/ext:readResponse/ext:outcome)), |
| 97 | + test:assert-equal('/config/alerts/email-sub-test', xs:string($result[2]/ext:readResponse/ext:subscription/alert:config/alert:config-uri)) |
| 98 | +); |
| 99 | + |
| 100 | +(: 27-document-create :) |
| 101 | +import module namespace c="http://marklogic.com/roxy/test-config" at "/test/test-config.xqy"; |
| 102 | +import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy"; |
| 103 | +import module namespace test="http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 104 | +declare namespace ext = "http://marklogic.com/rest-api/resource/processsubscription"; |
| 105 | +declare namespace http = "xdmp:http"; |
| 106 | + |
| 107 | +let $result := wrt:test-27-document-create ($c:xml-options) |
| 108 | +return ( |
| 109 | + test:assert-equal('201', xs:string($result[1]/http:code)) |
| 110 | +); |
| 111 | + |
| 112 | +(: Search needs to be immediately after - it executes too quick otherwise!!! (A blank result may mean processes already finished, not just haven't started) :) |
| 113 | +(: 28-processsearch-read :) |
| 114 | +import module namespace c="http://marklogic.com/roxy/test-config" at "/test/test-config.xqy"; |
| 115 | +import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy"; |
| 116 | +import module namespace test="http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 117 | +declare namespace ext = "http://marklogic.com/rest-api/resource/processsearch"; |
| 118 | +declare namespace http = "xdmp:http"; |
| 119 | +declare namespace wf = "http://marklogic.com/workflow"; |
| 120 | + |
| 121 | +let $result := wrt:test-28-processsearch-read ($c:xml-options) |
| 122 | +return ( |
| 123 | + test:assert-equal('200', xs:string($result[1]/http:code)), |
| 124 | + test:assert-equal('SUCCESS', xs:string($result[2]/ext:readResponse/ext:outcome)), |
| 125 | + test:assert-exists($result[2]/ext:readResponse/wf:list) |
| 126 | +); |
| 127 | + |
| 128 | +(: 29-processasset-create :) |
| 129 | +import module namespace c="http://marklogic.com/roxy/test-config" at "/test/test-config.xqy"; |
| 130 | +import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy"; |
| 131 | +import module namespace test="http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 132 | +declare namespace ext = "http://marklogic.com/rest-api/resource/processasset"; |
| 133 | +declare namespace http = "xdmp:http"; |
| 134 | + |
| 135 | +let $result := wrt:test-29-processasset-create ($c:xml-options) |
| 136 | +return ( |
| 137 | + test:assert-equal('200', xs:string($result[1]/http:code)), |
| 138 | + test:assert-equal('SUCCESS', xs:string($result[2]/ext:createResponse/ext:outcome)), |
| 139 | + test:assert-equal('/workflowengine/assets/021-initiating-attachment/1/3/RejectedEmail.txt', xs:string($result[2]/ext:createResponse/ext:assetUri)) |
| 140 | +); |
| 141 | + |
| 142 | +(: 30-processasset-read :) |
| 143 | +import module namespace c="http://marklogic.com/roxy/test-config" at "/test/test-config.xqy"; |
| 144 | +import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy"; |
| 145 | +import module namespace test="http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 146 | +declare namespace em = "URN:ietf:params:email-xml:"; |
| 147 | +declare namespace http = "xdmp:http"; |
| 148 | +declare namespace rf = "URN:ietf:params:rfc822:"; |
| 149 | + |
| 150 | +let $result := wrt:test-30-processasset-read ($c:xml-options) |
| 151 | +return ( |
| 152 | + test:assert-equal('200', xs:string($result[1]/http:code)) (:, |
| 153 | + test:assert-equal('Document Rejected', xs:string($result[2]/em:Message/rf:subject)) :) |
| 154 | +); |
| 155 | + |
| 156 | +(: 31-processasset-delete :) |
| 157 | +import module namespace c="http://marklogic.com/roxy/test-config" at "/test/test-config.xqy"; |
| 158 | +import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy"; |
| 159 | +import module namespace test="http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 160 | +declare namespace ext = "http://marklogic.com/rest-api/resource/processasset"; |
| 161 | +declare namespace http = "xdmp:http"; |
| 162 | + |
| 163 | +let $result := wrt:test-31-processasset-delete ($c:xml-options) |
| 164 | +return ( |
| 165 | + test:assert-equal('200', xs:string($result[1]/http:code)), |
| 166 | + test:assert-equal('SUCCESS', xs:string($result[2]/ext:deleteResponse/ext:outcome)), |
| 167 | + test:assert-equal('/workflowengine/assets/021-initiating-attachment/1/3/RejectedEmail.txt', xs:string($result[2]/ext:deleteResponse/ext:assetUri)) |
| 168 | +); |
| 169 | + |
| 170 | + |
0 commit comments