|
| 1 | +(: |
| 2 | + In this test we check that we can successfully delete a subscription |
| 3 | +
|
| 4 | + Prep) Set up process model |
| 5 | +
|
| 6 | + 1) Set up the subscription to the model |
| 7 | + 2) Check the subscription exists using the API |
| 8 | + 3) Verify that we have alert documents and a domain - white box testing |
| 9 | + 4) Delete the subscription using the API and check the response |
| 10 | + 5) Verify that we have NO alert documents and NO domain - white box testing |
| 11 | +
|
| 12 | +:) |
| 13 | +import module namespace test-config = "http://marklogic.com/roxy/test-config" at "/test/test-config.xqy"; |
| 14 | +import module namespace test = "http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 15 | +import module namespace test-constants = "http://marklogic.com/workflow/test-constants/inclusive-gateway" at "/test/suites/inclusive-gateway/lib/constants.xqy"; |
| 16 | + |
| 17 | +import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy"; |
| 18 | +import module namespace const="http://marklogic.com/roxy/workflow-constants" at "/test/workflow-constants.xqy"; |
| 19 | + |
| 20 | +declare namespace model = "http://marklogic.com/rest-api/resource/processmodel"; |
| 21 | + |
| 22 | +declare variable $MODEL-INPUT-FILE-NAME := test-constants:file-name-for-model($test-constants:TEST-02-MODEL-NAME); |
| 23 | + |
| 24 | +declare option xdmp:mapping "false"; |
| 25 | + |
| 26 | +let $model-response := wrt:processmodel-create ($const:xml-options, $MODEL-INPUT-FILE-NAME)[2] |
| 27 | +return |
| 28 | +( |
| 29 | + test:assert-equal(xs:string($model-response/model:createResponse/model:outcome/text()),"SUCCESS"), |
| 30 | + test:assert-equal(xs:string($model-response/model:createResponse/model:modelId/text()),test-constants:expected-model-id($test-constants:TEST-02-MODEL-NAME)) |
| 31 | +) |
| 32 | +; |
| 33 | + |
| 34 | +import module namespace test-constants = "http://marklogic.com/workflow/test-constants/inclusive-gateway" at "/test/suites/process-subscription/lib/constants.xqy"; |
| 35 | +import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy"; |
| 36 | +import module namespace const="http://marklogic.com/roxy/workflow-constants" at "/test/workflow-constants.xqy"; |
| 37 | +import module namespace test = "http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 38 | + |
| 39 | +declare namespace ext="http://marklogic.com/rest-api/resource/processsubscription"; |
| 40 | + |
| 41 | +let $test-payload := |
| 42 | +<ext:createRequest xmlns:ext="http://marklogic.com/rest-api/resource/processsubscription"> |
| 43 | + <ext:processName>{test-constants:expected-model-id($test-constants:TEST-02-MODEL-NAME)}</ext:processName> |
| 44 | + <ext:name>{$test-constants:SUBSCRIPTION-NAME}</ext:name> |
| 45 | + <ext:domain> |
| 46 | + <ext:name>{$test-constants:DOMAIN-NAME}</ext:name> |
| 47 | + <ext:type>directory</ext:type> |
| 48 | + <ext:path>{$test-constants:MONITORED-DIRECTORY}</ext:path> |
| 49 | + <ext:depth>0</ext:depth> |
| 50 | + </ext:domain> |
| 51 | + <ext:query> |
| 52 | + <cts:and-query xmlns:cts="http://marklogic.com/cts"></cts:and-query> |
| 53 | + </ext:query> |
| 54 | +</ext:createRequest> |
| 55 | +let $create-response := wrt:test-processsubscription-create($const:xml-options,$test-payload)[2] |
| 56 | +return |
| 57 | +( |
| 58 | + test:assert-equal($create-response/ext:createResponse/ext:subscriptionId/fn:string(),test-constants:expected-subscription-id($test-constants:SUBSCRIPTION-NAME)), |
| 59 | + test:assert-equal($create-response/ext:createResponse/ext:outcome/fn:string(),"SUCCESS") |
| 60 | +) |
| 61 | +; |
| 62 | +import module namespace test-constants = "http://marklogic.com/workflow/test-constants/inclusive-gateway" at "/test/suites/process-subscription/lib/constants.xqy"; |
| 63 | +import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy"; |
| 64 | +import module namespace const="http://marklogic.com/roxy/workflow-constants" at "/test/workflow-constants.xqy"; |
| 65 | +import module namespace test = "http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 66 | + |
| 67 | +declare namespace alert="http://marklogic.com/xdmp/alert"; |
| 68 | +declare namespace ext="http://marklogic.com/rest-api/resource/processsubscription"; |
| 69 | + |
| 70 | +let $read-response := wrt:test-processsubscription-read($const:xml-options,$test-constants:SUBSCRIPTION-NAME) |
| 71 | +return |
| 72 | +( |
| 73 | + test:assert-equal($read-response/ext:readResponse/ext:subscription/alert:config/alert:config-uri/fn:string(),test-constants:expected-subscription-id($test-constants:SUBSCRIPTION-NAME)), |
| 74 | + test:assert-equal($read-response/ext:readResponse/ext:outcome/fn:string(),"SUCCESS") |
| 75 | +) |
| 76 | +; |
| 77 | +(: Internally verify that we have a cpf domain with the expected name :) |
| 78 | +import module namespace test-constants = "http://marklogic.com/workflow/test-constants/inclusive-gateway" at "/test/suites/process-subscription/lib/constants.xqy"; |
| 79 | +import module namespace test = "http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 80 | + |
| 81 | +declare namespace dom = "http://marklogic.com/cpf/domains"; |
| 82 | + |
| 83 | +test:assert-true( |
| 84 | +xdmp:invoke-function(function(){ |
| 85 | + fn:exists(//dom:domain-name/text()[fn:matches(.,$test-constants:DOMAIN-NAME)])},<options xmlns="xdmp:eval"><database>{xdmp:triggers-database()}</database></options>)) |
| 86 | +; |
| 87 | +(: And that we have three alert documents :) |
| 88 | +import module namespace test-constants = "http://marklogic.com/workflow/test-constants/inclusive-gateway" at "/test/suites/process-subscription/lib/constants.xqy"; |
| 89 | +import module namespace test = "http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 90 | + |
| 91 | +test:assert-equal(fn:count(fn:collection(test-constants:expected-subscription-id($test-constants:SUBSCRIPTION-NAME))),3) |
| 92 | +; |
| 93 | +(: Delete should return a 204 :) |
| 94 | +import module namespace test-constants = "http://marklogic.com/workflow/test-constants/inclusive-gateway" at "/test/suites/process-subscription/lib/constants.xqy"; |
| 95 | +import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy"; |
| 96 | +import module namespace const="http://marklogic.com/roxy/workflow-constants" at "/test/workflow-constants.xqy"; |
| 97 | +import module namespace test = "http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 98 | + |
| 99 | +declare namespace http = "xdmp:http"; |
| 100 | + |
| 101 | +let $delete-response := wrt:test-processsubscription-delete($const:xml-options,$test-constants:SUBSCRIPTION-NAME) |
| 102 | +return |
| 103 | +test:assert-equal($delete-response/http:code/fn:data(),204) |
| 104 | +; |
| 105 | +import module namespace test-constants = "http://marklogic.com/workflow/test-constants/inclusive-gateway" at "/test/suites/process-subscription/lib/constants.xqy"; |
| 106 | +import module namespace wrt="http://marklogic.com/workflow/rest-tests" at "/test/workflow-rest-tests.xqy"; |
| 107 | +import module namespace const="http://marklogic.com/roxy/workflow-constants" at "/test/workflow-constants.xqy"; |
| 108 | +import module namespace test = "http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 109 | + |
| 110 | +declare namespace alert="http://marklogic.com/xdmp/alert"; |
| 111 | +declare namespace ext="http://marklogic.com/rest-api/resource/processsubscription"; |
| 112 | + |
| 113 | +let $read-response := wrt:test-processsubscription-read($const:xml-options,$test-constants:SUBSCRIPTION-NAME) |
| 114 | +return |
| 115 | +test:assert-equal($read-response/ext:readResponse/ext:outcome/fn:string(),"NOT FOUND") |
| 116 | +; |
| 117 | +(: Internally verify that we NO LONGER have a cpf domain with the expected name :) |
| 118 | +import module namespace test-constants = "http://marklogic.com/workflow/test-constants/inclusive-gateway" at "/test/suites/process-subscription/lib/constants.xqy"; |
| 119 | +import module namespace test = "http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 120 | + |
| 121 | +declare namespace dom = "http://marklogic.com/cpf/domains"; |
| 122 | + |
| 123 | +test:assert-false( |
| 124 | +xdmp:invoke-function(function(){ |
| 125 | + fn:exists(//dom:domain-name/text()[fn:matches(.,$test-constants:DOMAIN-NAME)])},<options xmlns="xdmp:eval"><database>{xdmp:triggers-database()}</database></options>)) |
| 126 | +; |
| 127 | +(: And that we have NO alert documents :) |
| 128 | +import module namespace test-constants = "http://marklogic.com/workflow/test-constants/inclusive-gateway" at "/test/suites/process-subscription/lib/constants.xqy"; |
| 129 | +import module namespace test = "http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy"; |
| 130 | + |
| 131 | +test:assert-equal(fn:count(fn:collection(test-constants:expected-subscription-id($test-constants:SUBSCRIPTION-NAME))),0) |
0 commit comments