Mercurial > hg > orthanc-databases
comparison Framework/Plugins/IndexUnitTests.h @ 569:f18e46d7dbf8 attach-custom-data
merged find-refactoring -> attach-custom-data
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 24 Sep 2024 15:04:21 +0200 |
parents | 9ed9a91bde33 |
children |
comparison
equal
deleted
inserted
replaced
368:82f73188b58d | 569:f18e46d7dbf8 |
---|---|
1 /** | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
4 * Department, University Hospital of Liege, Belgium | 4 * Department, University Hospital of Liege, Belgium |
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium | 5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium | |
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium | |
6 * | 8 * |
7 * This program is free software: you can redistribute it and/or | 9 * This program is free software: you can redistribute it and/or |
8 * modify it under the terms of the GNU Affero General Public License | 10 * modify it under the terms of the GNU Affero General Public License |
9 * as published by the Free Software Foundation, either version 3 of | 11 * as published by the Free Software Foundation, either version 3 of |
10 * the License, or (at your option) any later version. | 12 * the License, or (at your option) any later version. |
25 #include "DatabaseBackendAdapterV2.h" | 27 #include "DatabaseBackendAdapterV2.h" |
26 #include "GlobalProperties.h" | 28 #include "GlobalProperties.h" |
27 | 29 |
28 #include <Compatibility.h> // For std::unique_ptr<> | 30 #include <Compatibility.h> // For std::unique_ptr<> |
29 | 31 |
30 #include <orthanc/OrthancCDatabasePlugin.h> | |
31 | |
32 #include <gtest/gtest.h> | 32 #include <gtest/gtest.h> |
33 #include <list> | 33 #include <list> |
34 | 34 |
35 #if !defined(ORTHANC_DATABASE_VERSION) | 35 #if !defined(ORTHANC_DATABASE_VERSION) |
36 // This happens if using the Orthanc framework system-wide library | 36 // This happens if using the Orthanc framework system-wide library |
54 namespace Orthanc | 54 namespace Orthanc |
55 { | 55 { |
56 /** | 56 /** |
57 * Mock enumeration inspired from the source code of Orthanc... only | 57 * Mock enumeration inspired from the source code of Orthanc... only |
58 * for use in the unit tests! | 58 * for use in the unit tests! |
59 * https://hg.orthanc-server.com/orthanc/file/default/OrthancServer/Sources/ServerEnumerations.h | 59 * https://orthanc.uclouvain.be/hg/orthanc/file/default/OrthancServer/Sources/ServerEnumerations.h |
60 **/ | 60 **/ |
61 enum MetadataType | 61 enum MetadataType |
62 { | 62 { |
63 MetadataType_ModifiedFrom, | 63 MetadataType_ModifiedFrom, |
64 MetadataType_LastUpdate | 64 MetadataType_LastUpdate |
243 # error Unsupported database backend | 243 # error Unsupported database backend |
244 #endif | 244 #endif |
245 | 245 |
246 db.SetOutputFactory(new DatabaseBackendAdapterV2::Factory(&context, NULL)); | 246 db.SetOutputFactory(new DatabaseBackendAdapterV2::Factory(&context, NULL)); |
247 | 247 |
248 std::unique_ptr<DatabaseManager> manager(IndexBackend::CreateSingleDatabaseManager(db)); | 248 std::list<IdentifierTag> identifierTags; |
249 std::unique_ptr<DatabaseManager> manager(IndexBackend::CreateSingleDatabaseManager(db, false, identifierTags)); | |
249 | 250 |
250 std::unique_ptr<IDatabaseBackendOutput> output(db.CreateOutput()); | 251 std::unique_ptr<IDatabaseBackendOutput> output(db.CreateOutput()); |
251 | 252 |
252 std::string s; | 253 std::string s; |
253 ASSERT_TRUE(db.LookupGlobalProperty(s, *manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabaseSchemaVersion)); | 254 ASSERT_TRUE(db.LookupGlobalProperty(s, *manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabaseSchemaVersion)); |
507 db.LookupIdentifier(ci, *manager, OrthancPluginResourceType_Study, 0x0010, 0x0020, | 508 db.LookupIdentifier(ci, *manager, OrthancPluginResourceType_Study, 0x0010, 0x0020, |
508 OrthancPluginIdentifierConstraint_Equal, "study"); | 509 OrthancPluginIdentifierConstraint_Equal, "study"); |
509 ASSERT_EQ(0u, ci.size()); | 510 ASSERT_EQ(0u, ci.size()); |
510 | 511 |
511 | 512 |
512 OrthancPluginExportedResource exp; | 513 db.LogExportedResource(*manager, OrthancPluginResourceType_Study, "id", "remote", "date", |
513 exp.seq = -1; | 514 "patient", "study", "series", "instance"); |
514 exp.resourceType = OrthancPluginResourceType_Study; | |
515 exp.publicId = "id"; | |
516 exp.modality = "remote"; | |
517 exp.date = "date"; | |
518 exp.patientId = "patient"; | |
519 exp.studyInstanceUid = "study"; | |
520 exp.seriesInstanceUid = "series"; | |
521 exp.sopInstanceUid = "instance"; | |
522 db.LogExportedResource(*manager, exp); | |
523 | 515 |
524 expectedExported.reset(new OrthancPluginExportedResource()); | 516 expectedExported.reset(new OrthancPluginExportedResource()); |
525 *expectedExported = exp; | 517 expectedExported->seq = -1; |
518 expectedExported->resourceType = OrthancPluginResourceType_Study; | |
519 expectedExported->publicId = "id"; | |
520 expectedExported->modality = "remote"; | |
521 expectedExported->date = "date"; | |
522 expectedExported->patientId = "patient"; | |
523 expectedExported->studyInstanceUid = "study"; | |
524 expectedExported->seriesInstanceUid = "series"; | |
525 expectedExported->sopInstanceUid = "instance"; | |
526 | 526 |
527 bool done; | 527 bool done; |
528 db.GetExportedResources(*output, done, *manager, 0, 10); | 528 db.GetExportedResources(*output, done, *manager, 0, 10); |
529 | 529 |
530 | 530 |