Mercurial > hg > orthanc-databases
annotate Framework/Plugins/IndexUnitTests.h @ 114:fbdef0562717 OrthancMySQL-2.0
typo
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 23 Jan 2019 20:14:24 +0100 |
parents | 714c5d2bee76 |
children | 4cd7e45b671e |
rev | line source |
---|---|
0 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
67 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
28
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
27
diff
changeset
|
24 #include "../Common/ImplicitTransaction.h" |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
27
diff
changeset
|
25 |
0 | 26 #include <orthanc/OrthancCDatabasePlugin.h> |
27 #include <OrthancServer/ServerEnumerations.h> | |
28 | |
29 #include <gtest/gtest.h> | |
30 #include <list> | |
31 | |
32 | |
33 static std::auto_ptr<OrthancPluginAttachment> expectedAttachment; | |
34 static std::list<OrthancPluginDicomTag> expectedDicomTags; | |
35 static std::auto_ptr<OrthancPluginExportedResource> expectedExported; | |
36 | |
37 static void CheckAttachment(const OrthancPluginAttachment& attachment) | |
38 { | |
39 ASSERT_STREQ(expectedAttachment->uuid, attachment.uuid); | |
40 ASSERT_EQ(expectedAttachment->contentType, attachment.contentType); | |
41 ASSERT_EQ(expectedAttachment->uncompressedSize, attachment.uncompressedSize); | |
42 ASSERT_STREQ(expectedAttachment->uncompressedHash, attachment.uncompressedHash); | |
43 ASSERT_EQ(expectedAttachment->compressionType, attachment.compressionType); | |
44 ASSERT_EQ(expectedAttachment->compressedSize, attachment.compressedSize); | |
45 ASSERT_STREQ(expectedAttachment->compressedHash, attachment.compressedHash); | |
46 } | |
47 | |
48 static void CheckExportedResource(const OrthancPluginExportedResource& exported) | |
49 { | |
50 ASSERT_EQ(expectedExported->seq, exported.seq); | |
51 ASSERT_EQ(expectedExported->resourceType, exported.resourceType); | |
52 ASSERT_STREQ(expectedExported->publicId, exported.publicId); | |
53 ASSERT_STREQ(expectedExported->modality, exported.modality); | |
54 ASSERT_STREQ(expectedExported->date, exported.date); | |
55 ASSERT_STREQ(expectedExported->patientId, exported.patientId); | |
56 ASSERT_STREQ(expectedExported->studyInstanceUid, exported.studyInstanceUid); | |
57 ASSERT_STREQ(expectedExported->seriesInstanceUid, exported.seriesInstanceUid); | |
58 ASSERT_STREQ(expectedExported->sopInstanceUid, exported.sopInstanceUid); | |
59 } | |
60 | |
61 static void CheckDicomTag(const OrthancPluginDicomTag& tag) | |
62 { | |
63 for (std::list<OrthancPluginDicomTag>::const_iterator | |
64 it = expectedDicomTags.begin(); it != expectedDicomTags.end(); ++it) | |
65 { | |
66 if (it->group == tag.group && | |
67 it->element == tag.element && | |
68 !strcmp(it->value, tag.value)) | |
69 { | |
70 // OK, match | |
71 return; | |
72 } | |
73 } | |
74 | |
75 ASSERT_TRUE(0); // Error | |
76 } | |
77 | |
78 | |
79 | |
80 static OrthancPluginErrorCode InvokeService(struct _OrthancPluginContext_t* context, | |
81 _OrthancPluginService service, | |
82 const void* params) | |
83 { | |
84 if (service == _OrthancPluginService_DatabaseAnswer) | |
85 { | |
86 const _OrthancPluginDatabaseAnswer& answer = | |
87 *reinterpret_cast<const _OrthancPluginDatabaseAnswer*>(params); | |
88 | |
89 switch (answer.type) | |
90 { | |
91 case _OrthancPluginDatabaseAnswerType_Attachment: | |
92 { | |
93 const OrthancPluginAttachment& attachment = | |
94 *reinterpret_cast<const OrthancPluginAttachment*>(answer.valueGeneric); | |
95 CheckAttachment(attachment); | |
96 break; | |
97 } | |
98 | |
99 case _OrthancPluginDatabaseAnswerType_ExportedResource: | |
100 { | |
101 const OrthancPluginExportedResource& attachment = | |
102 *reinterpret_cast<const OrthancPluginExportedResource*>(answer.valueGeneric); | |
103 CheckExportedResource(attachment); | |
104 break; | |
105 } | |
106 | |
107 case _OrthancPluginDatabaseAnswerType_DicomTag: | |
108 { | |
109 const OrthancPluginDicomTag& tag = | |
110 *reinterpret_cast<const OrthancPluginDicomTag*>(answer.valueGeneric); | |
111 CheckDicomTag(tag); | |
112 break; | |
113 } | |
114 | |
115 default: | |
116 printf("Unhandled message: %d\n", answer.type); | |
117 break; | |
118 } | |
119 } | |
120 | |
121 return OrthancPluginErrorCode_Success; | |
122 } | |
123 | |
124 | |
125 TEST(IndexBackend, Basic) | |
126 { | |
127 using namespace OrthancDatabases; | |
128 | |
129 OrthancPluginContext context; | |
130 context.pluginsManager = NULL; | |
131 context.orthancVersion = "mainline"; | |
132 context.Free = ::free; | |
133 context.InvokeService = InvokeService; | |
134 | |
28
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
27
diff
changeset
|
135 ImplicitTransaction::SetErrorOnDoubleExecution(true); |
c0cb5d2cd696
checks depending on Orthanc version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
27
diff
changeset
|
136 |
0 | 137 #if ORTHANC_ENABLE_POSTGRESQL == 1 |
138 PostgreSQLIndex db(globalParameters_); | |
139 db.SetClearAll(true); | |
140 #elif ORTHANC_ENABLE_MYSQL == 1 | |
141 MySQLIndex db(globalParameters_); | |
142 db.SetClearAll(true); | |
143 #elif ORTHANC_ENABLE_SQLITE == 1 | |
144 SQLiteIndex db; // Open in memory | |
145 #else | |
146 # error Unsupported database backend | |
147 #endif | |
148 | |
149 db.RegisterOutput(new OrthancPlugins::DatabaseBackendOutput(&context, NULL)); | |
150 db.Open(); | |
26 | 151 |
0 | 152 |
153 std::string s; | |
154 ASSERT_TRUE(db.LookupGlobalProperty(s, Orthanc::GlobalProperty_DatabaseSchemaVersion)); | |
155 ASSERT_EQ("6", s); | |
156 | |
157 ASSERT_FALSE(db.LookupGlobalProperty(s, Orthanc::GlobalProperty_AnonymizationSequence)); | |
158 db.SetGlobalProperty(Orthanc::GlobalProperty_AnonymizationSequence, "Hello"); | |
159 ASSERT_TRUE(db.LookupGlobalProperty(s, Orthanc::GlobalProperty_AnonymizationSequence)); | |
160 ASSERT_EQ("Hello", s); | |
161 db.SetGlobalProperty(Orthanc::GlobalProperty_AnonymizationSequence, "HelloWorld"); | |
162 ASSERT_TRUE(db.LookupGlobalProperty(s, Orthanc::GlobalProperty_AnonymizationSequence)); | |
163 ASSERT_EQ("HelloWorld", s); | |
164 | |
165 int64_t a = db.CreateResource("study", OrthancPluginResourceType_Study); | |
166 ASSERT_TRUE(db.IsExistingResource(a)); | |
167 ASSERT_FALSE(db.IsExistingResource(a + 1)); | |
168 | |
169 int64_t b; | |
170 OrthancPluginResourceType t; | |
171 ASSERT_FALSE(db.LookupResource(b, t, "world")); | |
172 ASSERT_TRUE(db.LookupResource(b, t, "study")); | |
173 ASSERT_EQ(a, b); | |
174 ASSERT_EQ(OrthancPluginResourceType_Study, t); | |
175 | |
176 b = db.CreateResource("series", OrthancPluginResourceType_Series); | |
177 ASSERT_NE(a, b); | |
178 | |
179 ASSERT_EQ("study", db.GetPublicId(a)); | |
180 ASSERT_EQ("series", db.GetPublicId(b)); | |
181 ASSERT_EQ(OrthancPluginResourceType_Study, db.GetResourceType(a)); | |
182 ASSERT_EQ(OrthancPluginResourceType_Series, db.GetResourceType(b)); | |
183 | |
184 db.AttachChild(a, b); | |
185 | |
186 int64_t c; | |
187 ASSERT_FALSE(db.LookupParent(c, a)); | |
188 ASSERT_TRUE(db.LookupParent(c, b)); | |
189 ASSERT_EQ(a, c); | |
190 | |
191 c = db.CreateResource("series2", OrthancPluginResourceType_Series); | |
192 db.AttachChild(a, c); | |
193 | |
194 ASSERT_EQ(3u, db.GetResourcesCount()); | |
195 ASSERT_EQ(0u, db.GetResourceCount(OrthancPluginResourceType_Patient)); | |
196 ASSERT_EQ(1u, db.GetResourceCount(OrthancPluginResourceType_Study)); | |
197 ASSERT_EQ(2u, db.GetResourceCount(OrthancPluginResourceType_Series)); | |
198 | |
199 ASSERT_FALSE(db.GetParentPublicId(s, a)); | |
200 ASSERT_TRUE(db.GetParentPublicId(s, b)); ASSERT_EQ("study", s); | |
201 ASSERT_TRUE(db.GetParentPublicId(s, c)); ASSERT_EQ("study", s); | |
202 | |
203 std::list<std::string> children; | |
204 db.GetChildren(children, a); | |
205 ASSERT_EQ(2u, children.size()); | |
206 db.GetChildren(children, b); | |
207 ASSERT_EQ(0u, children.size()); | |
208 db.GetChildren(children, c); | |
209 ASSERT_EQ(0u, children.size()); | |
210 | |
211 std::list<std::string> cp; | |
212 db.GetChildrenPublicId(cp, a); | |
213 ASSERT_EQ(2u, cp.size()); | |
214 ASSERT_TRUE(cp.front() == "series" || cp.front() == "series2"); | |
215 ASSERT_TRUE(cp.back() == "series" || cp.back() == "series2"); | |
216 ASSERT_NE(cp.front(), cp.back()); | |
217 | |
218 std::list<std::string> pub; | |
219 db.GetAllPublicIds(pub, OrthancPluginResourceType_Patient); | |
220 ASSERT_EQ(0u, pub.size()); | |
221 db.GetAllPublicIds(pub, OrthancPluginResourceType_Study); | |
222 ASSERT_EQ(1u, pub.size()); | |
223 ASSERT_EQ("study", pub.front()); | |
224 db.GetAllPublicIds(pub, OrthancPluginResourceType_Series); | |
225 ASSERT_EQ(2u, pub.size()); | |
226 ASSERT_TRUE(pub.front() == "series" || pub.front() == "series2"); | |
227 ASSERT_TRUE(pub.back() == "series" || pub.back() == "series2"); | |
228 ASSERT_NE(pub.front(), pub.back()); | |
229 | |
230 std::list<int64_t> ci; | |
231 db.GetChildrenInternalId(ci, a); | |
232 ASSERT_EQ(2u, ci.size()); | |
233 ASSERT_TRUE(ci.front() == b || ci.front() == c); | |
234 ASSERT_TRUE(ci.back() == b || ci.back() == c); | |
235 ASSERT_NE(ci.front(), ci.back()); | |
236 | |
237 db.SetMetadata(a, Orthanc::MetadataType_ModifiedFrom, "modified"); | |
238 db.SetMetadata(a, Orthanc::MetadataType_LastUpdate, "update2"); | |
239 ASSERT_FALSE(db.LookupMetadata(s, b, Orthanc::MetadataType_LastUpdate)); | |
240 ASSERT_TRUE(db.LookupMetadata(s, a, Orthanc::MetadataType_LastUpdate)); | |
241 ASSERT_EQ("update2", s); | |
242 db.SetMetadata(a, Orthanc::MetadataType_LastUpdate, "update"); | |
243 ASSERT_TRUE(db.LookupMetadata(s, a, Orthanc::MetadataType_LastUpdate)); | |
244 ASSERT_EQ("update", s); | |
245 | |
246 std::list<int32_t> md; | |
247 db.ListAvailableMetadata(md, a); | |
248 ASSERT_EQ(2u, md.size()); | |
249 ASSERT_TRUE(md.front() == Orthanc::MetadataType_ModifiedFrom || md.back() == Orthanc::MetadataType_ModifiedFrom); | |
250 ASSERT_TRUE(md.front() == Orthanc::MetadataType_LastUpdate || md.back() == Orthanc::MetadataType_LastUpdate); | |
251 std::string mdd; | |
252 ASSERT_TRUE(db.LookupMetadata(mdd, a, Orthanc::MetadataType_ModifiedFrom)); | |
253 ASSERT_EQ("modified", mdd); | |
254 ASSERT_TRUE(db.LookupMetadata(mdd, a, Orthanc::MetadataType_LastUpdate)); | |
255 ASSERT_EQ("update", mdd); | |
256 | |
257 db.ListAvailableMetadata(md, b); | |
258 ASSERT_EQ(0u, md.size()); | |
259 | |
260 db.DeleteMetadata(a, Orthanc::MetadataType_LastUpdate); | |
261 db.DeleteMetadata(b, Orthanc::MetadataType_LastUpdate); | |
262 ASSERT_FALSE(db.LookupMetadata(s, a, Orthanc::MetadataType_LastUpdate)); | |
263 | |
264 db.ListAvailableMetadata(md, a); | |
265 ASSERT_EQ(1u, md.size()); | |
266 ASSERT_EQ(Orthanc::MetadataType_ModifiedFrom, md.front()); | |
267 | |
268 ASSERT_EQ(0u, db.GetTotalCompressedSize()); | |
269 ASSERT_EQ(0u, db.GetTotalUncompressedSize()); | |
270 | |
271 | |
272 std::list<int32_t> fc; | |
273 | |
274 OrthancPluginAttachment a1; | |
275 a1.uuid = "uuid1"; | |
276 a1.contentType = Orthanc::FileContentType_Dicom; | |
277 a1.uncompressedSize = 42; | |
278 a1.uncompressedHash = "md5_1"; | |
279 a1.compressionType = Orthanc::CompressionType_None; | |
280 a1.compressedSize = 42; | |
281 a1.compressedHash = "md5_1"; | |
282 | |
283 OrthancPluginAttachment a2; | |
284 a2.uuid = "uuid2"; | |
285 a2.contentType = Orthanc::FileContentType_DicomAsJson; | |
286 a2.uncompressedSize = 4242; | |
287 a2.uncompressedHash = "md5_2"; | |
288 a2.compressionType = Orthanc::CompressionType_None; | |
289 a2.compressedSize = 4242; | |
290 a2.compressedHash = "md5_2"; | |
291 | |
292 db.AddAttachment(a, a1); | |
293 db.ListAvailableAttachments(fc, a); | |
294 ASSERT_EQ(1u, fc.size()); | |
295 ASSERT_EQ(Orthanc::FileContentType_Dicom, fc.front()); | |
296 db.AddAttachment(a, a2); | |
297 db.ListAvailableAttachments(fc, a); | |
298 ASSERT_EQ(2u, fc.size()); | |
299 ASSERT_FALSE(db.LookupAttachment(b, Orthanc::FileContentType_Dicom)); | |
300 | |
301 ASSERT_EQ(4284u, db.GetTotalCompressedSize()); | |
302 ASSERT_EQ(4284u, db.GetTotalUncompressedSize()); | |
303 | |
304 expectedAttachment.reset(new OrthancPluginAttachment); | |
305 expectedAttachment->uuid = "uuid1"; | |
306 expectedAttachment->contentType = Orthanc::FileContentType_Dicom; | |
307 expectedAttachment->uncompressedSize = 42; | |
308 expectedAttachment->uncompressedHash = "md5_1"; | |
309 expectedAttachment->compressionType = Orthanc::CompressionType_None; | |
310 expectedAttachment->compressedSize = 42; | |
311 expectedAttachment->compressedHash = "md5_1"; | |
312 ASSERT_TRUE(db.LookupAttachment(a, Orthanc::FileContentType_Dicom)); | |
313 | |
314 expectedAttachment.reset(new OrthancPluginAttachment); | |
315 expectedAttachment->uuid = "uuid2"; | |
316 expectedAttachment->contentType = Orthanc::FileContentType_DicomAsJson; | |
317 expectedAttachment->uncompressedSize = 4242; | |
318 expectedAttachment->uncompressedHash = "md5_2"; | |
319 expectedAttachment->compressionType = Orthanc::CompressionType_None; | |
320 expectedAttachment->compressedSize = 4242; | |
321 expectedAttachment->compressedHash = "md5_2"; | |
322 ASSERT_TRUE(db.LookupAttachment(a, Orthanc::FileContentType_DicomAsJson)); | |
323 | |
324 db.ListAvailableAttachments(fc, b); | |
325 ASSERT_EQ(0u, fc.size()); | |
326 db.DeleteAttachment(a, Orthanc::FileContentType_Dicom); | |
327 db.ListAvailableAttachments(fc, a); | |
328 ASSERT_EQ(1u, fc.size()); | |
329 ASSERT_EQ(Orthanc::FileContentType_DicomAsJson, fc.front()); | |
330 db.DeleteAttachment(a, Orthanc::FileContentType_DicomAsJson); | |
331 db.ListAvailableAttachments(fc, a); | |
332 ASSERT_EQ(0u, fc.size()); | |
333 | |
334 | |
335 db.SetIdentifierTag(a, 0x0010, 0x0020, "patient"); | |
336 db.SetIdentifierTag(a, 0x0020, 0x000d, "study"); | |
337 | |
338 expectedDicomTags.clear(); | |
339 expectedDicomTags.push_back(OrthancPluginDicomTag()); | |
340 expectedDicomTags.push_back(OrthancPluginDicomTag()); | |
341 expectedDicomTags.front().group = 0x0010; | |
342 expectedDicomTags.front().element = 0x0020; | |
343 expectedDicomTags.front().value = "patient"; | |
344 expectedDicomTags.back().group = 0x0020; | |
345 expectedDicomTags.back().element = 0x000d; | |
346 expectedDicomTags.back().value = "study"; | |
347 db.GetMainDicomTags(a); | |
348 | |
349 | |
350 db.LookupIdentifier(ci, OrthancPluginResourceType_Study, 0x0010, 0x0020, | |
351 OrthancPluginIdentifierConstraint_Equal, "patient"); | |
352 ASSERT_EQ(1u, ci.size()); | |
353 ASSERT_EQ(a, ci.front()); | |
354 db.LookupIdentifier(ci, OrthancPluginResourceType_Study, 0x0010, 0x0020, | |
355 OrthancPluginIdentifierConstraint_Equal, "study"); | |
356 ASSERT_EQ(0u, ci.size()); | |
357 | |
358 | |
359 OrthancPluginExportedResource exp; | |
360 exp.seq = -1; | |
361 exp.resourceType = OrthancPluginResourceType_Study; | |
362 exp.publicId = "id"; | |
363 exp.modality = "remote"; | |
364 exp.date = "date"; | |
365 exp.patientId = "patient"; | |
366 exp.studyInstanceUid = "study"; | |
367 exp.seriesInstanceUid = "series"; | |
368 exp.sopInstanceUid = "instance"; | |
369 db.LogExportedResource(exp); | |
370 | |
371 expectedExported.reset(new OrthancPluginExportedResource()); | |
372 *expectedExported = exp; | |
373 expectedExported->seq = 1; | |
374 | |
375 bool done; | |
376 db.GetExportedResources(done, 0, 10); | |
377 | |
378 | |
379 db.GetAllPublicIds(pub, OrthancPluginResourceType_Patient); ASSERT_EQ(0u, pub.size()); | |
380 db.GetAllPublicIds(pub, OrthancPluginResourceType_Study); ASSERT_EQ(1u, pub.size()); | |
381 db.GetAllPublicIds(pub, OrthancPluginResourceType_Series); ASSERT_EQ(2u, pub.size()); | |
382 db.GetAllPublicIds(pub, OrthancPluginResourceType_Instance); ASSERT_EQ(0u, pub.size()); | |
383 ASSERT_EQ(3u, db.GetResourcesCount()); | |
384 | |
385 ASSERT_EQ(0u, db.GetUnprotectedPatientsCount()); // No patient was inserted | |
386 ASSERT_TRUE(db.IsExistingResource(c)); | |
27
173176f8cef2
jobs branch has disappeared in orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
387 |
173176f8cef2
jobs branch has disappeared in orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
388 { |
173176f8cef2
jobs branch has disappeared in orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
389 // A transaction is needed here for MySQL, as it was not possible |
173176f8cef2
jobs branch has disappeared in orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
390 // to implement recursive deletion of resources using pure SQL |
173176f8cef2
jobs branch has disappeared in orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
391 // statements |
173176f8cef2
jobs branch has disappeared in orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
392 db.StartTransaction(); |
173176f8cef2
jobs branch has disappeared in orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
393 db.DeleteResource(c); |
173176f8cef2
jobs branch has disappeared in orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
394 db.CommitTransaction(); |
173176f8cef2
jobs branch has disappeared in orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
395 } |
173176f8cef2
jobs branch has disappeared in orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
396 |
0 | 397 ASSERT_FALSE(db.IsExistingResource(c)); |
398 ASSERT_TRUE(db.IsExistingResource(a)); | |
399 ASSERT_TRUE(db.IsExistingResource(b)); | |
400 ASSERT_EQ(2u, db.GetResourcesCount()); | |
401 db.DeleteResource(a); | |
402 ASSERT_EQ(0u, db.GetResourcesCount()); | |
403 ASSERT_FALSE(db.IsExistingResource(a)); | |
404 ASSERT_FALSE(db.IsExistingResource(b)); | |
405 ASSERT_FALSE(db.IsExistingResource(c)); | |
406 | |
407 ASSERT_EQ(0u, db.GetResourcesCount()); | |
408 ASSERT_EQ(0u, db.GetUnprotectedPatientsCount()); | |
409 int64_t p1 = db.CreateResource("patient1", OrthancPluginResourceType_Patient); | |
410 int64_t p2 = db.CreateResource("patient2", OrthancPluginResourceType_Patient); | |
411 int64_t p3 = db.CreateResource("patient3", OrthancPluginResourceType_Patient); | |
412 ASSERT_EQ(3u, db.GetUnprotectedPatientsCount()); | |
413 int64_t r; | |
414 ASSERT_TRUE(db.SelectPatientToRecycle(r)); | |
415 ASSERT_EQ(p1, r); | |
416 ASSERT_TRUE(db.SelectPatientToRecycle(r, p1)); | |
417 ASSERT_EQ(p2, r); | |
418 ASSERT_FALSE(db.IsProtectedPatient(p1)); | |
419 db.SetProtectedPatient(p1, true); | |
420 ASSERT_TRUE(db.IsProtectedPatient(p1)); | |
421 ASSERT_TRUE(db.SelectPatientToRecycle(r)); | |
422 ASSERT_EQ(p2, r); | |
423 db.SetProtectedPatient(p1, false); | |
424 ASSERT_FALSE(db.IsProtectedPatient(p1)); | |
425 ASSERT_TRUE(db.SelectPatientToRecycle(r)); | |
426 ASSERT_EQ(p2, r); | |
427 db.DeleteResource(p2); | |
428 ASSERT_TRUE(db.SelectPatientToRecycle(r, p3)); | |
429 ASSERT_EQ(p1, r); | |
430 } |