Mercurial > hg > orthanc
comparison UnitTestsSources/MemoryCacheTests.cpp @ 3736:0540b54324f1 storage-commitment
StorageCommitmentReports
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 10 Mar 2020 17:43:49 +0100 |
parents | 94f4a18a79cc |
children |
comparison
equal
deleted
inserted
replaced
3735:77183afbf55e | 3736:0540b54324f1 |
---|---|
42 #include "../Core/Cache/MemoryCache.h" | 42 #include "../Core/Cache/MemoryCache.h" |
43 #include "../Core/Cache/MemoryStringCache.h" | 43 #include "../Core/Cache/MemoryStringCache.h" |
44 #include "../Core/Cache/SharedArchive.h" | 44 #include "../Core/Cache/SharedArchive.h" |
45 #include "../Core/IDynamicObject.h" | 45 #include "../Core/IDynamicObject.h" |
46 #include "../Core/Logging.h" | 46 #include "../Core/Logging.h" |
47 #include "../OrthancServer/StorageCommitmentReports.h" | |
47 | 48 |
48 | 49 |
49 TEST(LRU, Basic) | 50 TEST(LRU, Basic) |
50 { | 51 { |
51 Orthanc::LeastRecentlyUsedIndex<std::string> r; | 52 Orthanc::LeastRecentlyUsedIndex<std::string> r; |
364 | 365 |
365 c.Invalidate("hello"); | 366 c.Invalidate("hello"); |
366 ASSERT_FALSE(c.Fetch(v, "hello")); | 367 ASSERT_FALSE(c.Fetch(v, "hello")); |
367 ASSERT_TRUE(c.Fetch(v, "hello2")); ASSERT_EQ("b", v); | 368 ASSERT_TRUE(c.Fetch(v, "hello2")); ASSERT_EQ("b", v); |
368 } | 369 } |
370 | |
371 | |
372 TEST(StorageCommitmentReports, Basic) | |
373 { | |
374 Orthanc::StorageCommitmentReports reports(2); | |
375 ASSERT_EQ(2u, reports.GetMaxSize()); | |
376 | |
377 { | |
378 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "nope"); | |
379 ASSERT_EQ("nope", accessor.GetTransactionUid()); | |
380 ASSERT_FALSE(accessor.IsValid()); | |
381 ASSERT_THROW(accessor.GetReport(), Orthanc::OrthancException); | |
382 } | |
383 | |
384 reports.Store("a", new Orthanc::StorageCommitmentReports::Report("aet_a")); | |
385 reports.Store("b", new Orthanc::StorageCommitmentReports::Report("aet_b")); | |
386 reports.Store("c", new Orthanc::StorageCommitmentReports::Report("aet_c")); | |
387 | |
388 { | |
389 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "a"); | |
390 ASSERT_FALSE(accessor.IsValid()); | |
391 } | |
392 | |
393 { | |
394 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "b"); | |
395 ASSERT_TRUE(accessor.IsValid()); | |
396 ASSERT_EQ("aet_b", accessor.GetReport().GetRemoteAet()); | |
397 ASSERT_EQ(Orthanc::StorageCommitmentReports::Report::Status_Pending, | |
398 accessor.GetReport().GetStatus()); | |
399 } | |
400 | |
401 { | |
402 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "c"); | |
403 ASSERT_EQ("aet_c", accessor.GetReport().GetRemoteAet()); | |
404 ASSERT_TRUE(accessor.IsValid()); | |
405 } | |
406 | |
407 { | |
408 std::unique_ptr<Orthanc::StorageCommitmentReports::Report> report | |
409 (new Orthanc::StorageCommitmentReports::Report("aet")); | |
410 report->AddSuccess("class1", "instance1"); | |
411 report->AddFailure("class2", "instance2", | |
412 Orthanc::StorageCommitmentFailureReason_ReferencedSOPClassNotSupported); | |
413 report->MarkAsComplete(); | |
414 reports.Store("a", report.release()); | |
415 } | |
416 | |
417 { | |
418 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "a"); | |
419 ASSERT_TRUE(accessor.IsValid()); | |
420 ASSERT_EQ("aet", accessor.GetReport().GetRemoteAet()); | |
421 ASSERT_EQ(Orthanc::StorageCommitmentReports::Report::Status_Failure, | |
422 accessor.GetReport().GetStatus()); | |
423 } | |
424 | |
425 { | |
426 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "b"); | |
427 ASSERT_FALSE(accessor.IsValid()); | |
428 } | |
429 | |
430 { | |
431 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "c"); | |
432 ASSERT_TRUE(accessor.IsValid()); | |
433 } | |
434 | |
435 { | |
436 std::unique_ptr<Orthanc::StorageCommitmentReports::Report> report | |
437 (new Orthanc::StorageCommitmentReports::Report("aet")); | |
438 report->AddSuccess("class1", "instance1"); | |
439 report->MarkAsComplete(); | |
440 reports.Store("a", report.release()); | |
441 } | |
442 | |
443 { | |
444 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "a"); | |
445 ASSERT_TRUE(accessor.IsValid()); | |
446 ASSERT_EQ("aet", accessor.GetReport().GetRemoteAet()); | |
447 ASSERT_EQ(Orthanc::StorageCommitmentReports::Report::Status_Success, | |
448 accessor.GetReport().GetStatus()); | |
449 } | |
450 | |
451 { | |
452 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "b"); | |
453 ASSERT_FALSE(accessor.IsValid()); | |
454 } | |
455 | |
456 { | |
457 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "c"); | |
458 ASSERT_TRUE(accessor.IsValid()); | |
459 } | |
460 } |