comparison UnitTestsSources/ServerIndexTests.cpp @ 1286:b4acdb37e43b

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 03 Feb 2015 16:51:19 +0100
parents ee43f0d611a8
children 63a6428771f4
comparison
equal deleted inserted replaced
1285:5730f374e4e6 1286:b4acdb37e43b
117 virtual void TearDown() 117 virtual void TearDown()
118 { 118 {
119 index_.reset(NULL); 119 index_.reset(NULL);
120 listener_.reset(NULL); 120 listener_.reset(NULL);
121 } 121 }
122
123 void CheckTableRecordCount(uint32_t expected, const char* table)
124 {
125 if (GetParam() == DatabaseWrapperClass_SQLite)
126 {
127 DatabaseWrapper* sqlite = dynamic_cast<DatabaseWrapper*>(index_.get());
128 ASSERT_EQ(expected, sqlite->GetTableRecordCount(table));
129 }
130 }
131
122 }; 132 };
123 } 133 }
124 134
125 135
126 INSTANTIATE_TEST_CASE_P(DatabaseWrapperName, 136 INSTANTIATE_TEST_CASE_P(DatabaseWrapperName,
128 ::testing::Values(DatabaseWrapperClass_SQLite)); 138 ::testing::Values(DatabaseWrapperClass_SQLite));
129 139
130 140
131 TEST_P(DatabaseWrapperTest, Simple) 141 TEST_P(DatabaseWrapperTest, Simple)
132 { 142 {
143 DatabaseWrapper* sqlite_ = NULL;
144 if (GetParam() == DatabaseWrapperClass_SQLite)
145 {
146 sqlite_ = dynamic_cast<DatabaseWrapper*>(index_.get());
147 }
148
133 int64_t a[] = { 149 int64_t a[] = {
134 index_->CreateResource("a", ResourceType_Patient), // 0 150 index_->CreateResource("a", ResourceType_Patient), // 0
135 index_->CreateResource("b", ResourceType_Study), // 1 151 index_->CreateResource("b", ResourceType_Study), // 1
136 index_->CreateResource("c", ResourceType_Series), // 2 152 index_->CreateResource("c", ResourceType_Series), // 2
137 index_->CreateResource("d", ResourceType_Instance), // 3 153 index_->CreateResource("d", ResourceType_Instance), // 3
190 ASSERT_TRUE(index_->LookupParent(parent, a[4])); ASSERT_EQ(a[2], parent); 206 ASSERT_TRUE(index_->LookupParent(parent, a[4])); ASSERT_EQ(a[2], parent);
191 ASSERT_TRUE(index_->LookupParent(parent, a[5])); ASSERT_EQ(a[6], parent); 207 ASSERT_TRUE(index_->LookupParent(parent, a[5])); ASSERT_EQ(a[6], parent);
192 ASSERT_FALSE(index_->LookupParent(parent, a[6])); 208 ASSERT_FALSE(index_->LookupParent(parent, a[6]));
193 209
194 std::string s; 210 std::string s;
195 211
196 ASSERT_FALSE(index_->GetParentPublicId(s, a[0])); 212 if (sqlite_ != NULL)
197 ASSERT_FALSE(index_->GetParentPublicId(s, a[6])); 213 {
198 ASSERT_TRUE(index_->GetParentPublicId(s, a[1])); ASSERT_EQ("a", s); 214 ASSERT_FALSE(sqlite_->GetParentPublicId(s, a[0]));
199 ASSERT_TRUE(index_->GetParentPublicId(s, a[2])); ASSERT_EQ("b", s); 215 ASSERT_FALSE(sqlite_->GetParentPublicId(s, a[6]));
200 ASSERT_TRUE(index_->GetParentPublicId(s, a[3])); ASSERT_EQ("c", s); 216 ASSERT_TRUE(sqlite_->GetParentPublicId(s, a[1])); ASSERT_EQ("a", s);
201 ASSERT_TRUE(index_->GetParentPublicId(s, a[4])); ASSERT_EQ("c", s); 217 ASSERT_TRUE(sqlite_->GetParentPublicId(s, a[2])); ASSERT_EQ("b", s);
202 ASSERT_TRUE(index_->GetParentPublicId(s, a[5])); ASSERT_EQ("g", s); 218 ASSERT_TRUE(sqlite_->GetParentPublicId(s, a[3])); ASSERT_EQ("c", s);
219 ASSERT_TRUE(sqlite_->GetParentPublicId(s, a[4])); ASSERT_EQ("c", s);
220 ASSERT_TRUE(sqlite_->GetParentPublicId(s, a[5])); ASSERT_EQ("g", s);
221 }
203 222
204 std::list<std::string> l; 223 std::list<std::string> l;
205 index_->GetChildrenPublicId(l, a[0]); ASSERT_EQ(1u, l.size()); ASSERT_EQ("b", l.front()); 224 index_->GetChildrenPublicId(l, a[0]); ASSERT_EQ(1u, l.size()); ASSERT_EQ("b", l.front());
206 index_->GetChildrenPublicId(l, a[1]); ASSERT_EQ(1u, l.size()); ASSERT_EQ("c", l.front()); 225 index_->GetChildrenPublicId(l, a[1]); ASSERT_EQ(1u, l.size()); ASSERT_EQ("c", l.front());
207 index_->GetChildrenPublicId(l, a[3]); ASSERT_EQ(0u, l.size()); 226 index_->GetChildrenPublicId(l, a[3]); ASSERT_EQ(0u, l.size());
254 273
255 274
256 ASSERT_EQ(21u + 42u + 44u, index_->GetTotalCompressedSize()); 275 ASSERT_EQ(21u + 42u + 44u, index_->GetTotalCompressedSize());
257 ASSERT_EQ(42u + 42u + 44u, index_->GetTotalUncompressedSize()); 276 ASSERT_EQ(42u + 42u + 44u, index_->GetTotalUncompressedSize());
258 277
259 DicomMap m; 278 index_->SetMainDicomTag(a[3], DicomTag(0x0010, 0x0010), "PatientName");
260 m.SetValue(0x0010, 0x0010, "PatientName");
261 index_->SetMainDicomTags(a[3], m);
262 279
263 int64_t b; 280 int64_t b;
264 ResourceType t; 281 ResourceType t;
265 ASSERT_TRUE(index_->LookupResource("g", b, t)); 282 ASSERT_TRUE(index_->LookupResource("g", b, t));
266 ASSERT_EQ(7, b); 283 ASSERT_EQ(7, b);
296 ASSERT_EQ(44u, att.GetUncompressedSize()); 313 ASSERT_EQ(44u, att.GetUncompressedSize());
297 ASSERT_EQ(CompressionType_None, att.GetCompressionType()); 314 ASSERT_EQ(CompressionType_None, att.GetCompressionType());
298 315
299 ASSERT_EQ(0u, listener_->deletedFiles_.size()); 316 ASSERT_EQ(0u, listener_->deletedFiles_.size());
300 ASSERT_EQ(0u, listener_->deletedResources_.size()); 317 ASSERT_EQ(0u, listener_->deletedResources_.size());
301 ASSERT_EQ(7u, index_->GetTableRecordCount("Resources")); 318
302 ASSERT_EQ(3u, index_->GetTableRecordCount("AttachedFiles")); 319 CheckTableRecordCount(7, "Resources");
303 ASSERT_EQ(1u, index_->GetTableRecordCount("Metadata")); 320 CheckTableRecordCount(3, "AttachedFiles");
304 ASSERT_EQ(1u, index_->GetTableRecordCount("MainDicomTags")); 321 CheckTableRecordCount(1, "Metadata");
322 CheckTableRecordCount(1, "MainDicomTags");
305 323
306 index_->DeleteResource(a[0]); 324 index_->DeleteResource(a[0]);
307 ASSERT_EQ(5u, listener_->deletedResources_.size()); 325 ASSERT_EQ(5u, listener_->deletedResources_.size());
308 ASSERT_EQ(2u, listener_->deletedFiles_.size()); 326 ASSERT_EQ(2u, listener_->deletedFiles_.size());
309 ASSERT_FALSE(std::find(listener_->deletedFiles_.begin(), 327 ASSERT_FALSE(std::find(listener_->deletedFiles_.begin(),
311 "my json file") == listener_->deletedFiles_.end()); 329 "my json file") == listener_->deletedFiles_.end());
312 ASSERT_FALSE(std::find(listener_->deletedFiles_.begin(), 330 ASSERT_FALSE(std::find(listener_->deletedFiles_.begin(),
313 listener_->deletedFiles_.end(), 331 listener_->deletedFiles_.end(),
314 "my dicom file") == listener_->deletedFiles_.end()); 332 "my dicom file") == listener_->deletedFiles_.end());
315 333
316 ASSERT_EQ(2u, index_->GetTableRecordCount("Resources")); 334 CheckTableRecordCount(2, "Resources");
317 ASSERT_EQ(0u, index_->GetTableRecordCount("Metadata")); 335 CheckTableRecordCount(0, "Metadata");
318 ASSERT_EQ(1u, index_->GetTableRecordCount("AttachedFiles")); 336 CheckTableRecordCount(1, "AttachedFiles");
319 ASSERT_EQ(0u, index_->GetTableRecordCount("MainDicomTags")); 337 CheckTableRecordCount(0, "MainDicomTags");
338
320 index_->DeleteResource(a[5]); 339 index_->DeleteResource(a[5]);
321 ASSERT_EQ(7u, listener_->deletedResources_.size()); 340 ASSERT_EQ(7u, listener_->deletedResources_.size());
322 ASSERT_EQ(0u, index_->GetTableRecordCount("Resources")); 341
323 ASSERT_EQ(0u, index_->GetTableRecordCount("AttachedFiles")); 342 CheckTableRecordCount(0, "Resources");
324 ASSERT_EQ(2u, index_->GetTableRecordCount("GlobalProperties")); 343 CheckTableRecordCount(0, "AttachedFiles");
344 CheckTableRecordCount(2, "GlobalProperties");
325 345
326 ASSERT_EQ(3u, listener_->deletedFiles_.size()); 346 ASSERT_EQ(3u, listener_->deletedFiles_.size());
327 ASSERT_FALSE(std::find(listener_->deletedFiles_.begin(), 347 ASSERT_FALSE(std::find(listener_->deletedFiles_.begin(),
328 listener_->deletedFiles_.end(), 348 listener_->deletedFiles_.end(),
329 "world") == listener_->deletedFiles_.end()); 349 "world") == listener_->deletedFiles_.end());
332 352
333 353
334 354
335 TEST_P(DatabaseWrapperTest, Upward) 355 TEST_P(DatabaseWrapperTest, Upward)
336 { 356 {
357 DatabaseWrapper* sqlite_ = NULL;
358 if (GetParam() == DatabaseWrapperClass_SQLite)
359 {
360 sqlite_ = dynamic_cast<DatabaseWrapper*>(index_.get());
361 }
362
337 int64_t a[] = { 363 int64_t a[] = {
338 index_->CreateResource("a", ResourceType_Patient), // 0 364 index_->CreateResource("a", ResourceType_Patient), // 0
339 index_->CreateResource("b", ResourceType_Study), // 1 365 index_->CreateResource("b", ResourceType_Study), // 1
340 index_->CreateResource("c", ResourceType_Series), // 2 366 index_->CreateResource("c", ResourceType_Series), // 2
341 index_->CreateResource("d", ResourceType_Instance), // 3 367 index_->CreateResource("d", ResourceType_Instance), // 3
351 index_->AttachChild(a[2], a[4]); 377 index_->AttachChild(a[2], a[4]);
352 index_->AttachChild(a[1], a[6]); 378 index_->AttachChild(a[1], a[6]);
353 index_->AttachChild(a[0], a[5]); 379 index_->AttachChild(a[0], a[5]);
354 index_->AttachChild(a[5], a[7]); 380 index_->AttachChild(a[5], a[7]);
355 381
382 if (sqlite_ != NULL)
356 { 383 {
357 std::list<std::string> j; 384 std::list<std::string> j;
358 index_->GetChildren(j, a[0]); 385 sqlite_->GetChildren(j, a[0]);
359 ASSERT_EQ(2u, j.size()); 386 ASSERT_EQ(2u, j.size());
360 ASSERT_TRUE((j.front() == "b" && j.back() == "f") || 387 ASSERT_TRUE((j.front() == "b" && j.back() == "f") ||
361 (j.back() == "b" && j.front() == "f")); 388 (j.back() == "b" && j.front() == "f"));
362 389
363 index_->GetChildren(j, a[1]); 390 sqlite_->GetChildren(j, a[1]);
364 ASSERT_EQ(2u, j.size()); 391 ASSERT_EQ(2u, j.size());
365 ASSERT_TRUE((j.front() == "c" && j.back() == "g") || 392 ASSERT_TRUE((j.front() == "c" && j.back() == "g") ||
366 (j.back() == "c" && j.front() == "g")); 393 (j.back() == "c" && j.front() == "g"));
367 394
368 index_->GetChildren(j, a[2]); 395 sqlite_->GetChildren(j, a[2]);
369 ASSERT_EQ(2u, j.size()); 396 ASSERT_EQ(2u, j.size());
370 ASSERT_TRUE((j.front() == "d" && j.back() == "e") || 397 ASSERT_TRUE((j.front() == "d" && j.back() == "e") ||
371 (j.back() == "d" && j.front() == "e")); 398 (j.back() == "d" && j.front() == "e"));
372 399
373 index_->GetChildren(j, a[3]); ASSERT_EQ(0u, j.size()); 400 sqlite_->GetChildren(j, a[3]); ASSERT_EQ(0u, j.size());
374 index_->GetChildren(j, a[4]); ASSERT_EQ(0u, j.size()); 401 sqlite_->GetChildren(j, a[4]); ASSERT_EQ(0u, j.size());
375 index_->GetChildren(j, a[5]); ASSERT_EQ(1u, j.size()); ASSERT_EQ("h", j.front()); 402 sqlite_->GetChildren(j, a[5]); ASSERT_EQ(1u, j.size()); ASSERT_EQ("h", j.front());
376 index_->GetChildren(j, a[6]); ASSERT_EQ(0u, j.size()); 403 sqlite_->GetChildren(j, a[6]); ASSERT_EQ(0u, j.size());
377 index_->GetChildren(j, a[7]); ASSERT_EQ(0u, j.size()); 404 sqlite_->GetChildren(j, a[7]); ASSERT_EQ(0u, j.size());
378 } 405 }
379 406
380 listener_->Reset(); 407 listener_->Reset();
381 index_->DeleteResource(a[3]); 408 index_->DeleteResource(a[3]);
382 ASSERT_EQ("c", listener_->ancestorId_); 409 ASSERT_EQ("c", listener_->ancestorId_);
408 index_->AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10, 435 index_->AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10,
409 "md5-" + boost::lexical_cast<std::string>(i))); 436 "md5-" + boost::lexical_cast<std::string>(i)));
410 ASSERT_FALSE(index_->IsProtectedPatient(patients[i])); 437 ASSERT_FALSE(index_->IsProtectedPatient(patients[i]));
411 } 438 }
412 439
413 ASSERT_EQ(10u, index_->GetTableRecordCount("Resources")); 440 CheckTableRecordCount(10u, "Resources");
414 ASSERT_EQ(10u, index_->GetTableRecordCount("PatientRecyclingOrder")); 441 CheckTableRecordCount(10u, "PatientRecyclingOrder");
415 442
416 listener_->Reset(); 443 listener_->Reset();
417 ASSERT_EQ(0u, listener_->deletedResources_.size()); 444 ASSERT_EQ(0u, listener_->deletedResources_.size());
418 445
419 index_->DeleteResource(patients[5]); 446 index_->DeleteResource(patients[5]);
420 index_->DeleteResource(patients[0]); 447 index_->DeleteResource(patients[0]);
421 ASSERT_EQ(2u, listener_->deletedResources_.size()); 448 ASSERT_EQ(2u, listener_->deletedResources_.size());
422 ASSERT_EQ(8u, index_->GetTableRecordCount("Resources")); 449
423 ASSERT_EQ(8u, index_->GetTableRecordCount("PatientRecyclingOrder")); 450 CheckTableRecordCount(8u, "Resources");
451 CheckTableRecordCount(8u, "PatientRecyclingOrder");
424 452
425 ASSERT_EQ(2u, listener_->deletedFiles_.size()); 453 ASSERT_EQ(2u, listener_->deletedFiles_.size());
426 ASSERT_EQ("Patient 5", listener_->deletedFiles_[0]); 454 ASSERT_EQ("Patient 5", listener_->deletedFiles_[0]);
427 ASSERT_EQ("Patient 0", listener_->deletedFiles_[1]); 455 ASSERT_EQ("Patient 0", listener_->deletedFiles_[1]);
428 456
450 index_->DeleteResource(p); 478 index_->DeleteResource(p);
451 ASSERT_FALSE(index_->SelectPatientToRecycle(p)); 479 ASSERT_FALSE(index_->SelectPatientToRecycle(p));
452 ASSERT_EQ(10u, listener_->deletedResources_.size()); 480 ASSERT_EQ(10u, listener_->deletedResources_.size());
453 481
454 ASSERT_EQ(10u, listener_->deletedFiles_.size()); 482 ASSERT_EQ(10u, listener_->deletedFiles_.size());
455 ASSERT_EQ(0u, index_->GetTableRecordCount("Resources")); 483
456 ASSERT_EQ(0u, index_->GetTableRecordCount("PatientRecyclingOrder")); 484 CheckTableRecordCount(0, "Resources");
485 CheckTableRecordCount(0, "PatientRecyclingOrder");
457 } 486 }
458 487
459 488
460 TEST_P(DatabaseWrapperTest, PatientProtection) 489 TEST_P(DatabaseWrapperTest, PatientProtection)
461 { 490 {
467 index_->AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10, 496 index_->AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10,
468 "md5-" + boost::lexical_cast<std::string>(i))); 497 "md5-" + boost::lexical_cast<std::string>(i)));
469 ASSERT_FALSE(index_->IsProtectedPatient(patients[i])); 498 ASSERT_FALSE(index_->IsProtectedPatient(patients[i]));
470 } 499 }
471 500
472 ASSERT_EQ(5u, index_->GetTableRecordCount("Resources")); 501 CheckTableRecordCount(5, "Resources");
473 ASSERT_EQ(5u, index_->GetTableRecordCount("PatientRecyclingOrder")); 502 CheckTableRecordCount(5, "PatientRecyclingOrder");
474 503
475 ASSERT_FALSE(index_->IsProtectedPatient(patients[2])); 504 ASSERT_FALSE(index_->IsProtectedPatient(patients[2]));
476 index_->SetProtectedPatient(patients[2], true); 505 index_->SetProtectedPatient(patients[2], true);
477 ASSERT_TRUE(index_->IsProtectedPatient(patients[2])); 506 ASSERT_TRUE(index_->IsProtectedPatient(patients[2]));
478 ASSERT_EQ(4u, index_->GetTableRecordCount("PatientRecyclingOrder")); 507 CheckTableRecordCount(5, "Resources");
479 ASSERT_EQ(5u, index_->GetTableRecordCount("Resources")); 508 CheckTableRecordCount(4, "PatientRecyclingOrder");
480 509
481 index_->SetProtectedPatient(patients[2], true); 510 index_->SetProtectedPatient(patients[2], true);
482 ASSERT_TRUE(index_->IsProtectedPatient(patients[2])); 511 ASSERT_TRUE(index_->IsProtectedPatient(patients[2]));
483 ASSERT_EQ(4u, index_->GetTableRecordCount("PatientRecyclingOrder")); 512 CheckTableRecordCount(4, "PatientRecyclingOrder");
484 index_->SetProtectedPatient(patients[2], false); 513 index_->SetProtectedPatient(patients[2], false);
485 ASSERT_FALSE(index_->IsProtectedPatient(patients[2])); 514 ASSERT_FALSE(index_->IsProtectedPatient(patients[2]));
486 ASSERT_EQ(5u, index_->GetTableRecordCount("PatientRecyclingOrder")); 515 CheckTableRecordCount(5, "PatientRecyclingOrder");
487 index_->SetProtectedPatient(patients[2], false); 516 index_->SetProtectedPatient(patients[2], false);
488 ASSERT_FALSE(index_->IsProtectedPatient(patients[2])); 517 ASSERT_FALSE(index_->IsProtectedPatient(patients[2]));
489 ASSERT_EQ(5u, index_->GetTableRecordCount("PatientRecyclingOrder")); 518 CheckTableRecordCount(5, "PatientRecyclingOrder");
490 519 CheckTableRecordCount(5, "Resources");
491 ASSERT_EQ(5u, index_->GetTableRecordCount("Resources"));
492 ASSERT_EQ(5u, index_->GetTableRecordCount("PatientRecyclingOrder"));
493 index_->SetProtectedPatient(patients[2], true); 520 index_->SetProtectedPatient(patients[2], true);
494 ASSERT_TRUE(index_->IsProtectedPatient(patients[2])); 521 ASSERT_TRUE(index_->IsProtectedPatient(patients[2]));
495 ASSERT_EQ(4u, index_->GetTableRecordCount("PatientRecyclingOrder")); 522 CheckTableRecordCount(4, "PatientRecyclingOrder");
496 index_->SetProtectedPatient(patients[2], false); 523 index_->SetProtectedPatient(patients[2], false);
497 ASSERT_FALSE(index_->IsProtectedPatient(patients[2])); 524 ASSERT_FALSE(index_->IsProtectedPatient(patients[2]));
498 ASSERT_EQ(5u, index_->GetTableRecordCount("PatientRecyclingOrder")); 525 CheckTableRecordCount(5, "PatientRecyclingOrder");
499 index_->SetProtectedPatient(patients[3], true); 526 index_->SetProtectedPatient(patients[3], true);
500 ASSERT_TRUE(index_->IsProtectedPatient(patients[3])); 527 ASSERT_TRUE(index_->IsProtectedPatient(patients[3]));
501 ASSERT_EQ(4u, index_->GetTableRecordCount("PatientRecyclingOrder")); 528 CheckTableRecordCount(4, "PatientRecyclingOrder");
502 529
503 ASSERT_EQ(5u, index_->GetTableRecordCount("Resources")); 530 CheckTableRecordCount(5, "Resources");
504 ASSERT_EQ(0u, listener_->deletedFiles_.size()); 531 ASSERT_EQ(0u, listener_->deletedFiles_.size());
505 532
506 // Unprotecting a patient puts it at the last position in the recycling queue 533 // Unprotecting a patient puts it at the last position in the recycling queue
507 int64_t p; 534 int64_t p;
508 ASSERT_EQ(0u, listener_->deletedResources_.size()); 535 ASSERT_EQ(0u, listener_->deletedResources_.size());
522 ASSERT_EQ(4u, listener_->deletedResources_.size()); 549 ASSERT_EQ(4u, listener_->deletedResources_.size());
523 // "patients[3]" is still protected 550 // "patients[3]" is still protected
524 ASSERT_FALSE(index_->SelectPatientToRecycle(p)); 551 ASSERT_FALSE(index_->SelectPatientToRecycle(p));
525 552
526 ASSERT_EQ(4u, listener_->deletedFiles_.size()); 553 ASSERT_EQ(4u, listener_->deletedFiles_.size());
527 ASSERT_EQ(1u, index_->GetTableRecordCount("Resources")); 554 CheckTableRecordCount(1, "Resources");
528 ASSERT_EQ(0u, index_->GetTableRecordCount("PatientRecyclingOrder")); 555 CheckTableRecordCount(0, "PatientRecyclingOrder");
529 556
530 index_->SetProtectedPatient(patients[3], false); 557 index_->SetProtectedPatient(patients[3], false);
531 ASSERT_EQ(1u, index_->GetTableRecordCount("PatientRecyclingOrder")); 558 CheckTableRecordCount(1, "PatientRecyclingOrder");
532 ASSERT_FALSE(index_->SelectPatientToRecycle(p, patients[3])); 559 ASSERT_FALSE(index_->SelectPatientToRecycle(p, patients[3]));
533 ASSERT_TRUE(index_->SelectPatientToRecycle(p, patients[2])); 560 ASSERT_TRUE(index_->SelectPatientToRecycle(p, patients[2]));
534 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[3]); 561 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[3]);
535 index_->DeleteResource(p); 562 index_->DeleteResource(p);
536 ASSERT_EQ(5u, listener_->deletedResources_.size()); 563 ASSERT_EQ(5u, listener_->deletedResources_.size());
537 564
538 ASSERT_EQ(5u, listener_->deletedFiles_.size()); 565 ASSERT_EQ(5u, listener_->deletedFiles_.size());
539 ASSERT_EQ(0u, index_->GetTableRecordCount("Resources")); 566 CheckTableRecordCount(0, "Resources");
540 ASSERT_EQ(0u, index_->GetTableRecordCount("PatientRecyclingOrder")); 567 CheckTableRecordCount(0, "PatientRecyclingOrder");
541 } 568 }
542 569
543 570
544 571
545 TEST(ServerIndex, Sequence) 572 TEST(ServerIndex, Sequence)
568 index_->CreateResource("b", ResourceType_Study), // 1 595 index_->CreateResource("b", ResourceType_Study), // 1
569 index_->CreateResource("c", ResourceType_Study), // 2 596 index_->CreateResource("c", ResourceType_Study), // 2
570 index_->CreateResource("d", ResourceType_Series) // 3 597 index_->CreateResource("d", ResourceType_Series) // 3
571 }; 598 };
572 599
573 DicomMap m; 600 index_->SetMainDicomTag(a[0], DICOM_TAG_STUDY_INSTANCE_UID, "0");
574 m.Clear(); m.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, "0"); index_->SetMainDicomTags(a[0], m); 601 index_->SetMainDicomTag(a[1], DICOM_TAG_STUDY_INSTANCE_UID, "1");
575 m.Clear(); m.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, "1"); index_->SetMainDicomTags(a[1], m); 602 index_->SetMainDicomTag(a[2], DICOM_TAG_STUDY_INSTANCE_UID, "0");
576 m.Clear(); m.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, "0"); index_->SetMainDicomTags(a[2], m); 603 index_->SetMainDicomTag(a[3], DICOM_TAG_SERIES_INSTANCE_UID, "0");
577 m.Clear(); m.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, "0"); index_->SetMainDicomTags(a[3], m);
578 604
579 std::list<int64_t> s; 605 std::list<int64_t> s;
580 606
581 index_->LookupIdentifier(s, DICOM_TAG_STUDY_INSTANCE_UID, "0"); 607 index_->LookupIdentifier(s, DICOM_TAG_STUDY_INSTANCE_UID, "0");
582 ASSERT_EQ(2u, s.size()); 608 ASSERT_EQ(2u, s.size());