comparison UnitTestsSources/ServerIndex.cpp @ 633:e207b33216db

merge
author jodogne
date Tue, 29 Oct 2013 09:04:25 +0100
parents 17815b9d4280
children 01d8611c4a60
comparison
equal deleted inserted replaced
626:b8322fe3bdba 633:e207b33216db
1 #include "gtest/gtest.h"
2
3 #include "../OrthancServer/DatabaseWrapper.h"
4 #include "../Core/Uuid.h"
5
6 #include <ctype.h>
7 #include <glog/logging.h>
8 #include <algorithm>
9
10 using namespace Orthanc;
11
12 namespace
13 {
14 class ServerIndexListener : public IServerIndexListener
15 {
16 public:
17 std::vector<std::string> deletedFiles_;
18 std::string ancestorId_;
19 ResourceType ancestorType_;
20
21 void Reset()
22 {
23 ancestorId_ = "";
24 deletedFiles_.clear();
25 }
26
27 virtual void SignalRemainingAncestor(ResourceType type,
28 const std::string& publicId)
29 {
30 ancestorId_ = publicId;
31 ancestorType_ = type;
32 }
33
34 virtual void SignalFileDeleted(const FileInfo& info)
35 {
36 const std::string fileUuid = info.GetUuid();
37 deletedFiles_.push_back(fileUuid);
38 LOG(INFO) << "A file must be removed: " << fileUuid;
39 }
40 };
41 }
42
43
44 TEST(DatabaseWrapper, Simple)
45 {
46 ServerIndexListener listener;
47 DatabaseWrapper index(listener);
48
49 int64_t a[] = {
50 index.CreateResource("a", ResourceType_Patient), // 0
51 index.CreateResource("b", ResourceType_Study), // 1
52 index.CreateResource("c", ResourceType_Series), // 2
53 index.CreateResource("d", ResourceType_Instance), // 3
54 index.CreateResource("e", ResourceType_Instance), // 4
55 index.CreateResource("f", ResourceType_Instance), // 5
56 index.CreateResource("g", ResourceType_Study) // 6
57 };
58
59 ASSERT_EQ("a", index.GetPublicId(a[0]));
60 ASSERT_EQ("b", index.GetPublicId(a[1]));
61 ASSERT_EQ("c", index.GetPublicId(a[2]));
62 ASSERT_EQ("d", index.GetPublicId(a[3]));
63 ASSERT_EQ("e", index.GetPublicId(a[4]));
64 ASSERT_EQ("f", index.GetPublicId(a[5]));
65 ASSERT_EQ("g", index.GetPublicId(a[6]));
66
67 ASSERT_EQ(ResourceType_Patient, index.GetResourceType(a[0]));
68 ASSERT_EQ(ResourceType_Study, index.GetResourceType(a[1]));
69 ASSERT_EQ(ResourceType_Series, index.GetResourceType(a[2]));
70 ASSERT_EQ(ResourceType_Instance, index.GetResourceType(a[3]));
71 ASSERT_EQ(ResourceType_Instance, index.GetResourceType(a[4]));
72 ASSERT_EQ(ResourceType_Instance, index.GetResourceType(a[5]));
73 ASSERT_EQ(ResourceType_Study, index.GetResourceType(a[6]));
74
75 {
76 Json::Value t;
77 index.GetAllPublicIds(t, ResourceType_Patient);
78
79 ASSERT_EQ(1u, t.size());
80 ASSERT_EQ("a", t[0u].asString());
81
82 index.GetAllPublicIds(t, ResourceType_Series);
83 ASSERT_EQ(1u, t.size());
84 ASSERT_EQ("c", t[0u].asString());
85
86 index.GetAllPublicIds(t, ResourceType_Study);
87 ASSERT_EQ(2u, t.size());
88
89 index.GetAllPublicIds(t, ResourceType_Instance);
90 ASSERT_EQ(3u, t.size());
91 }
92
93 index.SetGlobalProperty(GlobalProperty_FlushSleep, "World");
94
95 index.AttachChild(a[0], a[1]);
96 index.AttachChild(a[1], a[2]);
97 index.AttachChild(a[2], a[3]);
98 index.AttachChild(a[2], a[4]);
99 index.AttachChild(a[6], a[5]);
100
101 int64_t parent;
102 ASSERT_FALSE(index.LookupParent(parent, a[0]));
103 ASSERT_TRUE(index.LookupParent(parent, a[1])); ASSERT_EQ(a[0], parent);
104 ASSERT_TRUE(index.LookupParent(parent, a[2])); ASSERT_EQ(a[1], parent);
105 ASSERT_TRUE(index.LookupParent(parent, a[3])); ASSERT_EQ(a[2], parent);
106 ASSERT_TRUE(index.LookupParent(parent, a[4])); ASSERT_EQ(a[2], parent);
107 ASSERT_TRUE(index.LookupParent(parent, a[5])); ASSERT_EQ(a[6], parent);
108 ASSERT_FALSE(index.LookupParent(parent, a[6]));
109
110 std::string s;
111
112 ASSERT_FALSE(index.GetParentPublicId(s, a[0]));
113 ASSERT_FALSE(index.GetParentPublicId(s, a[6]));
114 ASSERT_TRUE(index.GetParentPublicId(s, a[1])); ASSERT_EQ("a", s);
115 ASSERT_TRUE(index.GetParentPublicId(s, a[2])); ASSERT_EQ("b", s);
116 ASSERT_TRUE(index.GetParentPublicId(s, a[3])); ASSERT_EQ("c", s);
117 ASSERT_TRUE(index.GetParentPublicId(s, a[4])); ASSERT_EQ("c", s);
118 ASSERT_TRUE(index.GetParentPublicId(s, a[5])); ASSERT_EQ("g", s);
119
120 std::list<std::string> l;
121 index.GetChildrenPublicId(l, a[0]); ASSERT_EQ(1u, l.size()); ASSERT_EQ("b", l.front());
122 index.GetChildrenPublicId(l, a[1]); ASSERT_EQ(1u, l.size()); ASSERT_EQ("c", l.front());
123 index.GetChildrenPublicId(l, a[3]); ASSERT_EQ(0u, l.size());
124 index.GetChildrenPublicId(l, a[4]); ASSERT_EQ(0u, l.size());
125 index.GetChildrenPublicId(l, a[5]); ASSERT_EQ(0u, l.size());
126 index.GetChildrenPublicId(l, a[6]); ASSERT_EQ(1u, l.size()); ASSERT_EQ("f", l.front());
127
128 index.GetChildrenPublicId(l, a[2]); ASSERT_EQ(2u, l.size());
129 if (l.front() == "d")
130 {
131 ASSERT_EQ("e", l.back());
132 }
133 else
134 {
135 ASSERT_EQ("d", l.back());
136 ASSERT_EQ("e", l.front());
137 }
138
139 std::list<MetadataType> md;
140 index.ListAvailableMetadata(md, a[4]);
141 ASSERT_EQ(0u, md.size());
142
143 index.AddAttachment(a[4], FileInfo("my json file", FileContentType_Json, 42, CompressionType_Zlib, 21));
144 index.AddAttachment(a[4], FileInfo("my dicom file", FileContentType_Dicom, 42));
145 index.AddAttachment(a[6], FileInfo("world", FileContentType_Dicom, 44));
146 index.SetMetadata(a[4], MetadataType_Instance_RemoteAet, "PINNACLE");
147
148 index.ListAvailableMetadata(md, a[4]);
149 ASSERT_EQ(1u, md.size());
150 ASSERT_EQ(MetadataType_Instance_RemoteAet, md.front());
151 index.SetMetadata(a[4], MetadataType_ModifiedFrom, "TUTU");
152 index.ListAvailableMetadata(md, a[4]);
153 ASSERT_EQ(2u, md.size());
154 index.DeleteMetadata(a[4], MetadataType_ModifiedFrom);
155 index.ListAvailableMetadata(md, a[4]);
156 ASSERT_EQ(1u, md.size());
157 ASSERT_EQ(MetadataType_Instance_RemoteAet, md.front());
158
159 ASSERT_EQ(21u + 42u + 44u, index.GetTotalCompressedSize());
160 ASSERT_EQ(42u + 42u + 44u, index.GetTotalUncompressedSize());
161
162 DicomMap m;
163 m.SetValue(0x0010, 0x0010, "PatientName");
164 index.SetMainDicomTags(a[3], m);
165
166 int64_t b;
167 ResourceType t;
168 ASSERT_TRUE(index.LookupResource("g", b, t));
169 ASSERT_EQ(7, b);
170 ASSERT_EQ(ResourceType_Study, t);
171
172 ASSERT_TRUE(index.LookupMetadata(s, a[4], MetadataType_Instance_RemoteAet));
173 ASSERT_FALSE(index.LookupMetadata(s, a[4], MetadataType_Instance_IndexInSeries));
174 ASSERT_EQ("PINNACLE", s);
175 ASSERT_EQ("PINNACLE", index.GetMetadata(a[4], MetadataType_Instance_RemoteAet));
176 ASSERT_EQ("None", index.GetMetadata(a[4], MetadataType_Instance_IndexInSeries, "None"));
177
178 ASSERT_TRUE(index.LookupGlobalProperty(s, GlobalProperty_FlushSleep));
179 ASSERT_FALSE(index.LookupGlobalProperty(s, static_cast<GlobalProperty>(42)));
180 ASSERT_EQ("World", s);
181 ASSERT_EQ("World", index.GetGlobalProperty(GlobalProperty_FlushSleep));
182 ASSERT_EQ("None", index.GetGlobalProperty(static_cast<GlobalProperty>(42), "None"));
183
184 FileInfo att;
185 ASSERT_TRUE(index.LookupAttachment(att, a[4], FileContentType_Json));
186 ASSERT_EQ("my json file", att.GetUuid());
187 ASSERT_EQ(21u, att.GetCompressedSize());
188 ASSERT_EQ(42u, att.GetUncompressedSize());
189 ASSERT_EQ(CompressionType_Zlib, att.GetCompressionType());
190
191 ASSERT_EQ(0u, listener.deletedFiles_.size());
192 ASSERT_EQ(7u, index.GetTableRecordCount("Resources"));
193 ASSERT_EQ(3u, index.GetTableRecordCount("AttachedFiles"));
194 ASSERT_EQ(1u, index.GetTableRecordCount("Metadata"));
195 ASSERT_EQ(1u, index.GetTableRecordCount("MainDicomTags"));
196 index.DeleteResource(a[0]);
197
198 ASSERT_EQ(2u, listener.deletedFiles_.size());
199 ASSERT_FALSE(std::find(listener.deletedFiles_.begin(),
200 listener.deletedFiles_.end(),
201 "my json file") == listener.deletedFiles_.end());
202 ASSERT_FALSE(std::find(listener.deletedFiles_.begin(),
203 listener.deletedFiles_.end(),
204 "my dicom file") == listener.deletedFiles_.end());
205
206 ASSERT_EQ(2u, index.GetTableRecordCount("Resources"));
207 ASSERT_EQ(0u, index.GetTableRecordCount("Metadata"));
208 ASSERT_EQ(1u, index.GetTableRecordCount("AttachedFiles"));
209 ASSERT_EQ(0u, index.GetTableRecordCount("MainDicomTags"));
210 index.DeleteResource(a[5]);
211 ASSERT_EQ(0u, index.GetTableRecordCount("Resources"));
212 ASSERT_EQ(0u, index.GetTableRecordCount("AttachedFiles"));
213 ASSERT_EQ(2u, index.GetTableRecordCount("GlobalProperties"));
214
215 ASSERT_EQ(3u, listener.deletedFiles_.size());
216 ASSERT_FALSE(std::find(listener.deletedFiles_.begin(),
217 listener.deletedFiles_.end(),
218 "world") == listener.deletedFiles_.end());
219 }
220
221
222
223
224 TEST(DatabaseWrapper, Upward)
225 {
226 ServerIndexListener listener;
227 DatabaseWrapper index(listener);
228
229 int64_t a[] = {
230 index.CreateResource("a", ResourceType_Patient), // 0
231 index.CreateResource("b", ResourceType_Study), // 1
232 index.CreateResource("c", ResourceType_Series), // 2
233 index.CreateResource("d", ResourceType_Instance), // 3
234 index.CreateResource("e", ResourceType_Instance), // 4
235 index.CreateResource("f", ResourceType_Study), // 5
236 index.CreateResource("g", ResourceType_Series), // 6
237 index.CreateResource("h", ResourceType_Series) // 7
238 };
239
240 index.AttachChild(a[0], a[1]);
241 index.AttachChild(a[1], a[2]);
242 index.AttachChild(a[2], a[3]);
243 index.AttachChild(a[2], a[4]);
244 index.AttachChild(a[1], a[6]);
245 index.AttachChild(a[0], a[5]);
246 index.AttachChild(a[5], a[7]);
247
248 {
249 Json::Value j;
250 index.GetChildren(j, a[0]);
251 ASSERT_EQ(2u, j.size());
252 ASSERT_TRUE((j[0u] == "b" && j[1u] == "f") ||
253 (j[1u] == "b" && j[0u] == "f"));
254
255 index.GetChildren(j, a[1]);
256 ASSERT_EQ(2u, j.size());
257 ASSERT_TRUE((j[0u] == "c" && j[1u] == "g") ||
258 (j[1u] == "c" && j[0u] == "g"));
259
260 index.GetChildren(j, a[2]);
261 ASSERT_EQ(2u, j.size());
262 ASSERT_TRUE((j[0u] == "d" && j[1u] == "e") ||
263 (j[1u] == "d" && j[0u] == "e"));
264
265 index.GetChildren(j, a[3]); ASSERT_EQ(0u, j.size());
266 index.GetChildren(j, a[4]); ASSERT_EQ(0u, j.size());
267 index.GetChildren(j, a[5]); ASSERT_EQ(1u, j.size()); ASSERT_EQ("h", j[0u].asString());
268 index.GetChildren(j, a[6]); ASSERT_EQ(0u, j.size());
269 index.GetChildren(j, a[7]); ASSERT_EQ(0u, j.size());
270 }
271
272 listener.Reset();
273 index.DeleteResource(a[3]);
274 ASSERT_EQ("c", listener.ancestorId_);
275 ASSERT_EQ(ResourceType_Series, listener.ancestorType_);
276
277 listener.Reset();
278 index.DeleteResource(a[4]);
279 ASSERT_EQ("b", listener.ancestorId_);
280 ASSERT_EQ(ResourceType_Study, listener.ancestorType_);
281
282 listener.Reset();
283 index.DeleteResource(a[7]);
284 ASSERT_EQ("a", listener.ancestorId_);
285 ASSERT_EQ(ResourceType_Patient, listener.ancestorType_);
286
287 listener.Reset();
288 index.DeleteResource(a[6]);
289 ASSERT_EQ("", listener.ancestorId_); // No more ancestor
290 }
291
292
293 TEST(DatabaseWrapper, PatientRecycling)
294 {
295 ServerIndexListener listener;
296 DatabaseWrapper index(listener);
297
298 std::vector<int64_t> patients;
299 for (int i = 0; i < 10; i++)
300 {
301 std::string p = "Patient " + boost::lexical_cast<std::string>(i);
302 patients.push_back(index.CreateResource(p, ResourceType_Patient));
303 index.AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10));
304 ASSERT_FALSE(index.IsProtectedPatient(patients[i]));
305 }
306
307 ASSERT_EQ(10u, index.GetTableRecordCount("Resources"));
308 ASSERT_EQ(10u, index.GetTableRecordCount("PatientRecyclingOrder"));
309
310 listener.Reset();
311
312 index.DeleteResource(patients[5]);
313 index.DeleteResource(patients[0]);
314 ASSERT_EQ(8u, index.GetTableRecordCount("Resources"));
315 ASSERT_EQ(8u, index.GetTableRecordCount("PatientRecyclingOrder"));
316
317 ASSERT_EQ(2u, listener.deletedFiles_.size());
318 ASSERT_EQ("Patient 5", listener.deletedFiles_[0]);
319 ASSERT_EQ("Patient 0", listener.deletedFiles_[1]);
320
321 int64_t p;
322 ASSERT_TRUE(index.SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[1]);
323 index.DeleteResource(p);
324 ASSERT_TRUE(index.SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[2]);
325 index.DeleteResource(p);
326 ASSERT_TRUE(index.SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[3]);
327 index.DeleteResource(p);
328 ASSERT_TRUE(index.SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[4]);
329 index.DeleteResource(p);
330 ASSERT_TRUE(index.SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[6]);
331 index.DeleteResource(p);
332 index.DeleteResource(patients[8]);
333 ASSERT_TRUE(index.SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[7]);
334 index.DeleteResource(p);
335 ASSERT_TRUE(index.SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[9]);
336 index.DeleteResource(p);
337 ASSERT_FALSE(index.SelectPatientToRecycle(p));
338
339 ASSERT_EQ(10u, listener.deletedFiles_.size());
340 ASSERT_EQ(0u, index.GetTableRecordCount("Resources"));
341 ASSERT_EQ(0u, index.GetTableRecordCount("PatientRecyclingOrder"));
342 }
343
344
345 TEST(DatabaseWrapper, PatientProtection)
346 {
347 ServerIndexListener listener;
348 DatabaseWrapper index(listener);
349
350 std::vector<int64_t> patients;
351 for (int i = 0; i < 5; i++)
352 {
353 std::string p = "Patient " + boost::lexical_cast<std::string>(i);
354 patients.push_back(index.CreateResource(p, ResourceType_Patient));
355 index.AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10));
356 ASSERT_FALSE(index.IsProtectedPatient(patients[i]));
357 }
358
359 ASSERT_EQ(5u, index.GetTableRecordCount("Resources"));
360 ASSERT_EQ(5u, index.GetTableRecordCount("PatientRecyclingOrder"));
361
362 ASSERT_FALSE(index.IsProtectedPatient(patients[2]));
363 index.SetProtectedPatient(patients[2], true);
364 ASSERT_TRUE(index.IsProtectedPatient(patients[2]));
365 ASSERT_EQ(4u, index.GetTableRecordCount("PatientRecyclingOrder"));
366 ASSERT_EQ(5u, index.GetTableRecordCount("Resources"));
367
368 index.SetProtectedPatient(patients[2], true);
369 ASSERT_TRUE(index.IsProtectedPatient(patients[2]));
370 ASSERT_EQ(4u, index.GetTableRecordCount("PatientRecyclingOrder"));
371 index.SetProtectedPatient(patients[2], false);
372 ASSERT_FALSE(index.IsProtectedPatient(patients[2]));
373 ASSERT_EQ(5u, index.GetTableRecordCount("PatientRecyclingOrder"));
374 index.SetProtectedPatient(patients[2], false);
375 ASSERT_FALSE(index.IsProtectedPatient(patients[2]));
376 ASSERT_EQ(5u, index.GetTableRecordCount("PatientRecyclingOrder"));
377
378 ASSERT_EQ(5u, index.GetTableRecordCount("Resources"));
379 ASSERT_EQ(5u, index.GetTableRecordCount("PatientRecyclingOrder"));
380 index.SetProtectedPatient(patients[2], true);
381 ASSERT_TRUE(index.IsProtectedPatient(patients[2]));
382 ASSERT_EQ(4u, index.GetTableRecordCount("PatientRecyclingOrder"));
383 index.SetProtectedPatient(patients[2], false);
384 ASSERT_FALSE(index.IsProtectedPatient(patients[2]));
385 ASSERT_EQ(5u, index.GetTableRecordCount("PatientRecyclingOrder"));
386 index.SetProtectedPatient(patients[3], true);
387 ASSERT_TRUE(index.IsProtectedPatient(patients[3]));
388 ASSERT_EQ(4u, index.GetTableRecordCount("PatientRecyclingOrder"));
389
390 ASSERT_EQ(5u, index.GetTableRecordCount("Resources"));
391 ASSERT_EQ(0u, listener.deletedFiles_.size());
392
393 // Unprotecting a patient puts it at the last position in the recycling queue
394 int64_t p;
395 ASSERT_TRUE(index.SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[0]);
396 index.DeleteResource(p);
397 ASSERT_TRUE(index.SelectPatientToRecycle(p, patients[1])); ASSERT_EQ(p, patients[4]);
398 ASSERT_TRUE(index.SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[1]);
399 index.DeleteResource(p);
400 ASSERT_TRUE(index.SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[4]);
401 index.DeleteResource(p);
402 ASSERT_FALSE(index.SelectPatientToRecycle(p, patients[2]));
403 ASSERT_TRUE(index.SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[2]);
404 index.DeleteResource(p);
405 // "patients[3]" is still protected
406 ASSERT_FALSE(index.SelectPatientToRecycle(p));
407
408 ASSERT_EQ(4u, listener.deletedFiles_.size());
409 ASSERT_EQ(1u, index.GetTableRecordCount("Resources"));
410 ASSERT_EQ(0u, index.GetTableRecordCount("PatientRecyclingOrder"));
411
412 index.SetProtectedPatient(patients[3], false);
413 ASSERT_EQ(1u, index.GetTableRecordCount("PatientRecyclingOrder"));
414 ASSERT_FALSE(index.SelectPatientToRecycle(p, patients[3]));
415 ASSERT_TRUE(index.SelectPatientToRecycle(p, patients[2]));
416 ASSERT_TRUE(index.SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[3]);
417 index.DeleteResource(p);
418
419 ASSERT_EQ(5u, listener.deletedFiles_.size());
420 ASSERT_EQ(0u, index.GetTableRecordCount("Resources"));
421 ASSERT_EQ(0u, index.GetTableRecordCount("PatientRecyclingOrder"));
422 }
423
424
425
426 TEST(DatabaseWrapper, Sequence)
427 {
428 ServerIndexListener listener;
429 DatabaseWrapper index(listener);
430
431 ASSERT_EQ(1u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence));
432 ASSERT_EQ(2u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence));
433 ASSERT_EQ(3u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence));
434 ASSERT_EQ(4u, index.IncrementGlobalSequence(GlobalProperty_AnonymizationSequence));
435 }
436
437
438
439 TEST(DatabaseWrapper, LookupTagValue)
440 {
441 ServerIndexListener listener;
442 DatabaseWrapper index(listener);
443
444 int64_t a[] = {
445 index.CreateResource("a", ResourceType_Study), // 0
446 index.CreateResource("b", ResourceType_Study), // 1
447 index.CreateResource("c", ResourceType_Study), // 2
448 index.CreateResource("d", ResourceType_Series) // 3
449 };
450
451 DicomMap m;
452 m.Clear(); m.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, "0"); index.SetMainDicomTags(a[0], m);
453 m.Clear(); m.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, "1"); index.SetMainDicomTags(a[1], m);
454 m.Clear(); m.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, "0"); index.SetMainDicomTags(a[2], m);
455 m.Clear(); m.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, "0"); index.SetMainDicomTags(a[3], m);
456
457 std::list<int64_t> s;
458
459 index.LookupTagValue(s, DICOM_TAG_STUDY_INSTANCE_UID, "0");
460 ASSERT_EQ(2u, s.size());
461 ASSERT_TRUE(std::find(s.begin(), s.end(), a[0]) != s.end());
462 ASSERT_TRUE(std::find(s.begin(), s.end(), a[2]) != s.end());
463
464 index.LookupTagValue(s, "0");
465 ASSERT_EQ(3u, s.size());
466 ASSERT_TRUE(std::find(s.begin(), s.end(), a[0]) != s.end());
467 ASSERT_TRUE(std::find(s.begin(), s.end(), a[2]) != s.end());
468 ASSERT_TRUE(std::find(s.begin(), s.end(), a[3]) != s.end());
469
470 index.LookupTagValue(s, DICOM_TAG_STUDY_INSTANCE_UID, "1");
471 ASSERT_EQ(1u, s.size());
472 ASSERT_TRUE(std::find(s.begin(), s.end(), a[1]) != s.end());
473
474 index.LookupTagValue(s, "1");
475 ASSERT_EQ(1u, s.size());
476 ASSERT_TRUE(std::find(s.begin(), s.end(), a[1]) != s.end());
477
478
479 /*{
480 std::list<std::string> s;
481 context.GetIndex().LookupTagValue(s, DICOM_TAG_STUDY_INSTANCE_UID, "1.2.250.1.74.20130819132500.29000036381059");
482 for (std::list<std::string>::iterator i = s.begin(); i != s.end(); i++)
483 {
484 std::cout << "*** " << *i << std::endl;;
485 }
486 }*/
487
488
489 }
490
491
492 TEST(DicomMap, MainTags)
493 {
494 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID));
495 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID, ResourceType_Patient));
496 ASSERT_FALSE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID, ResourceType_Study));
497 }