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

Commit 6284f3c

Browse files
committed
converted email and fork tests to roxy
1 parent 028e485 commit 6284f3c

17 files changed

+1318
-35
lines changed
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
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+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
xquery version "1.0-ml";
2+
3+
import module namespace test = "http://marklogic.com/roxy/test-helper" at "/test/test-helper.xqy";
4+
import module namespace deploy = "http://marklogic.com/roxy/deploy-rest-resources" at "/test/deploy-rest-resources.xqy";
5+
6+
let $_modules-import := deploy:deploy()
7+
8+
return (
9+
test:load-test-file("022-email-test.bpmn", xdmp:database(), "/raw/data/022-email-test.bpmn"),
10+
test:load-test-file("23-payload.xml", xdmp:database(), "/raw/data/23-payload.xml"),
11+
test:load-test-file("25-payload.xml", xdmp:database(), "/raw/data/25-payload.xml"),
12+
test:load-test-file("27-payload.xml", xdmp:database(), "/raw/data/27-payload.xml"),
13+
test:load-test-file("RejectedEmail.txt", xdmp:database(), "/raw/data/RejectedEmail.txt")
14+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
xquery version "1.0-ml";
2+
3+
xdmp:directory-delete("/")
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- origin at X=0.0 Y=0.0 -->
3+
<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:ext="http://org.eclipse.bpmn2/ext" xmlns:xs="http://www.w3.org/2001/XMLSchema" id="Definitions_1" exporter="org.eclipse.bpmn2.modeler.core" exporterVersion="1.1.4.201509111742" targetNamespace="http://marklogic.com/workflow">
4+
<bpmn2:itemDefinition id="ItemDefinition_1" isCollection="false" structureRef="xs:string"/>
5+
<bpmn2:message id="Message_1" itemRef="ItemDefinition_1" name="BlankMessage">
6+
<bpmn2:extensionElements>
7+
<ext:style/>
8+
</bpmn2:extensionElements>
9+
</bpmn2:message>
10+
<bpmn2:message id="Message_2" itemRef="ItemDefinition_1" name="TestEmail">
11+
<bpmn2:extensionElements>
12+
<ext:style/>
13+
</bpmn2:extensionElements>
14+
</bpmn2:message>
15+
<bpmn2:interface id="Interface_1" implementationRef="MarkLogicEmailInterface" name="EmailInterface">
16+
<bpmn2:operation id="_Operation_4" name="SendTestEmail">
17+
<bpmn2:inMessageRef>Message_1</bpmn2:inMessageRef>
18+
<bpmn2:outMessageRef>Message_2</bpmn2:outMessageRef>
19+
</bpmn2:operation>
20+
</bpmn2:interface>
21+
<bpmn2:process id="EmailTest" name="Default Process" isExecutable="false">
22+
<bpmn2:startEvent id="StartEvent_1" name="Start Event 1">
23+
<bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
24+
</bpmn2:startEvent>
25+
<bpmn2:sequenceFlow id="SequenceFlow_1" name="Sequence Flow 1" sourceRef="StartEvent_1" targetRef="SendTask_1"/>
26+
<bpmn2:endEvent id="EndEvent_1" name="End Event 1">
27+
<bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
28+
</bpmn2:endEvent>
29+
<bpmn2:sendTask id="SendTask_1" name="Send Task 1" implementation="##unspecified" messageRef="Message_2" operationRef="_Operation_4">
30+
<bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
31+
<bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>
32+
<bpmn2:ioSpecification id="InputOutputSpecification_2">
33+
<bpmn2:dataInput id="DataInput_1" itemSubjectRef="ItemDefinition_1" name="input1"/>
34+
<bpmn2:inputSet id="InputSet_2">
35+
<bpmn2:dataInputRefs>DataInput_1</bpmn2:dataInputRefs>
36+
</bpmn2:inputSet>
37+
<bpmn2:outputSet id="OutputSet_2"/>
38+
</bpmn2:ioSpecification>
39+
</bpmn2:sendTask>
40+
<bpmn2:sequenceFlow id="SequenceFlow_2" sourceRef="SendTask_1" targetRef="EndEvent_1"/>
41+
</bpmn2:process>
42+
<bpmndi:BPMNDiagram id="BPMNDiagram_1" name="Default Process Diagram">
43+
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="EmailTest">
44+
<bpmndi:BPMNShape id="BPMNShape_1" bpmnElement="StartEvent_1">
45+
<dc:Bounds height="36.0" width="36.0" x="91.0" y="100.0"/>
46+
<bpmndi:BPMNLabel id="BPMNLabel_1" labelStyle="BPMNLabelStyle_1">
47+
<dc:Bounds height="10.0" width="55.0" x="82.0" y="136.0"/>
48+
</bpmndi:BPMNLabel>
49+
</bpmndi:BPMNShape>
50+
<bpmndi:BPMNShape id="BPMNShape_2" bpmnElement="EndEvent_1">
51+
<dc:Bounds height="36.0" width="36.0" x="530.0" y="100.0"/>
52+
<bpmndi:BPMNLabel id="BPMNLabel_2" labelStyle="BPMNLabelStyle_1">
53+
<dc:Bounds height="10.0" width="51.0" x="523.0" y="136.0"/>
54+
</bpmndi:BPMNLabel>
55+
</bpmndi:BPMNShape>
56+
<bpmndi:BPMNShape id="BPMNShape_SendTask_1" bpmnElement="SendTask_1">
57+
<dc:Bounds height="50.0" width="110.0" x="265.0" y="93.0"/>
58+
<bpmndi:BPMNLabel id="BPMNLabel_4" labelStyle="BPMNLabelStyle_1">
59+
<dc:Bounds height="10.0" width="52.0" x="294.0" y="113.0"/>
60+
</bpmndi:BPMNLabel>
61+
</bpmndi:BPMNShape>
62+
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="BPMNShape_1" targetElement="BPMNShape_SendTask_1">
63+
<di:waypoint xsi:type="dc:Point" x="127.0" y="118.0"/>
64+
<di:waypoint xsi:type="dc:Point" x="200.0" y="118.0"/>
65+
<di:waypoint xsi:type="dc:Point" x="265.0" y="118.0"/>
66+
<bpmndi:BPMNLabel id="BPMNLabel_3" labelStyle="BPMNLabelStyle_1">
67+
<dc:Bounds height="10.0" width="70.0" x="167.0" y="119.0"/>
68+
</bpmndi:BPMNLabel>
69+
</bpmndi:BPMNEdge>
70+
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="BPMNShape_SendTask_1" targetElement="BPMNShape_2">
71+
<di:waypoint xsi:type="dc:Point" x="375.0" y="118.0"/>
72+
<di:waypoint xsi:type="dc:Point" x="452.0" y="118.0"/>
73+
<di:waypoint xsi:type="dc:Point" x="530.0" y="118.0"/>
74+
<bpmndi:BPMNLabel id="BPMNLabel_5" labelStyle="BPMNLabelStyle_1"/>
75+
</bpmndi:BPMNEdge>
76+
</bpmndi:BPMNPlane>
77+
<bpmndi:BPMNLabelStyle id="BPMNLabelStyle_1">
78+
<dc:Font name="arial" size="9.0"/>
79+
</bpmndi:BPMNLabelStyle>
80+
</bpmndi:BPMNDiagram>
81+
</bpmn2:definitions>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<ext:createRequest xmlns:ext="http://marklogic.com/rest-api/resource/process" xmlns:wf="http://marklogic.com/workflow">
2+
<ext:processName>022-email-test__1__0</ext:processName>
3+
<ext:data>
4+
</ext:data>
5+
<ext:attachments>
6+
<wf:attachment name="Document" uri="/initial/sampledoc.xml" />
7+
</ext:attachments>
8+
</ext:createRequest>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<ext:createRequest xmlns:ext="http://marklogic.com/rest-api/resource/processsubscription">
2+
<ext:processName>022-email-test__1__0</ext:processName>
3+
<ext:name>email-sub-test</ext:name>
4+
<ext:domain>
5+
<ext:name>Some folder alerting domain</ext:name>
6+
<ext:type>directory</ext:type>
7+
<ext:path>/some/</ext:path>
8+
<ext:depth>0</ext:depth>
9+
</ext:domain>
10+
<ext:query>
11+
<cts:collection-query xmlns:cts="http://marklogic.com/cts"><cts:uri>/test/email/sub</cts:uri></cts:collection-query>
12+
</ext:query>
13+
</ext:createRequest>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<somedoc>
2+
<choiceA>B</choiceA>
3+
<choiceB>C</choiceB>
4+
</somedoc>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<em:Message
2+
xmlns:em="URN:ietf:params:email-xml:"
3+
xmlns:rf="URN:ietf:params:rfc822:">
4+
<rf:subject>Document Rejected</rf:subject>
5+
<rf:from>
6+
<em:Address>
7+
<em:name>MarkLogic Admin</em:name>
8+
<em:adrs>admin@example.com</em:adrs>
9+
</em:Address>
10+
</rf:from>
11+
<rf:to>
12+
<em:Address>
13+
<em:name>{$wf:process/wf:data/RecipientName/text()}</em:name>
14+
<em:adrs>{$wf:process/wf:data/RecipientEmail/text()}</em:adrs>
15+
</em:Address>
16+
</rf:to>
17+
<em:content>
18+
<html xmlns="http://www.w3.org/1999/xhtml">
19+
<head>
20+
<title>V2 sample rejection message</title>
21+
</head>
22+
<body>
23+
<h1>Document rejected</h1>
24+
<p>Your document {xs:string($wf:process/wf:attachments/wf:attachment[@name='Document']/@uri)} was rejected.</p>
25+
</body>
26+
</html>
27+
</em:content>
28+
</em:Message>

0 commit comments

Comments
 (0)