-
Notifications
You must be signed in to change notification settings - Fork 6
/
VPRJTDRN.m
251 lines (251 loc) · 6.17 KB
/
VPRJTDRN.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
VPRJTDRN ;AFS/MBS -- Unit tests for operational data wrapper code for jdsClient using cache.node
;
STARTUP ; Run once before all tests
N I,TAGS
F I=1:1:6 S TAGS(I)="TEST"_I_"^VPRJTD01"
D ODSBLD^VPRJTX(.TAGS)
QUIT
;
SHUTDOWN ; Run once after all tests
D ODSCLR^VPRJTX
QUIT
;
SETUP ; Run before each test
K ^TMP
QUIT
;
TEARDOWN ; Run after each test
K ^TMP
QUIT
;
ASSERT(EXPECT,ACTUAL) ; convenience
D EQ^VPRJT(EXPECT,ACTUAL)
QUIT
;
;
GETDATAMISSINGUID ;; @TEST get operational data with missing uid
N ERROR,UID,RESULT,UUID
S UID=""
;
S RESULT=$$GETOBJ^VPRJDRN(UID)
S ERROR=$P(RESULT,":")
S UUID=$P(RESULT,":",2)
;
D ASSERT(1,ERROR)
D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J)))
D ASSERT(404,$G(^TMP("HTTPERR",UUID,$J,1,"error","code")))
D ASSERT("Bad key",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message")))
D ASSERT(104,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason")))
D ASSERT("Not Found",$G(^TMP("HTTPERR",UUID,$J,1,"error","message")))
;
; cleanup
K ^TMP("HTTPERR",UUID,$J)
;
QUIT
;
GETDATABADUID ;; @TEST get operational data with bad uid
N ERROR,UID,RESULT,UUID
; clear data
D SHUTDOWN
;
S UID="urn:va:test:3"
;
S RESULT=$$GETOBJ^VPRJDRN(UID)
S ERROR=$P(RESULT,":")
S UUID=$P(RESULT,":",2)
;
D ASSERT(1,ERROR)
D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J)))
D ASSERT(404,$G(^TMP("HTTPERR",UUID,$J,1,"error","code")))
D ASSERT("UID:"_UID,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"domain")))
D ASSERT("Bad key",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message")))
D ASSERT(104,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason")))
D ASSERT("Not Found",$G(^TMP("HTTPERR",UUID,$J,1,"error","message")))
;
; cleanup
K ^TMP("HTTPERR",UUID,$J)
;
QUIT
;
GETDATABYUID ;; @TEST get operational data by uid
N ERROR,UID,RESULT,UUID
; retore data
D STARTUP
;
S UID="urn:va:test:3"
;
S RESULT=$$GETOBJ^VPRJDRN(UID)
S ERROR=$P(RESULT,":")
S UUID=$P(RESULT,":",2)
;
D ASSERT(10,$D(^TMP(UUID)))
D ASSERT(1,$D(^TMP(UUID,$J,0,1)))
D ASSERT(1,$D(^TMP(UUID,$J,"PREAMBLE")))
D ASSERT(1,$D(^TMP(UUID,$J,"POSTAMBLE")))
D ASSERT(1,$D(^TMP(UUID,$J,"STATUS")))
;
; cleanup
K ^TMP(UUID,$J)
;
QUIT
;
GETINDEXMISSINGINDEX ;; @TEST get operational data from index with missing index name
N ERROR,INDEX,RESULT,UUID
S INDEX=""
;
S RESULT=$$INDEX^VPRJDRN(INDEX)
S ERROR=$P(RESULT,":")
S UUID=$P(RESULT,":",2)
;
D ASSERT(1,ERROR)
D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J)))
D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code")))
D ASSERT("Missing name of index",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message")))
D ASSERT(101,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason")))
;
; cleanup
K ^TMP("HTTPERR",UUID,$J)
;
QUIT
;
GETINDEX ;; @TEST get operational data from index
N ERROR,INDEX,RESULT,UUID
S INDEX="test-name"
;
S RESULT=$$INDEX^VPRJDRN(INDEX)
S ERROR=$P(RESULT,":")
S UUID=$P(RESULT,":",2)
;
D ASSERT(10,$D(^TMP(UUID)))
D ASSERT(1,$D(^TMP(UUID,$J,0,1)))
D ASSERT(1,$D(^TMP(UUID,$J,1,1)))
D ASSERT(1,$D(^TMP(UUID,$J,2,1)))
D ASSERT(1,$D(^TMP(UUID,$J,3,1)))
D ASSERT(1,$D(^TMP(UUID,$J,4,1)))
D ASSERT(1,$D(^TMP(UUID,$J,5,1)))
D ASSERT(0,$D(^TMP(UUID,$J,6,1)))
D ASSERT(1,$D(^TMP(UUID,$J,"PREAMBLE")))
D ASSERT(1,$D(^TMP(UUID,$J,"POSTAMBLE")))
D ASSERT(1,$D(^TMP(UUID,$J,"STATUS")))
;
; cleanup
K ^TMP(UUID,$J)
;
QUIT
;
GETCOUNTMISSINGCOUNT ;; @TEST get operational data count with missing count name
N ERROR,COUNT,RESULT,UUID
S COUNT=""
;
S RESULT=$$COUNT^VPRJDRN(COUNT)
S ERROR=$P(RESULT,":")
S UUID=$P(RESULT,":",2)
;
D ASSERT(1,ERROR)
D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J)))
D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code")))
D ASSERT("Missing name of index",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message")))
D ASSERT(101,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason")))
;
; cleanup
K ^TMP("HTTPERR",UUID,$J)
;
QUIT
;
GETCOUNT ;; @TEST get operational data count
N ERROR,COUNT,RESULT,UUID
S COUNT="collection"
;
S RESULT=$$COUNT^VPRJDRN(COUNT)
S ERROR=$P(RESULT,":")
S UUID=$P(RESULT,":",2)
;
D ASSERT(10,$D(^TMP(UUID)))
D ASSERT(1,$D(^TMP(UUID,$J,1)))
D ASSERT(0,$D(^TMP(UUID,$J,2)))
;
; cleanup
K ^TMP(UUID,$J)
;
QUIT
;
GETALLCOUNTMISSINGCOUNT ;; @TEST get operational data all count with missing count name
N ERROR,COUNT,ALL,RESULT,UUID
S COUNT="",ALL="true"
;
S RESULT=$$COUNT^VPRJDRN(COUNT,ALL)
S ERROR=$P(RESULT,":")
S UUID=$P(RESULT,":",2)
;
D ASSERT(1,ERROR)
D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J)))
D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code")))
D ASSERT("Missing name of index",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message")))
D ASSERT(101,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason")))
;
; cleanup
K ^TMP("HTTPERR",UUID,$J)
;
QUIT
;
GETALLCOUNT ;; @TEST get operational data all count
N ERROR,COUNT,ALL,RESULT,UUID
S COUNT="collection",ALL="true"
;
S RESULT=$$COUNT^VPRJDRN(COUNT,ALL)
S ERROR=$P(RESULT,":")
S UUID=$P(RESULT,":",2)
;
D ASSERT(10,$D(^TMP(UUID)))
D ASSERT(1,$D(^TMP(UUID,$J,1)))
D ASSERT(0,$D(^TMP(UUID,$J,2)))
;
; cleanup
K ^TMP(UUID,$J)
;
QUIT
;
FINDMISSINGCOLL ;; @TEST operational data find with missing collection
N ERROR,INDEX,RESULT,UUID
S INDEX=""
;
S RESULT=$$INDEX^VPRJDRN(INDEX)
S ERROR=$P(RESULT,":")
S UUID=$P(RESULT,":",2)
;
D ASSERT(1,ERROR)
D ASSERT(10,$D(^TMP("HTTPERR",UUID,$J)))
D ASSERT(400,$G(^TMP("HTTPERR",UUID,$J,1,"error","code")))
D ASSERT("Missing name of index",$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"message")))
D ASSERT(101,$G(^TMP("HTTPERR",UUID,$J,1,"error","errors",1,"reason")))
;
; cleanup
K ^TMP("HTTPERR",UUID,$J)
;
QUIT
;
FIND ;; @TEST get operational data find
N ERROR,INDEX,RESULT,UUID
S INDEX="test-name"
;
S RESULT=$$INDEX^VPRJDRN(INDEX)
S ERROR=$P(RESULT,":")
S UUID=$P(RESULT,":",2)
;
D ASSERT(10,$D(^TMP(UUID)))
D ASSERT(1,$D(^TMP(UUID,$J,0,1)))
D ASSERT(1,$D(^TMP(UUID,$J,1,1)))
D ASSERT(1,$D(^TMP(UUID,$J,2,1)))
D ASSERT(1,$D(^TMP(UUID,$J,3,1)))
D ASSERT(1,$D(^TMP(UUID,$J,4,1)))
D ASSERT(1,$D(^TMP(UUID,$J,5,1)))
D ASSERT(0,$D(^TMP(UUID,$J,6,1)))
D ASSERT(1,$D(^TMP(UUID,$J,"PREAMBLE")))
D ASSERT(1,$D(^TMP(UUID,$J,"POSTAMBLE")))
D ASSERT(1,$D(^TMP(UUID,$J,"STATUS")))
;
; cleanup
K ^TMP(UUID,$J)
;
QUIT
;