Mercurial > hg > orthanc
comparison UnitTestsSources/ServerIndexTests.cpp @ 3080:1a75595d8e44 db-changes
started refactoring of ServerIndex::Store()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 03 Jan 2019 18:21:22 +0100 |
parents | ead8576a02ef |
children | 2e5970ddcfeb |
comparison
equal
deleted
inserted
replaced
3079:65e2bfa953ef | 3080:1a75595d8e44 |
---|---|
295 | 295 |
296 | 296 |
297 TEST_P(DatabaseWrapperTest, Simple) | 297 TEST_P(DatabaseWrapperTest, Simple) |
298 { | 298 { |
299 int64_t a[] = { | 299 int64_t a[] = { |
300 index_->CreateResource("a", ResourceType_Patient), // 0 | 300 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource("a", ResourceType_Patient), // 0 |
301 index_->CreateResource("b", ResourceType_Study), // 1 | 301 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource("b", ResourceType_Study), // 1 |
302 index_->CreateResource("c", ResourceType_Series), // 2 | 302 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource("c", ResourceType_Series), // 2 |
303 index_->CreateResource("d", ResourceType_Instance), // 3 | 303 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource("d", ResourceType_Instance), // 3 |
304 index_->CreateResource("e", ResourceType_Instance), // 4 | 304 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource("e", ResourceType_Instance), // 4 |
305 index_->CreateResource("f", ResourceType_Instance), // 5 | 305 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource("f", ResourceType_Instance), // 5 |
306 index_->CreateResource("g", ResourceType_Study) // 6 | 306 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource("g", ResourceType_Study) // 6 |
307 }; | 307 }; |
308 | 308 |
309 ASSERT_EQ("a", index_->GetPublicId(a[0])); | 309 ASSERT_EQ("a", dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetPublicId(a[0])); |
310 ASSERT_EQ("b", index_->GetPublicId(a[1])); | 310 ASSERT_EQ("b", dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetPublicId(a[1])); |
311 ASSERT_EQ("c", index_->GetPublicId(a[2])); | 311 ASSERT_EQ("c", dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetPublicId(a[2])); |
312 ASSERT_EQ("d", index_->GetPublicId(a[3])); | 312 ASSERT_EQ("d", dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetPublicId(a[3])); |
313 ASSERT_EQ("e", index_->GetPublicId(a[4])); | 313 ASSERT_EQ("e", dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetPublicId(a[4])); |
314 ASSERT_EQ("f", index_->GetPublicId(a[5])); | 314 ASSERT_EQ("f", dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetPublicId(a[5])); |
315 ASSERT_EQ("g", index_->GetPublicId(a[6])); | 315 ASSERT_EQ("g", dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetPublicId(a[6])); |
316 | 316 |
317 ASSERT_EQ(ResourceType_Patient, index_->GetResourceType(a[0])); | 317 ASSERT_EQ(ResourceType_Patient, dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetResourceType(a[0])); |
318 ASSERT_EQ(ResourceType_Study, index_->GetResourceType(a[1])); | 318 ASSERT_EQ(ResourceType_Study, dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetResourceType(a[1])); |
319 ASSERT_EQ(ResourceType_Series, index_->GetResourceType(a[2])); | 319 ASSERT_EQ(ResourceType_Series, dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetResourceType(a[2])); |
320 ASSERT_EQ(ResourceType_Instance, index_->GetResourceType(a[3])); | 320 ASSERT_EQ(ResourceType_Instance, dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetResourceType(a[3])); |
321 ASSERT_EQ(ResourceType_Instance, index_->GetResourceType(a[4])); | 321 ASSERT_EQ(ResourceType_Instance, dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetResourceType(a[4])); |
322 ASSERT_EQ(ResourceType_Instance, index_->GetResourceType(a[5])); | 322 ASSERT_EQ(ResourceType_Instance, dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetResourceType(a[5])); |
323 ASSERT_EQ(ResourceType_Study, index_->GetResourceType(a[6])); | 323 ASSERT_EQ(ResourceType_Study, dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetResourceType(a[6])); |
324 | 324 |
325 { | 325 { |
326 std::list<std::string> t; | 326 std::list<std::string> t; |
327 index_->GetAllPublicIds(t, ResourceType_Patient); | 327 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetAllPublicIds(t, ResourceType_Patient); |
328 | 328 |
329 ASSERT_EQ(1u, t.size()); | 329 ASSERT_EQ(1u, t.size()); |
330 ASSERT_EQ("a", t.front()); | 330 ASSERT_EQ("a", t.front()); |
331 | 331 |
332 index_->GetAllPublicIds(t, ResourceType_Series); | 332 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetAllPublicIds(t, ResourceType_Series); |
333 ASSERT_EQ(1u, t.size()); | 333 ASSERT_EQ(1u, t.size()); |
334 ASSERT_EQ("c", t.front()); | 334 ASSERT_EQ("c", t.front()); |
335 | 335 |
336 index_->GetAllPublicIds(t, ResourceType_Study); | 336 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetAllPublicIds(t, ResourceType_Study); |
337 ASSERT_EQ(2u, t.size()); | 337 ASSERT_EQ(2u, t.size()); |
338 | 338 |
339 index_->GetAllPublicIds(t, ResourceType_Instance); | 339 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetAllPublicIds(t, ResourceType_Instance); |
340 ASSERT_EQ(3u, t.size()); | 340 ASSERT_EQ(3u, t.size()); |
341 } | 341 } |
342 | 342 |
343 index_->SetGlobalProperty(GlobalProperty_FlushSleep, "World"); | 343 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SetGlobalProperty(GlobalProperty_FlushSleep, "World"); |
344 | 344 |
345 index_->AttachChild(a[0], a[1]); | 345 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).AttachChild(a[0], a[1]); |
346 index_->AttachChild(a[1], a[2]); | 346 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).AttachChild(a[1], a[2]); |
347 index_->AttachChild(a[2], a[3]); | 347 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).AttachChild(a[2], a[3]); |
348 index_->AttachChild(a[2], a[4]); | 348 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).AttachChild(a[2], a[4]); |
349 index_->AttachChild(a[6], a[5]); | 349 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).AttachChild(a[6], a[5]); |
350 | 350 |
351 int64_t parent; | 351 int64_t parent; |
352 ASSERT_FALSE(index_->LookupParent(parent, a[0])); | 352 ASSERT_FALSE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).LookupParent(parent, a[0])); |
353 ASSERT_TRUE(index_->LookupParent(parent, a[1])); ASSERT_EQ(a[0], parent); | 353 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).LookupParent(parent, a[1])); ASSERT_EQ(a[0], parent); |
354 ASSERT_TRUE(index_->LookupParent(parent, a[2])); ASSERT_EQ(a[1], parent); | 354 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).LookupParent(parent, a[2])); ASSERT_EQ(a[1], parent); |
355 ASSERT_TRUE(index_->LookupParent(parent, a[3])); ASSERT_EQ(a[2], parent); | 355 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).LookupParent(parent, a[3])); ASSERT_EQ(a[2], parent); |
356 ASSERT_TRUE(index_->LookupParent(parent, a[4])); ASSERT_EQ(a[2], parent); | 356 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).LookupParent(parent, a[4])); ASSERT_EQ(a[2], parent); |
357 ASSERT_TRUE(index_->LookupParent(parent, a[5])); ASSERT_EQ(a[6], parent); | 357 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).LookupParent(parent, a[5])); ASSERT_EQ(a[6], parent); |
358 ASSERT_FALSE(index_->LookupParent(parent, a[6])); | 358 ASSERT_FALSE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).LookupParent(parent, a[6])); |
359 | 359 |
360 std::string s; | 360 std::string s; |
361 | 361 |
362 CheckNoParent(a[0]); | 362 CheckNoParent(a[0]); |
363 CheckNoParent(a[6]); | 363 CheckNoParent(a[6]); |
366 CheckParentPublicId("c", a[3]); | 366 CheckParentPublicId("c", a[3]); |
367 CheckParentPublicId("c", a[4]); | 367 CheckParentPublicId("c", a[4]); |
368 CheckParentPublicId("g", a[5]); | 368 CheckParentPublicId("g", a[5]); |
369 | 369 |
370 std::list<std::string> l; | 370 std::list<std::string> l; |
371 index_->GetChildrenPublicId(l, a[0]); ASSERT_EQ(1u, l.size()); ASSERT_EQ("b", l.front()); | 371 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetChildrenPublicId(l, a[0]); ASSERT_EQ(1u, l.size()); ASSERT_EQ("b", l.front()); |
372 index_->GetChildrenPublicId(l, a[1]); ASSERT_EQ(1u, l.size()); ASSERT_EQ("c", l.front()); | 372 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetChildrenPublicId(l, a[1]); ASSERT_EQ(1u, l.size()); ASSERT_EQ("c", l.front()); |
373 index_->GetChildrenPublicId(l, a[3]); ASSERT_EQ(0u, l.size()); | 373 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetChildrenPublicId(l, a[3]); ASSERT_EQ(0u, l.size()); |
374 index_->GetChildrenPublicId(l, a[4]); ASSERT_EQ(0u, l.size()); | 374 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetChildrenPublicId(l, a[4]); ASSERT_EQ(0u, l.size()); |
375 index_->GetChildrenPublicId(l, a[5]); ASSERT_EQ(0u, l.size()); | 375 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetChildrenPublicId(l, a[5]); ASSERT_EQ(0u, l.size()); |
376 index_->GetChildrenPublicId(l, a[6]); ASSERT_EQ(1u, l.size()); ASSERT_EQ("f", l.front()); | 376 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetChildrenPublicId(l, a[6]); ASSERT_EQ(1u, l.size()); ASSERT_EQ("f", l.front()); |
377 | 377 |
378 index_->GetChildrenPublicId(l, a[2]); ASSERT_EQ(2u, l.size()); | 378 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetChildrenPublicId(l, a[2]); ASSERT_EQ(2u, l.size()); |
379 if (l.front() == "d") | 379 if (l.front() == "d") |
380 { | 380 { |
381 ASSERT_EQ("e", l.back()); | 381 ASSERT_EQ("e", l.back()); |
382 } | 382 } |
383 else | 383 else |
385 ASSERT_EQ("d", l.back()); | 385 ASSERT_EQ("d", l.back()); |
386 ASSERT_EQ("e", l.front()); | 386 ASSERT_EQ("e", l.front()); |
387 } | 387 } |
388 | 388 |
389 std::list<MetadataType> md; | 389 std::list<MetadataType> md; |
390 index_->ListAvailableMetadata(md, a[4]); | 390 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).ListAvailableMetadata(md, a[4]); |
391 ASSERT_EQ(0u, md.size()); | 391 ASSERT_EQ(0u, md.size()); |
392 | 392 |
393 index_->AddAttachment(a[4], FileInfo("my json file", FileContentType_DicomAsJson, 42, "md5", | 393 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).AddAttachment(a[4], FileInfo("my json file", FileContentType_DicomAsJson, 42, "md5", |
394 CompressionType_ZlibWithSize, 21, "compressedMD5")); | 394 CompressionType_ZlibWithSize, 21, "compressedMD5")); |
395 index_->AddAttachment(a[4], FileInfo("my dicom file", FileContentType_Dicom, 42, "md5")); | 395 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).AddAttachment(a[4], FileInfo("my dicom file", FileContentType_Dicom, 42, "md5")); |
396 index_->AddAttachment(a[6], FileInfo("world", FileContentType_Dicom, 44, "md5")); | 396 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).AddAttachment(a[6], FileInfo("world", FileContentType_Dicom, 44, "md5")); |
397 index_->SetMetadata(a[4], MetadataType_Instance_RemoteAet, "PINNACLE"); | 397 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SetMetadata(a[4], MetadataType_Instance_RemoteAet, "PINNACLE"); |
398 | 398 |
399 index_->ListAvailableMetadata(md, a[4]); | 399 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).ListAvailableMetadata(md, a[4]); |
400 ASSERT_EQ(1u, md.size()); | 400 ASSERT_EQ(1u, md.size()); |
401 ASSERT_EQ(MetadataType_Instance_RemoteAet, md.front()); | 401 ASSERT_EQ(MetadataType_Instance_RemoteAet, md.front()); |
402 index_->SetMetadata(a[4], MetadataType_ModifiedFrom, "TUTU"); | 402 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SetMetadata(a[4], MetadataType_ModifiedFrom, "TUTU"); |
403 index_->ListAvailableMetadata(md, a[4]); | 403 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).ListAvailableMetadata(md, a[4]); |
404 ASSERT_EQ(2u, md.size()); | 404 ASSERT_EQ(2u, md.size()); |
405 | 405 |
406 std::map<MetadataType, std::string> md2; | 406 std::map<MetadataType, std::string> md2; |
407 index_->GetAllMetadata(md2, a[4]); | 407 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetAllMetadata(md2, a[4]); |
408 ASSERT_EQ(2u, md2.size()); | 408 ASSERT_EQ(2u, md2.size()); |
409 ASSERT_EQ("TUTU", md2[MetadataType_ModifiedFrom]); | 409 ASSERT_EQ("TUTU", md2[MetadataType_ModifiedFrom]); |
410 ASSERT_EQ("PINNACLE", md2[MetadataType_Instance_RemoteAet]); | 410 ASSERT_EQ("PINNACLE", md2[MetadataType_Instance_RemoteAet]); |
411 | 411 |
412 index_->DeleteMetadata(a[4], MetadataType_ModifiedFrom); | 412 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteMetadata(a[4], MetadataType_ModifiedFrom); |
413 index_->ListAvailableMetadata(md, a[4]); | 413 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).ListAvailableMetadata(md, a[4]); |
414 ASSERT_EQ(1u, md.size()); | 414 ASSERT_EQ(1u, md.size()); |
415 ASSERT_EQ(MetadataType_Instance_RemoteAet, md.front()); | 415 ASSERT_EQ(MetadataType_Instance_RemoteAet, md.front()); |
416 | 416 |
417 index_->GetAllMetadata(md2, a[4]); | 417 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetAllMetadata(md2, a[4]); |
418 ASSERT_EQ(1u, md2.size()); | 418 ASSERT_EQ(1u, md2.size()); |
419 ASSERT_EQ("PINNACLE", md2[MetadataType_Instance_RemoteAet]); | 419 ASSERT_EQ("PINNACLE", md2[MetadataType_Instance_RemoteAet]); |
420 | 420 |
421 | 421 |
422 ASSERT_EQ(21u + 42u + 44u, index_->GetTotalCompressedSize()); | 422 ASSERT_EQ(21u + 42u + 44u, dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetTotalCompressedSize()); |
423 ASSERT_EQ(42u + 42u + 44u, index_->GetTotalUncompressedSize()); | 423 ASSERT_EQ(42u + 42u + 44u, dynamic_cast<SQLiteDatabaseWrapper&>(*index_).GetTotalUncompressedSize()); |
424 | 424 |
425 index_->SetMainDicomTag(a[3], DicomTag(0x0010, 0x0010), "PatientName"); | 425 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SetMainDicomTag(a[3], DicomTag(0x0010, 0x0010), "PatientName"); |
426 | 426 |
427 int64_t b; | 427 int64_t b; |
428 ResourceType t; | 428 ResourceType t; |
429 ASSERT_TRUE(index_->LookupResource(b, t, "g")); | 429 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).LookupResource(b, t, "g")); |
430 ASSERT_EQ(7, b); | 430 ASSERT_EQ(7, b); |
431 ASSERT_EQ(ResourceType_Study, t); | 431 ASSERT_EQ(ResourceType_Study, t); |
432 | 432 |
433 ASSERT_TRUE(index_->LookupMetadata(s, a[4], MetadataType_Instance_RemoteAet)); | 433 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).LookupMetadata(s, a[4], MetadataType_Instance_RemoteAet)); |
434 ASSERT_FALSE(index_->LookupMetadata(s, a[4], MetadataType_Instance_IndexInSeries)); | 434 ASSERT_FALSE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).LookupMetadata(s, a[4], MetadataType_Instance_IndexInSeries)); |
435 ASSERT_EQ("PINNACLE", s); | 435 ASSERT_EQ("PINNACLE", s); |
436 | 436 |
437 std::string u; | 437 std::string u; |
438 ASSERT_TRUE(index_->LookupMetadata(u, a[4], MetadataType_Instance_RemoteAet)); | 438 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).LookupMetadata(u, a[4], MetadataType_Instance_RemoteAet)); |
439 ASSERT_EQ("PINNACLE", u); | 439 ASSERT_EQ("PINNACLE", u); |
440 ASSERT_FALSE(index_->LookupMetadata(u, a[4], MetadataType_Instance_IndexInSeries)); | 440 ASSERT_FALSE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).LookupMetadata(u, a[4], MetadataType_Instance_IndexInSeries)); |
441 | 441 |
442 ASSERT_TRUE(index_->LookupGlobalProperty(s, GlobalProperty_FlushSleep)); | 442 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).LookupGlobalProperty(s, GlobalProperty_FlushSleep)); |
443 ASSERT_FALSE(index_->LookupGlobalProperty(s, static_cast<GlobalProperty>(42))); | 443 ASSERT_FALSE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).LookupGlobalProperty(s, static_cast<GlobalProperty>(42))); |
444 ASSERT_EQ("World", s); | 444 ASSERT_EQ("World", s); |
445 | 445 |
446 FileInfo att; | 446 FileInfo att; |
447 ASSERT_TRUE(index_->LookupAttachment(att, a[4], FileContentType_DicomAsJson)); | 447 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).LookupAttachment(att, a[4], FileContentType_DicomAsJson)); |
448 ASSERT_EQ("my json file", att.GetUuid()); | 448 ASSERT_EQ("my json file", att.GetUuid()); |
449 ASSERT_EQ(21u, att.GetCompressedSize()); | 449 ASSERT_EQ(21u, att.GetCompressedSize()); |
450 ASSERT_EQ("md5", att.GetUncompressedMD5()); | 450 ASSERT_EQ("md5", att.GetUncompressedMD5()); |
451 ASSERT_EQ("compressedMD5", att.GetCompressedMD5()); | 451 ASSERT_EQ("compressedMD5", att.GetCompressedMD5()); |
452 ASSERT_EQ(42u, att.GetUncompressedSize()); | 452 ASSERT_EQ(42u, att.GetUncompressedSize()); |
453 ASSERT_EQ(CompressionType_ZlibWithSize, att.GetCompressionType()); | 453 ASSERT_EQ(CompressionType_ZlibWithSize, att.GetCompressionType()); |
454 | 454 |
455 ASSERT_TRUE(index_->LookupAttachment(att, a[6], FileContentType_Dicom)); | 455 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).LookupAttachment(att, a[6], FileContentType_Dicom)); |
456 ASSERT_EQ("world", att.GetUuid()); | 456 ASSERT_EQ("world", att.GetUuid()); |
457 ASSERT_EQ(44u, att.GetCompressedSize()); | 457 ASSERT_EQ(44u, att.GetCompressedSize()); |
458 ASSERT_EQ("md5", att.GetUncompressedMD5()); | 458 ASSERT_EQ("md5", att.GetUncompressedMD5()); |
459 ASSERT_EQ("md5", att.GetCompressedMD5()); | 459 ASSERT_EQ("md5", att.GetCompressedMD5()); |
460 ASSERT_EQ(44u, att.GetUncompressedSize()); | 460 ASSERT_EQ(44u, att.GetUncompressedSize()); |
466 CheckTableRecordCount(7, "Resources"); | 466 CheckTableRecordCount(7, "Resources"); |
467 CheckTableRecordCount(3, "AttachedFiles"); | 467 CheckTableRecordCount(3, "AttachedFiles"); |
468 CheckTableRecordCount(1, "Metadata"); | 468 CheckTableRecordCount(1, "Metadata"); |
469 CheckTableRecordCount(1, "MainDicomTags"); | 469 CheckTableRecordCount(1, "MainDicomTags"); |
470 | 470 |
471 index_->DeleteResource(a[0]); | 471 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(a[0]); |
472 ASSERT_EQ(5u, listener_->deletedResources_.size()); | 472 ASSERT_EQ(5u, listener_->deletedResources_.size()); |
473 ASSERT_EQ(2u, listener_->deletedFiles_.size()); | 473 ASSERT_EQ(2u, listener_->deletedFiles_.size()); |
474 ASSERT_FALSE(std::find(listener_->deletedFiles_.begin(), | 474 ASSERT_FALSE(std::find(listener_->deletedFiles_.begin(), |
475 listener_->deletedFiles_.end(), | 475 listener_->deletedFiles_.end(), |
476 "my json file") == listener_->deletedFiles_.end()); | 476 "my json file") == listener_->deletedFiles_.end()); |
481 CheckTableRecordCount(2, "Resources"); | 481 CheckTableRecordCount(2, "Resources"); |
482 CheckTableRecordCount(0, "Metadata"); | 482 CheckTableRecordCount(0, "Metadata"); |
483 CheckTableRecordCount(1, "AttachedFiles"); | 483 CheckTableRecordCount(1, "AttachedFiles"); |
484 CheckTableRecordCount(0, "MainDicomTags"); | 484 CheckTableRecordCount(0, "MainDicomTags"); |
485 | 485 |
486 index_->DeleteResource(a[5]); | 486 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(a[5]); |
487 ASSERT_EQ(7u, listener_->deletedResources_.size()); | 487 ASSERT_EQ(7u, listener_->deletedResources_.size()); |
488 | 488 |
489 CheckTableRecordCount(0, "Resources"); | 489 CheckTableRecordCount(0, "Resources"); |
490 CheckTableRecordCount(0, "AttachedFiles"); | 490 CheckTableRecordCount(0, "AttachedFiles"); |
491 CheckTableRecordCount(3, "GlobalProperties"); | 491 CheckTableRecordCount(3, "GlobalProperties"); |
492 | 492 |
493 std::string tmp; | 493 std::string tmp; |
494 ASSERT_TRUE(index_->LookupGlobalProperty(tmp, GlobalProperty_DatabaseSchemaVersion)); | 494 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).LookupGlobalProperty(tmp, GlobalProperty_DatabaseSchemaVersion)); |
495 ASSERT_EQ("6", tmp); | 495 ASSERT_EQ("6", tmp); |
496 ASSERT_TRUE(index_->LookupGlobalProperty(tmp, GlobalProperty_FlushSleep)); | 496 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).LookupGlobalProperty(tmp, GlobalProperty_FlushSleep)); |
497 ASSERT_EQ("World", tmp); | 497 ASSERT_EQ("World", tmp); |
498 ASSERT_TRUE(index_->LookupGlobalProperty(tmp, GlobalProperty_GetTotalSizeIsFast)); | 498 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).LookupGlobalProperty(tmp, GlobalProperty_GetTotalSizeIsFast)); |
499 ASSERT_EQ("1", tmp); | 499 ASSERT_EQ("1", tmp); |
500 | 500 |
501 ASSERT_EQ(3u, listener_->deletedFiles_.size()); | 501 ASSERT_EQ(3u, listener_->deletedFiles_.size()); |
502 ASSERT_FALSE(std::find(listener_->deletedFiles_.begin(), | 502 ASSERT_FALSE(std::find(listener_->deletedFiles_.begin(), |
503 listener_->deletedFiles_.end(), | 503 listener_->deletedFiles_.end(), |
508 | 508 |
509 | 509 |
510 TEST_P(DatabaseWrapperTest, Upward) | 510 TEST_P(DatabaseWrapperTest, Upward) |
511 { | 511 { |
512 int64_t a[] = { | 512 int64_t a[] = { |
513 index_->CreateResource("a", ResourceType_Patient), // 0 | 513 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource("a", ResourceType_Patient), // 0 |
514 index_->CreateResource("b", ResourceType_Study), // 1 | 514 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource("b", ResourceType_Study), // 1 |
515 index_->CreateResource("c", ResourceType_Series), // 2 | 515 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource("c", ResourceType_Series), // 2 |
516 index_->CreateResource("d", ResourceType_Instance), // 3 | 516 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource("d", ResourceType_Instance), // 3 |
517 index_->CreateResource("e", ResourceType_Instance), // 4 | 517 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource("e", ResourceType_Instance), // 4 |
518 index_->CreateResource("f", ResourceType_Study), // 5 | 518 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource("f", ResourceType_Study), // 5 |
519 index_->CreateResource("g", ResourceType_Series), // 6 | 519 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource("g", ResourceType_Series), // 6 |
520 index_->CreateResource("h", ResourceType_Series) // 7 | 520 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource("h", ResourceType_Series) // 7 |
521 }; | 521 }; |
522 | 522 |
523 index_->AttachChild(a[0], a[1]); | 523 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).AttachChild(a[0], a[1]); |
524 index_->AttachChild(a[1], a[2]); | 524 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).AttachChild(a[1], a[2]); |
525 index_->AttachChild(a[2], a[3]); | 525 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).AttachChild(a[2], a[3]); |
526 index_->AttachChild(a[2], a[4]); | 526 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).AttachChild(a[2], a[4]); |
527 index_->AttachChild(a[1], a[6]); | 527 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).AttachChild(a[1], a[6]); |
528 index_->AttachChild(a[0], a[5]); | 528 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).AttachChild(a[0], a[5]); |
529 index_->AttachChild(a[5], a[7]); | 529 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).AttachChild(a[5], a[7]); |
530 | 530 |
531 CheckTwoChildren("b", "f", a[0]); | 531 CheckTwoChildren("b", "f", a[0]); |
532 CheckTwoChildren("c", "g", a[1]); | 532 CheckTwoChildren("c", "g", a[1]); |
533 CheckTwoChildren("d", "e", a[2]); | 533 CheckTwoChildren("d", "e", a[2]); |
534 CheckNoChild(a[3]); | 534 CheckNoChild(a[3]); |
536 CheckOneChild("h", a[5]); | 536 CheckOneChild("h", a[5]); |
537 CheckNoChild(a[6]); | 537 CheckNoChild(a[6]); |
538 CheckNoChild(a[7]); | 538 CheckNoChild(a[7]); |
539 | 539 |
540 listener_->Reset(); | 540 listener_->Reset(); |
541 index_->DeleteResource(a[3]); | 541 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(a[3]); |
542 ASSERT_EQ("c", listener_->ancestorId_); | 542 ASSERT_EQ("c", listener_->ancestorId_); |
543 ASSERT_EQ(ResourceType_Series, listener_->ancestorType_); | 543 ASSERT_EQ(ResourceType_Series, listener_->ancestorType_); |
544 | 544 |
545 listener_->Reset(); | 545 listener_->Reset(); |
546 index_->DeleteResource(a[4]); | 546 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(a[4]); |
547 ASSERT_EQ("b", listener_->ancestorId_); | 547 ASSERT_EQ("b", listener_->ancestorId_); |
548 ASSERT_EQ(ResourceType_Study, listener_->ancestorType_); | 548 ASSERT_EQ(ResourceType_Study, listener_->ancestorType_); |
549 | 549 |
550 listener_->Reset(); | 550 listener_->Reset(); |
551 index_->DeleteResource(a[7]); | 551 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(a[7]); |
552 ASSERT_EQ("a", listener_->ancestorId_); | 552 ASSERT_EQ("a", listener_->ancestorId_); |
553 ASSERT_EQ(ResourceType_Patient, listener_->ancestorType_); | 553 ASSERT_EQ(ResourceType_Patient, listener_->ancestorType_); |
554 | 554 |
555 listener_->Reset(); | 555 listener_->Reset(); |
556 index_->DeleteResource(a[6]); | 556 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(a[6]); |
557 ASSERT_EQ("", listener_->ancestorId_); // No more ancestor | 557 ASSERT_EQ("", listener_->ancestorId_); // No more ancestor |
558 } | 558 } |
559 | 559 |
560 | 560 |
561 TEST_P(DatabaseWrapperTest, PatientRecycling) | 561 TEST_P(DatabaseWrapperTest, PatientRecycling) |
562 { | 562 { |
563 std::vector<int64_t> patients; | 563 std::vector<int64_t> patients; |
564 for (int i = 0; i < 10; i++) | 564 for (int i = 0; i < 10; i++) |
565 { | 565 { |
566 std::string p = "Patient " + boost::lexical_cast<std::string>(i); | 566 std::string p = "Patient " + boost::lexical_cast<std::string>(i); |
567 patients.push_back(index_->CreateResource(p, ResourceType_Patient)); | 567 patients.push_back(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource(p, ResourceType_Patient)); |
568 index_->AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10, | 568 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10, |
569 "md5-" + boost::lexical_cast<std::string>(i))); | 569 "md5-" + boost::lexical_cast<std::string>(i))); |
570 ASSERT_FALSE(index_->IsProtectedPatient(patients[i])); | 570 ASSERT_FALSE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).IsProtectedPatient(patients[i])); |
571 } | 571 } |
572 | 572 |
573 CheckTableRecordCount(10u, "Resources"); | 573 CheckTableRecordCount(10u, "Resources"); |
574 CheckTableRecordCount(10u, "PatientRecyclingOrder"); | 574 CheckTableRecordCount(10u, "PatientRecyclingOrder"); |
575 | 575 |
576 listener_->Reset(); | 576 listener_->Reset(); |
577 ASSERT_EQ(0u, listener_->deletedResources_.size()); | 577 ASSERT_EQ(0u, listener_->deletedResources_.size()); |
578 | 578 |
579 index_->DeleteResource(patients[5]); | 579 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(patients[5]); |
580 index_->DeleteResource(patients[0]); | 580 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(patients[0]); |
581 ASSERT_EQ(2u, listener_->deletedResources_.size()); | 581 ASSERT_EQ(2u, listener_->deletedResources_.size()); |
582 | 582 |
583 CheckTableRecordCount(8u, "Resources"); | 583 CheckTableRecordCount(8u, "Resources"); |
584 CheckTableRecordCount(8u, "PatientRecyclingOrder"); | 584 CheckTableRecordCount(8u, "PatientRecyclingOrder"); |
585 | 585 |
586 ASSERT_EQ(2u, listener_->deletedFiles_.size()); | 586 ASSERT_EQ(2u, listener_->deletedFiles_.size()); |
587 ASSERT_EQ("Patient 5", listener_->deletedFiles_[0]); | 587 ASSERT_EQ("Patient 5", listener_->deletedFiles_[0]); |
588 ASSERT_EQ("Patient 0", listener_->deletedFiles_[1]); | 588 ASSERT_EQ("Patient 0", listener_->deletedFiles_[1]); |
589 | 589 |
590 int64_t p; | 590 int64_t p; |
591 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[1]); | 591 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[1]); |
592 index_->DeleteResource(p); | 592 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(p); |
593 ASSERT_EQ(3u, listener_->deletedResources_.size()); | 593 ASSERT_EQ(3u, listener_->deletedResources_.size()); |
594 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[2]); | 594 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[2]); |
595 index_->DeleteResource(p); | 595 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(p); |
596 ASSERT_EQ(4u, listener_->deletedResources_.size()); | 596 ASSERT_EQ(4u, listener_->deletedResources_.size()); |
597 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[3]); | 597 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[3]); |
598 index_->DeleteResource(p); | 598 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(p); |
599 ASSERT_EQ(5u, listener_->deletedResources_.size()); | 599 ASSERT_EQ(5u, listener_->deletedResources_.size()); |
600 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[4]); | 600 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[4]); |
601 index_->DeleteResource(p); | 601 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(p); |
602 ASSERT_EQ(6u, listener_->deletedResources_.size()); | 602 ASSERT_EQ(6u, listener_->deletedResources_.size()); |
603 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[6]); | 603 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[6]); |
604 index_->DeleteResource(p); | 604 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(p); |
605 index_->DeleteResource(patients[8]); | 605 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(patients[8]); |
606 ASSERT_EQ(8u, listener_->deletedResources_.size()); | 606 ASSERT_EQ(8u, listener_->deletedResources_.size()); |
607 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[7]); | 607 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[7]); |
608 index_->DeleteResource(p); | 608 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(p); |
609 ASSERT_EQ(9u, listener_->deletedResources_.size()); | 609 ASSERT_EQ(9u, listener_->deletedResources_.size()); |
610 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[9]); | 610 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[9]); |
611 index_->DeleteResource(p); | 611 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(p); |
612 ASSERT_FALSE(index_->SelectPatientToRecycle(p)); | 612 ASSERT_FALSE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SelectPatientToRecycle(p)); |
613 ASSERT_EQ(10u, listener_->deletedResources_.size()); | 613 ASSERT_EQ(10u, listener_->deletedResources_.size()); |
614 | 614 |
615 ASSERT_EQ(10u, listener_->deletedFiles_.size()); | 615 ASSERT_EQ(10u, listener_->deletedFiles_.size()); |
616 | 616 |
617 CheckTableRecordCount(0, "Resources"); | 617 CheckTableRecordCount(0, "Resources"); |
623 { | 623 { |
624 std::vector<int64_t> patients; | 624 std::vector<int64_t> patients; |
625 for (int i = 0; i < 5; i++) | 625 for (int i = 0; i < 5; i++) |
626 { | 626 { |
627 std::string p = "Patient " + boost::lexical_cast<std::string>(i); | 627 std::string p = "Patient " + boost::lexical_cast<std::string>(i); |
628 patients.push_back(index_->CreateResource(p, ResourceType_Patient)); | 628 patients.push_back(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource(p, ResourceType_Patient)); |
629 index_->AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10, | 629 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10, |
630 "md5-" + boost::lexical_cast<std::string>(i))); | 630 "md5-" + boost::lexical_cast<std::string>(i))); |
631 ASSERT_FALSE(index_->IsProtectedPatient(patients[i])); | 631 ASSERT_FALSE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).IsProtectedPatient(patients[i])); |
632 } | 632 } |
633 | 633 |
634 CheckTableRecordCount(5, "Resources"); | 634 CheckTableRecordCount(5, "Resources"); |
635 CheckTableRecordCount(5, "PatientRecyclingOrder"); | 635 CheckTableRecordCount(5, "PatientRecyclingOrder"); |
636 | 636 |
637 ASSERT_FALSE(index_->IsProtectedPatient(patients[2])); | 637 ASSERT_FALSE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).IsProtectedPatient(patients[2])); |
638 index_->SetProtectedPatient(patients[2], true); | 638 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SetProtectedPatient(patients[2], true); |
639 ASSERT_TRUE(index_->IsProtectedPatient(patients[2])); | 639 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).IsProtectedPatient(patients[2])); |
640 CheckTableRecordCount(5, "Resources"); | 640 CheckTableRecordCount(5, "Resources"); |
641 CheckTableRecordCount(4, "PatientRecyclingOrder"); | 641 CheckTableRecordCount(4, "PatientRecyclingOrder"); |
642 | 642 |
643 index_->SetProtectedPatient(patients[2], true); | 643 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SetProtectedPatient(patients[2], true); |
644 ASSERT_TRUE(index_->IsProtectedPatient(patients[2])); | 644 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).IsProtectedPatient(patients[2])); |
645 CheckTableRecordCount(4, "PatientRecyclingOrder"); | 645 CheckTableRecordCount(4, "PatientRecyclingOrder"); |
646 index_->SetProtectedPatient(patients[2], false); | 646 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SetProtectedPatient(patients[2], false); |
647 ASSERT_FALSE(index_->IsProtectedPatient(patients[2])); | 647 ASSERT_FALSE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).IsProtectedPatient(patients[2])); |
648 CheckTableRecordCount(5, "PatientRecyclingOrder"); | 648 CheckTableRecordCount(5, "PatientRecyclingOrder"); |
649 index_->SetProtectedPatient(patients[2], false); | 649 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SetProtectedPatient(patients[2], false); |
650 ASSERT_FALSE(index_->IsProtectedPatient(patients[2])); | 650 ASSERT_FALSE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).IsProtectedPatient(patients[2])); |
651 CheckTableRecordCount(5, "PatientRecyclingOrder"); | 651 CheckTableRecordCount(5, "PatientRecyclingOrder"); |
652 CheckTableRecordCount(5, "Resources"); | 652 CheckTableRecordCount(5, "Resources"); |
653 index_->SetProtectedPatient(patients[2], true); | 653 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SetProtectedPatient(patients[2], true); |
654 ASSERT_TRUE(index_->IsProtectedPatient(patients[2])); | 654 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).IsProtectedPatient(patients[2])); |
655 CheckTableRecordCount(4, "PatientRecyclingOrder"); | 655 CheckTableRecordCount(4, "PatientRecyclingOrder"); |
656 index_->SetProtectedPatient(patients[2], false); | 656 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SetProtectedPatient(patients[2], false); |
657 ASSERT_FALSE(index_->IsProtectedPatient(patients[2])); | 657 ASSERT_FALSE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).IsProtectedPatient(patients[2])); |
658 CheckTableRecordCount(5, "PatientRecyclingOrder"); | 658 CheckTableRecordCount(5, "PatientRecyclingOrder"); |
659 index_->SetProtectedPatient(patients[3], true); | 659 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SetProtectedPatient(patients[3], true); |
660 ASSERT_TRUE(index_->IsProtectedPatient(patients[3])); | 660 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).IsProtectedPatient(patients[3])); |
661 CheckTableRecordCount(4, "PatientRecyclingOrder"); | 661 CheckTableRecordCount(4, "PatientRecyclingOrder"); |
662 | 662 |
663 CheckTableRecordCount(5, "Resources"); | 663 CheckTableRecordCount(5, "Resources"); |
664 ASSERT_EQ(0u, listener_->deletedFiles_.size()); | 664 ASSERT_EQ(0u, listener_->deletedFiles_.size()); |
665 | 665 |
666 // Unprotecting a patient puts it at the last position in the recycling queue | 666 // Unprotecting a patient puts it at the last position in the recycling queue |
667 int64_t p; | 667 int64_t p; |
668 ASSERT_EQ(0u, listener_->deletedResources_.size()); | 668 ASSERT_EQ(0u, listener_->deletedResources_.size()); |
669 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[0]); | 669 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[0]); |
670 index_->DeleteResource(p); | 670 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(p); |
671 ASSERT_EQ(1u, listener_->deletedResources_.size()); | 671 ASSERT_EQ(1u, listener_->deletedResources_.size()); |
672 ASSERT_TRUE(index_->SelectPatientToRecycle(p, patients[1])); ASSERT_EQ(p, patients[4]); | 672 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SelectPatientToRecycle(p, patients[1])); ASSERT_EQ(p, patients[4]); |
673 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[1]); | 673 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[1]); |
674 index_->DeleteResource(p); | 674 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(p); |
675 ASSERT_EQ(2u, listener_->deletedResources_.size()); | 675 ASSERT_EQ(2u, listener_->deletedResources_.size()); |
676 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[4]); | 676 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[4]); |
677 index_->DeleteResource(p); | 677 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(p); |
678 ASSERT_EQ(3u, listener_->deletedResources_.size()); | 678 ASSERT_EQ(3u, listener_->deletedResources_.size()); |
679 ASSERT_FALSE(index_->SelectPatientToRecycle(p, patients[2])); | 679 ASSERT_FALSE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SelectPatientToRecycle(p, patients[2])); |
680 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[2]); | 680 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[2]); |
681 index_->DeleteResource(p); | 681 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(p); |
682 ASSERT_EQ(4u, listener_->deletedResources_.size()); | 682 ASSERT_EQ(4u, listener_->deletedResources_.size()); |
683 // "patients[3]" is still protected | 683 // "patients[3]" is still protected |
684 ASSERT_FALSE(index_->SelectPatientToRecycle(p)); | 684 ASSERT_FALSE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SelectPatientToRecycle(p)); |
685 | 685 |
686 ASSERT_EQ(4u, listener_->deletedFiles_.size()); | 686 ASSERT_EQ(4u, listener_->deletedFiles_.size()); |
687 CheckTableRecordCount(1, "Resources"); | 687 CheckTableRecordCount(1, "Resources"); |
688 CheckTableRecordCount(0, "PatientRecyclingOrder"); | 688 CheckTableRecordCount(0, "PatientRecyclingOrder"); |
689 | 689 |
690 index_->SetProtectedPatient(patients[3], false); | 690 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SetProtectedPatient(patients[3], false); |
691 CheckTableRecordCount(1, "PatientRecyclingOrder"); | 691 CheckTableRecordCount(1, "PatientRecyclingOrder"); |
692 ASSERT_FALSE(index_->SelectPatientToRecycle(p, patients[3])); | 692 ASSERT_FALSE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SelectPatientToRecycle(p, patients[3])); |
693 ASSERT_TRUE(index_->SelectPatientToRecycle(p, patients[2])); | 693 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SelectPatientToRecycle(p, patients[2])); |
694 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[3]); | 694 ASSERT_TRUE(dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[3]); |
695 index_->DeleteResource(p); | 695 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).DeleteResource(p); |
696 ASSERT_EQ(5u, listener_->deletedResources_.size()); | 696 ASSERT_EQ(5u, listener_->deletedResources_.size()); |
697 | 697 |
698 ASSERT_EQ(5u, listener_->deletedFiles_.size()); | 698 ASSERT_EQ(5u, listener_->deletedFiles_.size()); |
699 CheckTableRecordCount(0, "Resources"); | 699 CheckTableRecordCount(0, "Resources"); |
700 CheckTableRecordCount(0, "PatientRecyclingOrder"); | 700 CheckTableRecordCount(0, "PatientRecyclingOrder"); |
727 | 727 |
728 | 728 |
729 TEST_P(DatabaseWrapperTest, LookupIdentifier) | 729 TEST_P(DatabaseWrapperTest, LookupIdentifier) |
730 { | 730 { |
731 int64_t a[] = { | 731 int64_t a[] = { |
732 index_->CreateResource("a", ResourceType_Study), // 0 | 732 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource("a", ResourceType_Study), // 0 |
733 index_->CreateResource("b", ResourceType_Study), // 1 | 733 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource("b", ResourceType_Study), // 1 |
734 index_->CreateResource("c", ResourceType_Study), // 2 | 734 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource("c", ResourceType_Study), // 2 |
735 index_->CreateResource("d", ResourceType_Series) // 3 | 735 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).CreateResource("d", ResourceType_Series) // 3 |
736 }; | 736 }; |
737 | 737 |
738 index_->SetIdentifierTag(a[0], DICOM_TAG_STUDY_INSTANCE_UID, "0"); | 738 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SetIdentifierTag(a[0], DICOM_TAG_STUDY_INSTANCE_UID, "0"); |
739 index_->SetIdentifierTag(a[1], DICOM_TAG_STUDY_INSTANCE_UID, "1"); | 739 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SetIdentifierTag(a[1], DICOM_TAG_STUDY_INSTANCE_UID, "1"); |
740 index_->SetIdentifierTag(a[2], DICOM_TAG_STUDY_INSTANCE_UID, "0"); | 740 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SetIdentifierTag(a[2], DICOM_TAG_STUDY_INSTANCE_UID, "0"); |
741 index_->SetIdentifierTag(a[3], DICOM_TAG_SERIES_INSTANCE_UID, "0"); | 741 dynamic_cast<SQLiteDatabaseWrapper&>(*index_).SetIdentifierTag(a[3], DICOM_TAG_SERIES_INSTANCE_UID, "0"); |
742 | 742 |
743 std::list<std::string> s; | 743 std::list<std::string> s; |
744 | 744 |
745 DoLookupIdentifier(s, ResourceType_Study, DICOM_TAG_STUDY_INSTANCE_UID, ConstraintType_Equal, "0"); | 745 DoLookupIdentifier(s, ResourceType_Study, DICOM_TAG_STUDY_INSTANCE_UID, ConstraintType_Equal, "0"); |
746 ASSERT_EQ(2u, s.size()); | 746 ASSERT_EQ(2u, s.size()); |