annotate OrthancServer/UnitTestsSources/ServerJobsTests.cpp @ 4733:1db3b79d97bd

Error code and description of jobs are now saved into the Orthanc database
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 28 Jun 2021 14:25:37 +0200
parents 7826ac059c31
children c1d6ce00be3f 94616af363ec 0a38000b086d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
827
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
1 /**
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1681
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1009
diff changeset
4 * Department, University Hospital of Liege, Belgium
4437
d9473bd5ed43 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4310
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
827
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
6 *
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
7 * This program is free software: you can redistribute it and/or
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
8 * modify it under the terms of the GNU General Public License as
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
10 * License, or (at your option) any later version.
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
11 *
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
12 * In addition, as a special exception, the copyright holders of this
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
13 * program give permission to link the code of its release with the
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
16 * the linked executables. You must obey the GNU General Public License
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
20 * you do not wish to do so, delete this exception statement from your
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
21 * version. If you delete this exception statement from all source files
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
22 * in the program, then also delete it here.
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
23 *
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
24 * This program is distributed in the hope that it will be useful, but
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
27 * General Public License for more details.
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
28 *
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
29 * You should have received a copy of the GNU General Public License
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
31 **/
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
32
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
33
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 827
diff changeset
34 #include "PrecompiledHeadersUnitTests.h"
4062
0953b3dc3261 pretty-printing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4060
diff changeset
35 #include <gtest/gtest.h>
723
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
37 #include "../../OrthancFramework/Sources/Compatibility.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
38 #include "../../OrthancFramework/Sources/FileStorage/MemoryStorageArea.h"
4062
0953b3dc3261 pretty-printing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4060
diff changeset
39 #include "../../OrthancFramework/Sources/JobsEngine/Operations/LogJobOperation.h"
4304
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4245
diff changeset
40 #include "../../OrthancFramework/Sources/Logging.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
41 #include "../../OrthancFramework/Sources/SerializationToolbox.h"
4060
149172a06b4d splitting MultiThreadingTests.cpp into JobsTests.cpp and ServerJobsTests.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
42
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
43 #include "../Sources/Database/SQLiteDatabaseWrapper.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
44 #include "../Sources/ServerContext.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
45 #include "../Sources/ServerJobs/LuaJobManager.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
46 #include "../Sources/ServerJobs/OrthancJobUnserializer.h"
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
47
4062
0953b3dc3261 pretty-printing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4060
diff changeset
48 #include "../Sources/ServerJobs/Operations/DeleteResourceOperation.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
49 #include "../Sources/ServerJobs/Operations/DicomInstanceOperationValue.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
50 #include "../Sources/ServerJobs/Operations/ModifyInstanceOperation.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
51 #include "../Sources/ServerJobs/Operations/StorePeerOperation.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
52 #include "../Sources/ServerJobs/Operations/StoreScuOperation.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
53 #include "../Sources/ServerJobs/Operations/SystemCallOperation.h"
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
54
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
55 #include "../Sources/ServerJobs/ArchiveJob.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
56 #include "../Sources/ServerJobs/DicomModalityStoreJob.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
57 #include "../Sources/ServerJobs/DicomMoveScuJob.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
58 #include "../Sources/ServerJobs/MergeStudyJob.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
59 #include "../Sources/ServerJobs/OrthancPeerStoreJob.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
60 #include "../Sources/ServerJobs/ResourceModificationJob.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
61 #include "../Sources/ServerJobs/SplitStudyJob.h"
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
62
723
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 using namespace Orthanc;
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 namespace
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 {
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
68 class DummyJob : public IJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
69 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
70 private:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
71 bool fails_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
72 unsigned int count_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
73 unsigned int steps_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
74
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
75 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
76 DummyJob() :
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
77 fails_(false),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
78 count_(0),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
79 steps_(4)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
80 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
81 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
82
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
83 explicit DummyJob(bool fails) :
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
84 fails_(fails),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
85 count_(0),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
86 steps_(4)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
87 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
88 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
89
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2872
diff changeset
90 virtual void Start() ORTHANC_OVERRIDE
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
91 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
92 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
93
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2872
diff changeset
94 virtual void Reset() ORTHANC_OVERRIDE
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
95 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
96 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
97
3658
2d90dd30858c providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3641
diff changeset
98 virtual JobStepResult Step(const std::string& jobId) ORTHANC_OVERRIDE
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
99 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
100 if (fails_)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
101 {
3240
e44e0127e553 Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3093
diff changeset
102 return JobStepResult::Failure(ErrorCode_ParameterOutOfRange, NULL);
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
103 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
104 else if (count_ == steps_ - 1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
105 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
106 return JobStepResult::Success();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
107 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
108 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
109 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
110 count_++;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
111 return JobStepResult::Continue();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
112 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
113 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
114
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2872
diff changeset
115 virtual void Stop(JobStopReason reason) ORTHANC_OVERRIDE
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
116 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
117 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
118
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2872
diff changeset
119 virtual float GetProgress() ORTHANC_OVERRIDE
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
120 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
121 return static_cast<float>(count_) / static_cast<float>(steps_ - 1);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
122 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
123
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2872
diff changeset
124 virtual void GetJobType(std::string& type) ORTHANC_OVERRIDE
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
125 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
126 type = "DummyJob";
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
127 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
128
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2872
diff changeset
129 virtual bool Serialize(Json::Value& value) ORTHANC_OVERRIDE
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
130 {
2667
5fa2f2ce74f0 serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2666
diff changeset
131 value = Json::objectValue;
5fa2f2ce74f0 serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2666
diff changeset
132 value["Type"] = "DummyJob";
2663
228e2783ce83 some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
133 return true;
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
134 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
135
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2872
diff changeset
136 virtual void GetPublicContent(Json::Value& value) ORTHANC_OVERRIDE
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
137 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
138 value["hello"] = "world";
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
139 }
2976
cb5d75143da0 Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
140
cb5d75143da0 Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
141 virtual bool GetOutput(std::string& output,
cb5d75143da0 Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
142 MimeType& mime,
cb5d75143da0 Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
143 const std::string& key) ORTHANC_OVERRIDE
cb5d75143da0 Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
144 {
cb5d75143da0 Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
145 return false;
cb5d75143da0 Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2966
diff changeset
146 }
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
147 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
148
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
149
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
150 class DummyInstancesJob : public SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
151 {
2842
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
152 private:
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
153 bool trailingStepDone_;
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
154
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
155 protected:
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2872
diff changeset
156 virtual bool HandleInstance(const std::string& instance) ORTHANC_OVERRIDE
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
157 {
2657
5eea2f11e8df JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2656
diff changeset
158 return (instance != "nope");
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
159 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
160
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2872
diff changeset
161 virtual bool HandleTrailingStep() ORTHANC_OVERRIDE
2842
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
162 {
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
163 if (HasTrailingStep())
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
164 {
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
165 if (trailingStepDone_)
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
166 {
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
167 throw OrthancException(ErrorCode_InternalError);
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
168 }
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
169 else
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
170 {
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
171 trailingStepDone_ = true;
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
172 return true;
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
173 }
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
174 }
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
175 else
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
176 {
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
177 throw OrthancException(ErrorCode_InternalError);
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
178 }
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
179 }
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
180
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
181 public:
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2853
diff changeset
182 DummyInstancesJob() :
2842
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
183 trailingStepDone_(false)
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
184 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
185 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
186
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
187 DummyInstancesJob(const Json::Value& value) :
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
188 SetOfInstancesJob(value)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
189 {
2842
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
190 if (HasTrailingStep())
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
191 {
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2853
diff changeset
192 trailingStepDone_ = (GetPosition() == GetCommandsCount());
2842
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
193 }
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
194 else
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
195 {
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
196 trailingStepDone_ = false;
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
197 }
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
198 }
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
199
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
200 bool IsTrailingStepDone() const
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
201 {
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
202 return trailingStepDone_;
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
203 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
204
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2872
diff changeset
205 virtual void Stop(JobStopReason reason) ORTHANC_OVERRIDE
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
206 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
207 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
208
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2872
diff changeset
209 virtual void GetJobType(std::string& s) ORTHANC_OVERRIDE
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
210 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
211 s = "DummyInstancesJob";
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
212 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
213 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
214
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
215
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
216 class DummyUnserializer : public GenericJobUnserializer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
217 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
218 public:
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2872
diff changeset
219 virtual IJob* UnserializeJob(const Json::Value& value) ORTHANC_OVERRIDE
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
220 {
2656
a6d3e45eeff5 SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
221 if (SerializationToolbox::ReadString(value, "Type") == "DummyInstancesJob")
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
222 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
223 return new DummyInstancesJob(value);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
224 }
2667
5fa2f2ce74f0 serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2666
diff changeset
225 else if (SerializationToolbox::ReadString(value, "Type") == "DummyJob")
5fa2f2ce74f0 serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2666
diff changeset
226 {
5fa2f2ce74f0 serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2666
diff changeset
227 return new DummyJob;
5fa2f2ce74f0 serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2666
diff changeset
228 }
2652
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
229 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
230 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
231 return GenericJobUnserializer::UnserializeJob(value);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
232 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
233 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
234 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
235
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2651
diff changeset
236
1396
ac4efabeb80c Migration of the orthanc-client as a separate project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
237 class DynamicInteger : public IDynamicObject
723
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 {
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 private:
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 int value_;
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 std::set<int>& target_;
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 public:
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 DynamicInteger(int value, std::set<int>& target) :
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 value_(value), target_(target)
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 {
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 }
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 int GetValue() const
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 {
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 return value_;
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 }
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 };
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 }
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255
0da078f3affc multithreading tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256
2621
83ac5a05ce84 primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2610
diff changeset
257 TEST(JobsEngine, DISABLED_Lua)
2600
140a539b4eba SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2599
diff changeset
258 {
2950
dc18d5804746 support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2924
diff changeset
259 JobsEngine engine(10);
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
260 engine.SetThreadSleep(10);
2600
140a539b4eba SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2599
diff changeset
261 engine.SetWorkersCount(2);
140a539b4eba SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2599
diff changeset
262 engine.Start();
140a539b4eba SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2599
diff changeset
263
2604
76ef12fa136c fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
264 LuaJobManager lua;
2600
140a539b4eba SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2599
diff changeset
265 lua.SetMaxOperationsPerJob(5);
140a539b4eba SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2599
diff changeset
266 lua.SetTrailingOperationTimeout(200);
140a539b4eba SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2599
diff changeset
267
140a539b4eba SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2599
diff changeset
268 for (size_t i = 0; i < 30; i++)
140a539b4eba SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2599
diff changeset
269 {
140a539b4eba SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2599
diff changeset
270 boost::this_thread::sleep(boost::posix_time::milliseconds(150));
2604
76ef12fa136c fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
271
76ef12fa136c fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
272 LuaJobManager::Lock lock(lua, engine);
76ef12fa136c fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
273 size_t a = lock.AddLogOperation();
76ef12fa136c fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
274 size_t b = lock.AddLogOperation();
2606
f2b9d3256060 SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2604
diff changeset
275 size_t c = lock.AddSystemCallOperation("echo");
2604
76ef12fa136c fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
276 lock.AddStringInput(a, boost::lexical_cast<std::string>(i));
76ef12fa136c fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
277 lock.AddNullInput(a);
76ef12fa136c fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2603
diff changeset
278 lock.Connect(a, b);
2606
f2b9d3256060 SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2604
diff changeset
279 lock.Connect(a, c);
2600
140a539b4eba SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2599
diff changeset
280 }
140a539b4eba SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2599
diff changeset
281
140a539b4eba SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2599
diff changeset
282 boost::this_thread::sleep(boost::posix_time::milliseconds(2000));
140a539b4eba SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2599
diff changeset
283
140a539b4eba SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2599
diff changeset
284 engine.Stop();
2651
1da5a052c777 testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2648
diff changeset
285 }
2600
140a539b4eba SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2599
diff changeset
286
2651
1da5a052c777 testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2648
diff changeset
287
2666
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
288 static bool CheckSameJson(const Json::Value& a,
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
289 const Json::Value& b)
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
290 {
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
291 std::string s = a.toStyledString();
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
292 std::string t = b.toStyledString();
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
293
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
294 if (s == t)
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
295 {
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
296 return true;
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
297 }
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
298 else
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
299 {
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
300 LOG(ERROR) << "Expected serialization: " << s;
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
301 LOG(ERROR) << "Actual serialization: " << t;
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
302 return false;
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
303 }
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
304 }
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
305
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
306
2842
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
307 static bool CheckIdempotentSetOfInstances(IJobUnserializer& unserializer,
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
308 SetOfInstancesJob& job)
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
309 {
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
310 Json::Value a = 42;
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
311
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
312 if (!job.Serialize(a))
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
313 {
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
314 return false;
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
315 }
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
316 else
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
317 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
318 std::unique_ptr<SetOfInstancesJob> unserialized
2842
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
319 (dynamic_cast<SetOfInstancesJob*>(unserializer.UnserializeJob(a)));
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
320
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
321 Json::Value b = 43;
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
322 if (unserialized->Serialize(b))
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
323 {
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
324 return (CheckSameJson(a, b) &&
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
325 job.HasTrailingStep() == unserialized->HasTrailingStep() &&
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
326 job.GetPosition() == unserialized->GetPosition() &&
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
327 job.GetInstancesCount() == unserialized->GetInstancesCount() &&
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2853
diff changeset
328 job.GetCommandsCount() == unserialized->GetCommandsCount());
2666
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
329 }
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
330 else
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
331 {
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
332 return false;
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
333 }
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
334 }
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
335 }
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
336
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
337
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
338 static bool CheckIdempotentSerialization(IJobUnserializer& unserializer,
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
339 IJobOperation& operation)
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
340 {
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
341 Json::Value a = 42;
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
342 operation.Serialize(a);
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
343
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
344 std::unique_ptr<IJobOperation> unserialized(unserializer.UnserializeOperation(a));
2666
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
345
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
346 Json::Value b = 43;
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
347 unserialized->Serialize(b);
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
348
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
349 return CheckSameJson(a, b);
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
350 }
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
351
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
352
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
353 static bool CheckIdempotentSerialization(IJobUnserializer& unserializer,
4310
2ae905070221 renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
354 IJobOperationValue& value)
2666
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
355 {
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
356 Json::Value a = 42;
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
357 value.Serialize(a);
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
358
4310
2ae905070221 renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
359 std::unique_ptr<IJobOperationValue> unserialized(unserializer.UnserializeValue(a));
2666
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
360
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
361 Json::Value b = 43;
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
362 unserialized->Serialize(b);
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
363
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
364 return CheckSameJson(a, b);
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
365 }
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
366
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
367
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
368 TEST(JobsSerialization, GenericOperations)
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
369 {
2666
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
370 DummyUnserializer unserializer;
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
371 Json::Value s;
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
372
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
373 {
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
374 LogJobOperation operation;
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
375
2666
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
376 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, operation));
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
377 operation.Serialize(s);
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
378 }
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
379
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
380 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException);
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
381 ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException);
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
382
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
383 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
384 std::unique_ptr<IJobOperation> operation;
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
385 operation.reset(unserializer.UnserializeOperation(s));
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
386
2657
5eea2f11e8df JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2656
diff changeset
387 // Make sure that we have indeed unserialized a log operation
2731
fe4fe52f0c94 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2730
diff changeset
388 Json::Value dummy;
fe4fe52f0c94 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2730
diff changeset
389 ASSERT_THROW(dynamic_cast<DeleteResourceOperation&>(*operation).Serialize(dummy), std::bad_cast);
fe4fe52f0c94 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2730
diff changeset
390 dynamic_cast<LogJobOperation&>(*operation).Serialize(dummy);
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
391 }
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
392 }
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
393
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
394
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
395 TEST(JobsSerialization, DicomInstanceOrigin)
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
396 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
397 Json::Value s;
2726
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
398 std::string t;
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
399
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
400 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
401 DicomInstanceOrigin origin;
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
402
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
403 s = 42;
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
404 origin.Serialize(s);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
405 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
406
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
407 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
408 DicomInstanceOrigin origin(s);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
409 ASSERT_EQ(RequestOrigin_Unknown, origin.GetRequestOrigin());
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
410 ASSERT_EQ("", std::string(origin.GetRemoteAetC()));
2726
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
411 ASSERT_FALSE(origin.LookupRemoteIp(t));
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
412 ASSERT_FALSE(origin.LookupRemoteAet(t));
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
413 ASSERT_FALSE(origin.LookupCalledAet(t));
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
414 ASSERT_FALSE(origin.LookupHttpUsername(t));
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
415 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
416
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
417 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
418 DicomInstanceOrigin origin(DicomInstanceOrigin::FromDicomProtocol("host", "aet", "called"));
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
419
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
420 s = 42;
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
421 origin.Serialize(s);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
422 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
423
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
424 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
425 DicomInstanceOrigin origin(s);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
426 ASSERT_EQ(RequestOrigin_DicomProtocol, origin.GetRequestOrigin());
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
427 ASSERT_EQ("aet", std::string(origin.GetRemoteAetC()));
2726
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
428 ASSERT_TRUE(origin.LookupRemoteIp(t)); ASSERT_EQ("host", t);
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
429 ASSERT_TRUE(origin.LookupRemoteAet(t)); ASSERT_EQ("aet", t);
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
430 ASSERT_TRUE(origin.LookupCalledAet(t)); ASSERT_EQ("called", t);
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
431 ASSERT_FALSE(origin.LookupHttpUsername(t));
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
432 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
433
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
434 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
435 DicomInstanceOrigin origin(DicomInstanceOrigin::FromHttp("host", "username"));
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
436
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
437 s = 42;
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
438 origin.Serialize(s);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
439 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
440
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
441 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
442 DicomInstanceOrigin origin(s);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
443 ASSERT_EQ(RequestOrigin_RestApi, origin.GetRequestOrigin());
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
444 ASSERT_EQ("", std::string(origin.GetRemoteAetC()));
2726
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
445 ASSERT_TRUE(origin.LookupRemoteIp(t)); ASSERT_EQ("host", t);
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
446 ASSERT_FALSE(origin.LookupRemoteAet(t));
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
447 ASSERT_FALSE(origin.LookupCalledAet(t));
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
448 ASSERT_TRUE(origin.LookupHttpUsername(t)); ASSERT_EQ("username", t);
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
449 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
450
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
451 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
452 DicomInstanceOrigin origin(DicomInstanceOrigin::FromLua());
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
453
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
454 s = 42;
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
455 origin.Serialize(s);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
456 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
457
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
458 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
459 DicomInstanceOrigin origin(s);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
460 ASSERT_EQ(RequestOrigin_Lua, origin.GetRequestOrigin());
2726
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
461 ASSERT_FALSE(origin.LookupRemoteIp(t));
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
462 ASSERT_FALSE(origin.LookupRemoteAet(t));
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
463 ASSERT_FALSE(origin.LookupCalledAet(t));
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
464 ASSERT_FALSE(origin.LookupHttpUsername(t));
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
465 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
466
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
467 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
468 DicomInstanceOrigin origin(DicomInstanceOrigin::FromPlugins());
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
469
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
470 s = 42;
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
471 origin.Serialize(s);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
472 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
473
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
474 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
475 DicomInstanceOrigin origin(s);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
476 ASSERT_EQ(RequestOrigin_Plugins, origin.GetRequestOrigin());
2726
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
477 ASSERT_FALSE(origin.LookupRemoteIp(t));
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
478 ASSERT_FALSE(origin.LookupRemoteAet(t));
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
479 ASSERT_FALSE(origin.LookupCalledAet(t));
46061a91c88a new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2715
diff changeset
480 ASSERT_FALSE(origin.LookupHttpUsername(t));
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
481 }
4245
c70df925151e RequestOrigin_WebDav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4177
diff changeset
482
c70df925151e RequestOrigin_WebDav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4177
diff changeset
483 {
c70df925151e RequestOrigin_WebDav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4177
diff changeset
484 DicomInstanceOrigin origin(DicomInstanceOrigin::FromWebDav());
c70df925151e RequestOrigin_WebDav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4177
diff changeset
485
c70df925151e RequestOrigin_WebDav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4177
diff changeset
486 s = 42;
c70df925151e RequestOrigin_WebDav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4177
diff changeset
487 origin.Serialize(s);
c70df925151e RequestOrigin_WebDav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4177
diff changeset
488 }
c70df925151e RequestOrigin_WebDav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4177
diff changeset
489
c70df925151e RequestOrigin_WebDav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4177
diff changeset
490 {
c70df925151e RequestOrigin_WebDav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4177
diff changeset
491 DicomInstanceOrigin origin(s);
c70df925151e RequestOrigin_WebDav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4177
diff changeset
492 ASSERT_EQ(RequestOrigin_WebDav, origin.GetRequestOrigin());
c70df925151e RequestOrigin_WebDav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4177
diff changeset
493 ASSERT_EQ("", std::string(origin.GetRemoteAetC()));
c70df925151e RequestOrigin_WebDav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4177
diff changeset
494 ASSERT_FALSE(origin.LookupRemoteIp(t));
c70df925151e RequestOrigin_WebDav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4177
diff changeset
495 ASSERT_FALSE(origin.LookupRemoteAet(t));
c70df925151e RequestOrigin_WebDav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4177
diff changeset
496 ASSERT_FALSE(origin.LookupCalledAet(t));
c70df925151e RequestOrigin_WebDav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4177
diff changeset
497 ASSERT_FALSE(origin.LookupHttpUsername(t));
c70df925151e RequestOrigin_WebDav
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4177
diff changeset
498 }
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
499 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
500
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
501
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
502 namespace
2651
1da5a052c777 testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2648
diff changeset
503 {
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
504 class OrthancJobsSerialization : public testing::Test
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
505 {
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
506 private:
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
507 MemoryStorageArea storage_;
3017
517fc4767ae0 renamed class DatabaseWrapper as SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2976
diff changeset
508 SQLiteDatabaseWrapper db_; // The SQLite DB is in memory
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
509 std::unique_ptr<ServerContext> context_;
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
510
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
511 public:
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
512 OrthancJobsSerialization()
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
513 {
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
514 db_.Open();
2950
dc18d5804746 support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2924
diff changeset
515 context_.reset(new ServerContext(db_, storage_, true /* running unit tests */, 10));
2815
925d8dc03a23 unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2812
diff changeset
516 context_->SetupJobsEngine(true, false);
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
517 }
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
518
2924
22524fd06225 macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2872
diff changeset
519 virtual ~OrthancJobsSerialization() ORTHANC_OVERRIDE
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
520 {
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
521 context_->Stop();
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
522 context_.reset(NULL);
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
523 db_.Close();
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
524 }
2651
1da5a052c777 testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2648
diff changeset
525
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
526 ServerContext& GetContext()
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
527 {
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
528 return *context_;
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
529 }
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
530
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
531 bool CreateInstance(std::string& id)
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
532 {
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
533 // Create a sample DICOM file
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
534 ParsedDicomFile dicom(true);
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
535 dicom.Replace(DICOM_TAG_PATIENT_NAME, std::string("JODOGNE"),
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
536 false, DicomReplaceMode_InsertIfAbsent, "");
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
537
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
538 std::unique_ptr<DicomInstanceToStore> toStore(DicomInstanceToStore::CreateFromParsedDicomFile(dicom));
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
539
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
540 return (context_->Store(id, *toStore, StoreInstanceMode_Default) == StoreStatus_Success);
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
541 }
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
542 };
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
543 }
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
544
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
545
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
546 TEST_F(OrthancJobsSerialization, Values)
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
547 {
2651
1da5a052c777 testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2648
diff changeset
548 std::string id;
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
549 ASSERT_TRUE(CreateInstance(id));
2651
1da5a052c777 testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2648
diff changeset
550
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
551 Json::Value s;
2666
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
552 OrthancJobUnserializer unserializer(GetContext());
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
553
2651
1da5a052c777 testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2648
diff changeset
554 {
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
555 DicomInstanceOperationValue instance(GetContext(), id);
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
556
2666
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
557 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, instance));
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
558 instance.Serialize(s);
2651
1da5a052c777 testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2648
diff changeset
559 }
1da5a052c777 testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2648
diff changeset
560
4310
2ae905070221 renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
561 std::unique_ptr<IJobOperationValue> value;
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
562 value.reset(unserializer.UnserializeValue(s));
4310
2ae905070221 renaming pure interface JobOperationValue as IJobOperationValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4304
diff changeset
563 ASSERT_EQ(IJobOperationValue::Type_DicomInstance, value->GetType());
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
564 ASSERT_EQ(id, dynamic_cast<DicomInstanceOperationValue&>(*value).GetId());
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
565
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
566 {
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
567 std::string content;
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
568 dynamic_cast<DicomInstanceOperationValue&>(*value).ReadDicom(content);
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
569
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
570 ParsedDicomFile dicom(content);
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
571 ASSERT_TRUE(dicom.GetTagValue(content, DICOM_TAG_PATIENT_NAME));
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
572 ASSERT_EQ("JODOGNE", content);
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
573 }
2651
1da5a052c777 testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2648
diff changeset
574 }
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
575
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
576
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
577 TEST_F(OrthancJobsSerialization, Operations)
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
578 {
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
579 std::string id;
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
580 ASSERT_TRUE(CreateInstance(id));
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
581
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
582 Json::Value s;
2666
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
583 OrthancJobUnserializer unserializer(GetContext());
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
584
2659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
585 // DeleteResourceOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
586
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
587 {
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
588 DeleteResourceOperation operation(GetContext());
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
589
2666
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
590 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, operation));
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
591 operation.Serialize(s);
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
592 }
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
593
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
594 std::unique_ptr<IJobOperation> operation;
2659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
595
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
596 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
597 operation.reset(unserializer.UnserializeOperation(s));
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
598
2731
fe4fe52f0c94 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2730
diff changeset
599 Json::Value dummy;
fe4fe52f0c94 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2730
diff changeset
600 ASSERT_THROW(dynamic_cast<LogJobOperation&>(*operation).Serialize(dummy), std::bad_cast);
fe4fe52f0c94 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2730
diff changeset
601 dynamic_cast<DeleteResourceOperation&>(*operation).Serialize(dummy);
2659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
602 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
603
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
604 // StorePeerOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
605
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
606 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
607 WebServiceParameters peer;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
608 peer.SetUrl("http://localhost/");
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2731
diff changeset
609 peer.SetCredentials("username", "password");
2659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
610 peer.SetPkcs11Enabled(true);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
611
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
612 StorePeerOperation operation(peer);
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
613
2666
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
614 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, operation));
2659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
615 operation.Serialize(s);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
616 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
617
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
618 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
619 operation.reset(unserializer.UnserializeOperation(s));
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
620
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
621 const StorePeerOperation& tmp = dynamic_cast<StorePeerOperation&>(*operation);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
622 ASSERT_EQ("http://localhost/", tmp.GetPeer().GetUrl());
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
623 ASSERT_EQ("username", tmp.GetPeer().GetUsername());
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
624 ASSERT_EQ("password", tmp.GetPeer().GetPassword());
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
625 ASSERT_TRUE(tmp.GetPeer().IsPkcs11Enabled());
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
626 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
627
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
628 // StoreScuOperation
2658
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
629
2659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
630 {
3851
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3849
diff changeset
631 TimeoutDicomConnectionManager luaManager;
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3849
diff changeset
632
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3849
diff changeset
633 {
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3849
diff changeset
634 RemoteModalityParameters modality;
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3849
diff changeset
635 modality.SetApplicationEntityTitle("REMOTE");
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3849
diff changeset
636 modality.SetHost("192.168.1.1");
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3849
diff changeset
637 modality.SetPortNumber(1000);
4177
f0d81320f17f removed references to unused Manufacturer_StoreScp
Alain Mazy <alain@mazy.be>
parents: 4062
diff changeset
638 modality.SetManufacturer(ModalityManufacturer_GE);
2659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
639
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3878
diff changeset
640 StoreScuOperation operation(GetContext(), luaManager, "TEST", modality);
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
641
3851
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3849
diff changeset
642 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, operation));
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3849
diff changeset
643 operation.Serialize(s);
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3849
diff changeset
644 }
2659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
645
3851
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3849
diff changeset
646 {
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3849
diff changeset
647 operation.reset(unserializer.UnserializeOperation(s));
2659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
648
3851
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3849
diff changeset
649 const StoreScuOperation& tmp = dynamic_cast<StoreScuOperation&>(*operation);
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3849
diff changeset
650 ASSERT_EQ("REMOTE", tmp.GetRemoteModality().GetApplicationEntityTitle());
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3849
diff changeset
651 ASSERT_EQ("192.168.1.1", tmp.GetRemoteModality().GetHost());
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3849
diff changeset
652 ASSERT_EQ(1000, tmp.GetRemoteModality().GetPortNumber());
4177
f0d81320f17f removed references to unused Manufacturer_StoreScp
Alain Mazy <alain@mazy.be>
parents: 4062
diff changeset
653 ASSERT_EQ(ModalityManufacturer_GE, tmp.GetRemoteModality().GetManufacturer());
3851
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3849
diff changeset
654 ASSERT_EQ("TEST", tmp.GetLocalAet());
6498739a3c3c refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3849
diff changeset
655 }
2659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
656 }
2658
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
657
2659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
658 // SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
660 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
661 SystemCallOperation operation(std::string("echo"));
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
662 operation.AddPreArgument("a");
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
663 operation.AddPreArgument("b");
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
664 operation.AddPostArgument("c");
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
665
2666
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
666 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, operation));
2659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
667 operation.Serialize(s);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
668 }
2658
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
669
2659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
670 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
671 operation.reset(unserializer.UnserializeOperation(s));
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
672
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
673 const SystemCallOperation& tmp = dynamic_cast<SystemCallOperation&>(*operation);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
674 ASSERT_EQ("echo", tmp.GetCommand());
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
675 ASSERT_EQ(2u, tmp.GetPreArgumentsCount());
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
676 ASSERT_EQ(1u, tmp.GetPostArgumentsCount());
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
677 ASSERT_EQ("a", tmp.GetPreArgument(0));
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
678 ASSERT_EQ("b", tmp.GetPreArgument(1));
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
679 ASSERT_EQ("c", tmp.GetPostArgument(0));
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
680 }
2658
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
681
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2660
diff changeset
682 // ModifyInstanceOperation
2659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
683
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
684 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
685 std::unique_ptr<DicomModification> modification(new DicomModification);
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2660
diff changeset
686 modification->SetupAnonymization(DicomVersion_2008);
2659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
687
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
688 ModifyInstanceOperation operation(GetContext(), RequestOrigin_Lua, modification.release());
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
689
2666
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
690 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, operation));
2659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
691 operation.Serialize(s);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
692 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
694 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
695 operation.reset(unserializer.UnserializeOperation(s));
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
696
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
697 const ModifyInstanceOperation& tmp = dynamic_cast<ModifyInstanceOperation&>(*operation);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2658
diff changeset
698 ASSERT_EQ(RequestOrigin_Lua, tmp.GetRequestOrigin());
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2660
diff changeset
699 ASSERT_TRUE(tmp.GetModification().IsRemoved(DICOM_TAG_STUDY_DESCRIPTION));
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2660
diff changeset
700 }
4678
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
701
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
702 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
703 std::unique_ptr<DicomModification> modification(new DicomModification);
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
704 modification->SetupAnonymization(DicomVersion_2021b);
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
705
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
706 ModifyInstanceOperation operation(GetContext(), RequestOrigin_Lua, modification.release());
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
707
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
708 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, operation));
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
709 operation.Serialize(s);
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
710 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
711
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
712 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
713 operation.reset(unserializer.UnserializeOperation(s));
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
714
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
715 const ModifyInstanceOperation& tmp = dynamic_cast<ModifyInstanceOperation&>(*operation);
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
716 ASSERT_EQ(RequestOrigin_Lua, tmp.GetRequestOrigin());
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
717 ASSERT_TRUE(tmp.GetModification().IsRemoved(DICOM_TAG_STUDY_DESCRIPTION));
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
718 }
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2653
diff changeset
719 }
2658
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
720
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
721
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
722 TEST_F(OrthancJobsSerialization, Jobs)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
723 {
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
724 Json::Value s;
2663
228e2783ce83 some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
725
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
726 // ArchiveJob
2663
228e2783ce83 some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
727
228e2783ce83 some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
728 {
2966
10c610e80b15 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2950
diff changeset
729 ArchiveJob job(GetContext(), false, false);
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
730 ASSERT_FALSE(job.Serialize(s)); // Cannot serialize this
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
731 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
732
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
733 // DicomModalityStoreJob
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
734
2666
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
735 OrthancJobUnserializer unserializer(GetContext());
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
736
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
737 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
738 RemoteModalityParameters modality;
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
739 modality.SetApplicationEntityTitle("REMOTE");
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
740 modality.SetHost("192.168.1.1");
2715
73bc0c32547c fix embedding openssl within a DLL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2671
diff changeset
741 modality.SetPortNumber(1000);
4177
f0d81320f17f removed references to unused Manufacturer_StoreScp
Alain Mazy <alain@mazy.be>
parents: 4062
diff changeset
742 modality.SetManufacturer(ModalityManufacturer_GE);
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
743
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
744 DicomModalityStoreJob job(GetContext());
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
745 job.SetLocalAet("LOCAL");
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
746 job.SetRemoteModality(modality);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
747 job.SetMoveOriginator("MOVESCU", 42);
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
748
2842
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
749 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job));
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
750 ASSERT_TRUE(job.Serialize(s));
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
751 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
752
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
753 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
754 std::unique_ptr<IJob> job;
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
755 job.reset(unserializer.UnserializeJob(s));
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
756
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
757 DicomModalityStoreJob& tmp = dynamic_cast<DicomModalityStoreJob&>(*job);
3875
ea1d32861cfc moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3857
diff changeset
758 ASSERT_EQ("LOCAL", tmp.GetParameters().GetLocalApplicationEntityTitle());
ea1d32861cfc moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3857
diff changeset
759 ASSERT_EQ("REMOTE", tmp.GetParameters().GetRemoteModality().GetApplicationEntityTitle());
ea1d32861cfc moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3857
diff changeset
760 ASSERT_EQ("192.168.1.1", tmp.GetParameters().GetRemoteModality().GetHost());
ea1d32861cfc moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3857
diff changeset
761 ASSERT_EQ(1000, tmp.GetParameters().GetRemoteModality().GetPortNumber());
4177
f0d81320f17f removed references to unused Manufacturer_StoreScp
Alain Mazy <alain@mazy.be>
parents: 4062
diff changeset
762 ASSERT_EQ(ModalityManufacturer_GE, tmp.GetParameters().GetRemoteModality().GetManufacturer());
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
763 ASSERT_TRUE(tmp.HasMoveOriginator());
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
764 ASSERT_EQ("MOVESCU", tmp.GetMoveOriginatorAet());
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
765 ASSERT_EQ(42, tmp.GetMoveOriginatorId());
2663
228e2783ce83 some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
766 }
2658
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
767
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
768 // OrthancPeerStoreJob
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
769
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
770 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
771 WebServiceParameters peer;
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
772 peer.SetUrl("http://localhost/");
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2731
diff changeset
773 peer.SetCredentials("username", "password");
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
774 peer.SetPkcs11Enabled(true);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
775
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
776 OrthancPeerStoreJob job(GetContext());
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
777 job.SetPeer(peer);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
778
2842
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
779 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job));
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
780 ASSERT_TRUE(job.Serialize(s));
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
781 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
782
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
783 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
784 std::unique_ptr<IJob> job;
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
785 job.reset(unserializer.UnserializeJob(s));
2658
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
786
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
787 OrthancPeerStoreJob& tmp = dynamic_cast<OrthancPeerStoreJob&>(*job);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
788 ASSERT_EQ("http://localhost/", tmp.GetPeer().GetUrl());
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
789 ASSERT_EQ("username", tmp.GetPeer().GetUsername());
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
790 ASSERT_EQ("password", tmp.GetPeer().GetPassword());
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
791 ASSERT_TRUE(tmp.GetPeer().IsPkcs11Enabled());
3949
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
792 ASSERT_FALSE(tmp.IsTranscode());
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
793 ASSERT_THROW(tmp.GetTransferSyntax(), OrthancException);
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
794 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
795
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
796 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
797 OrthancPeerStoreJob job(GetContext());
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
798 ASSERT_THROW(job.SetTranscode("nope"), OrthancException);
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
799 job.SetTranscode("1.2.840.10008.1.2.4.50");
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
800
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
801 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job));
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
802 ASSERT_TRUE(job.Serialize(s));
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
803 }
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
804
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
805 {
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
806 std::unique_ptr<IJob> job;
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
807 job.reset(unserializer.UnserializeJob(s));
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
808
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
809 OrthancPeerStoreJob& tmp = dynamic_cast<OrthancPeerStoreJob&>(*job);
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
810 ASSERT_EQ("http://127.0.0.1:8042/", tmp.GetPeer().GetUrl());
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
811 ASSERT_EQ("", tmp.GetPeer().GetUsername());
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
812 ASSERT_EQ("", tmp.GetPeer().GetPassword());
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
813 ASSERT_FALSE(tmp.GetPeer().IsPkcs11Enabled());
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
814 ASSERT_TRUE(tmp.IsTranscode());
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
815 ASSERT_EQ(DicomTransferSyntax_JPEGProcess1, tmp.GetTransferSyntax());
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
816 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
817
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
818 // ResourceModificationJob
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
819
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
820 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
821 std::unique_ptr<DicomModification> modification(new DicomModification);
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
822 modification->SetupAnonymization(DicomVersion_2008);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
823 modification->SetLevel(ResourceType_Series);
2658
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2657
diff changeset
824
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
825 ResourceModificationJob job(GetContext());
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
826 ASSERT_THROW(job.IsSingleResourceModification(), OrthancException);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
827 job.SetSingleResourceModification(modification.release(), ResourceType_Patient, true);
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
828 job.SetOrigin(DicomInstanceOrigin::FromLua());
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
829 ASSERT_TRUE(job.IsAnonymization());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
830 ASSERT_TRUE(job.IsSingleResourceModification());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
831 ASSERT_EQ(ResourceType_Patient, job.GetOutputLevel());
3942
5b882ad2ffd0 "/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
832
5b882ad2ffd0 "/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
833 job.AddTrailingStep(); // Necessary since 1.7.0
2842
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2815
diff changeset
834 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job));
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
835 ASSERT_TRUE(job.Serialize(s));
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
836 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
837
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
838 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
839 std::unique_ptr<IJob> job;
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
840 job.reset(unserializer.UnserializeJob(s));
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
841
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
842 ResourceModificationJob& tmp = dynamic_cast<ResourceModificationJob&>(*job);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
843 ASSERT_TRUE(tmp.IsAnonymization());
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
844 ASSERT_FALSE(tmp.IsTranscode());
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
845 ASSERT_THROW(tmp.GetTransferSyntax(), OrthancException);
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
846 ASSERT_EQ(RequestOrigin_Lua, tmp.GetOrigin().GetRequestOrigin());
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
847 ASSERT_TRUE(tmp.GetModification().IsRemoved(DICOM_TAG_STUDY_DESCRIPTION));
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
848 ASSERT_TRUE(tmp.IsSingleResourceModification());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
849 ASSERT_EQ(ResourceType_Patient, tmp.GetOutputLevel());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
850 ASSERT_EQ(ResourceType_Series, tmp.GetModification().GetLevel());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
851 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
852
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
853 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
854 // Backward compatibility with Orthanc 1.9.3
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
855 ASSERT_TRUE(s.isMember("OutputLevel"));
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
856 ASSERT_TRUE(s.isMember("IsSingleResource"));
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
857 s.removeMember("OutputLevel");
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
858 s.removeMember("IsSingleResource");
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
859
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
860 std::unique_ptr<IJob> job;
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
861 job.reset(unserializer.UnserializeJob(s));
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
862
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
863 ResourceModificationJob& tmp = dynamic_cast<ResourceModificationJob&>(*job);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
864 ASSERT_TRUE(tmp.IsSingleResourceModification());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
865 ASSERT_EQ(ResourceType_Series, tmp.GetOutputLevel()); // old, incorrect behavior
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
866 ASSERT_EQ(ResourceType_Series, tmp.GetModification().GetLevel());
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
867 }
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
868
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
869 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
870 ResourceModificationJob job(GetContext());
3949
ef696db8426f preparing transcoding in OrthancPeerStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
871 ASSERT_THROW(job.SetTranscode("nope"), OrthancException);
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
872 job.SetTranscode(DicomTransferSyntax_JPEGProcess1);
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
873 job.SetSingleResourceModification(new DicomModification, ResourceType_Study, false);
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
874
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
875 job.AddTrailingStep(); // Necessary since 1.7.0
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
876 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job));
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
877 ASSERT_TRUE(job.Serialize(s));
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
878 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
879
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
880 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
881 std::unique_ptr<IJob> job;
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
882 job.reset(unserializer.UnserializeJob(s));
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
883
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
884 ResourceModificationJob& tmp = dynamic_cast<ResourceModificationJob&>(*job);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
885 ASSERT_FALSE(tmp.IsAnonymization());
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
886 ASSERT_TRUE(tmp.IsTranscode());
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
887 ASSERT_EQ(DicomTransferSyntax_JPEGProcess1, tmp.GetTransferSyntax());
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
888 ASSERT_EQ(RequestOrigin_Unknown, tmp.GetOrigin().GetRequestOrigin());
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
889 ASSERT_TRUE(tmp.IsSingleResourceModification());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
890 ASSERT_EQ(ResourceType_Study, tmp.GetOutputLevel());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
891 ASSERT_EQ(ResourceType_Instance, tmp.GetModification().GetLevel());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
892 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
893
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
894 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
895 ResourceModificationJob job(GetContext());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
896 job.SetMultipleResourcesModification(new DicomModification, true);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
897 job.AddInstance("toto");
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
898 job.AddInstance("tutu");
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
899 job.AddTrailingStep(); // Necessary since 1.7.0
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
900 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job));
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
901 ASSERT_TRUE(job.Serialize(s));
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
902 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
903
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
904 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
905 std::unique_ptr<IJob> job;
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
906 job.reset(unserializer.UnserializeJob(s));
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
907
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
908 ResourceModificationJob& tmp = dynamic_cast<ResourceModificationJob&>(*job);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
909
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
910 std::set<std::string> instances;
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
911 for (size_t i = 0; i < tmp.GetInstancesCount(); i++)
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
912 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
913 instances.insert(tmp.GetInstance(i));
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
914 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
915
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
916 ASSERT_EQ(2u, instances.size());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
917 ASSERT_TRUE(instances.find("toto") != instances.end());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
918 ASSERT_TRUE(instances.find("tutu") != instances.end());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
919
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
920 ASSERT_TRUE(tmp.IsAnonymization());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
921 ASSERT_FALSE(tmp.IsSingleResourceModification());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
922 ASSERT_THROW(tmp.GetOutputLevel(), OrthancException);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
923 ASSERT_EQ(ResourceType_Instance, tmp.GetModification().GetLevel());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
924 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
925
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
926 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
927 // Test behavior on broken serialization
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
928 ASSERT_FALSE(s.isMember("OutputLevel"));
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
929 ASSERT_TRUE(s.isMember("IsSingleResource"));
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
930 s.removeMember("IsSingleResource");
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
931
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
932 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
933 std::unique_ptr<IJob> job;
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
934 job.reset(unserializer.UnserializeJob(s));
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
935
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
936 ResourceModificationJob& tmp = dynamic_cast<ResourceModificationJob&>(*job);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
937 ASSERT_TRUE(tmp.IsAnonymization());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
938 ASSERT_TRUE(tmp.IsSingleResourceModification());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
939 ASSERT_EQ(ResourceType_Patient, tmp.GetOutputLevel());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
940 ASSERT_EQ(ResourceType_Instance, tmp.GetModification().GetLevel());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
941 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
942
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
943 s["Modification"]["Level"] = "Series";
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
944
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
945 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
946 std::unique_ptr<IJob> job;
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
947 job.reset(unserializer.UnserializeJob(s));
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
948
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
949 ResourceModificationJob& tmp = dynamic_cast<ResourceModificationJob&>(*job);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
950 ASSERT_TRUE(tmp.IsAnonymization());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
951 ASSERT_TRUE(tmp.IsSingleResourceModification());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
952 ASSERT_EQ(ResourceType_Series, tmp.GetOutputLevel());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
953 ASSERT_EQ(ResourceType_Series, tmp.GetModification().GetLevel());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
954 }
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
955 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
956
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
957 // SplitStudyJob
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
958
2853
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
959 std::string instance;
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
960 ASSERT_TRUE(CreateInstance(instance));
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
961
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
962 std::string study, series;
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
963
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
964 {
2853
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
965 ServerContext::DicomCacheLocker lock(GetContext(), instance);
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
966 study = lock.GetDicom().GetHasher().HashStudy();
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
967 series = lock.GetDicom().GetHasher().HashSeries();
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
968 }
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
969
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
970 {
2853
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
971 std::list<std::string> tmp;
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
972 GetContext().GetIndex().GetAllUuids(tmp, ResourceType_Study);
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
973 ASSERT_EQ(1u, tmp.size());
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
974 ASSERT_EQ(study, tmp.front());
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
975 GetContext().GetIndex().GetAllUuids(tmp, ResourceType_Series);
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
976 ASSERT_EQ(1u, tmp.size());
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
977 ASSERT_EQ(series, tmp.front());
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
978 }
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
979
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
980 std::string study2;
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
981
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
982 {
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
983 std::string a, b;
2847
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
984
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
985 {
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
986 ASSERT_THROW(SplitStudyJob(GetContext(), std::string("nope")), OrthancException);
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
987
2847
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
988 SplitStudyJob job(GetContext(), study);
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
989 job.SetKeepSource(true);
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
990 job.AddSourceSeries(series);
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
991 ASSERT_THROW(job.AddSourceSeries("nope"), OrthancException);
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
992 job.SetOrigin(DicomInstanceOrigin::FromLua());
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
993 job.Replace(DICOM_TAG_PATIENT_NAME, "hello");
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
994 job.Remove(DICOM_TAG_PATIENT_BIRTH_DATE);
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
995 ASSERT_THROW(job.Replace(DICOM_TAG_SERIES_DESCRIPTION, "nope"), OrthancException);
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
996 ASSERT_THROW(job.Remove(DICOM_TAG_SERIES_DESCRIPTION), OrthancException);
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
997
2847
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
998 ASSERT_TRUE(job.GetTargetStudy().empty());
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
999 a = job.GetTargetStudyUid();
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1000 ASSERT_TRUE(job.LookupTargetSeriesUid(b, series));
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1001
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2853
diff changeset
1002 job.AddTrailingStep();
2847
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1003 job.Start();
3658
2d90dd30858c providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3641
diff changeset
1004 ASSERT_EQ(JobStepCode_Continue, job.Step("jobId").GetCode());
2d90dd30858c providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3641
diff changeset
1005 ASSERT_EQ(JobStepCode_Success, job.Step("jobId").GetCode());
2847
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1006
2853
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1007 study2 = job.GetTargetStudy();
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1008 ASSERT_FALSE(study2.empty());
2847
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1009
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1010 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job));
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1011 ASSERT_TRUE(job.Serialize(s));
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1012 }
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1013
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1014 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
1015 std::unique_ptr<IJob> job;
2847
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1016 job.reset(unserializer.UnserializeJob(s));
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
1017
2847
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1018 SplitStudyJob& tmp = dynamic_cast<SplitStudyJob&>(*job);
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1019 ASSERT_TRUE(tmp.IsKeepSource());
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1020 ASSERT_EQ(study, tmp.GetSourceStudy());
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1021 ASSERT_EQ(a, tmp.GetTargetStudyUid());
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1022 ASSERT_EQ(RequestOrigin_Lua, tmp.GetOrigin().GetRequestOrigin());
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
1023
2847
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1024 std::string s;
2853
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1025 ASSERT_EQ(study2, tmp.GetTargetStudy());
2847
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1026 ASSERT_FALSE(tmp.LookupTargetSeriesUid(s, "nope"));
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1027 ASSERT_TRUE(tmp.LookupTargetSeriesUid(s, series));
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1028 ASSERT_EQ(b, s);
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1029
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1030 ASSERT_FALSE(tmp.LookupReplacement(s, DICOM_TAG_STUDY_DESCRIPTION));
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1031 ASSERT_TRUE(tmp.LookupReplacement(s, DICOM_TAG_PATIENT_NAME));
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1032 ASSERT_EQ("hello", s);
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1033 ASSERT_FALSE(tmp.IsRemoved(DICOM_TAG_PATIENT_NAME));
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1034 ASSERT_TRUE(tmp.IsRemoved(DICOM_TAG_PATIENT_BIRTH_DATE));
2da68edacab6 unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2845
diff changeset
1035 }
2845
218e2c864d1d serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
1036 }
2853
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1037
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1038 {
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1039 std::list<std::string> tmp;
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1040 GetContext().GetIndex().GetAllUuids(tmp, ResourceType_Study);
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1041 ASSERT_EQ(2u, tmp.size());
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1042 GetContext().GetIndex().GetAllUuids(tmp, ResourceType_Series);
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1043 ASSERT_EQ(2u, tmp.size());
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1044 }
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1045
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1046 // MergeStudyJob
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1047
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1048 {
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1049 ASSERT_THROW(SplitStudyJob(GetContext(), std::string("nope")), OrthancException);
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1050
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1051 MergeStudyJob job(GetContext(), study);
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1052 job.SetKeepSource(true);
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1053 job.AddSource(study2);
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1054 ASSERT_THROW(job.AddSourceSeries("nope"), OrthancException);
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1055 ASSERT_THROW(job.AddSourceStudy("nope"), OrthancException);
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1056 ASSERT_THROW(job.AddSource("nope"), OrthancException);
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1057 job.SetOrigin(DicomInstanceOrigin::FromLua());
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1058
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1059 ASSERT_EQ(job.GetTargetStudy(), study);
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1060
2860
8b00e4cb4a6b SetOfCommandsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2853
diff changeset
1061 job.AddTrailingStep();
2853
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1062 job.Start();
3658
2d90dd30858c providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3641
diff changeset
1063 ASSERT_EQ(JobStepCode_Continue, job.Step("jobId").GetCode());
2d90dd30858c providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3641
diff changeset
1064 ASSERT_EQ(JobStepCode_Success, job.Step("jobId").GetCode());
2853
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1065
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1066 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job));
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1067 ASSERT_TRUE(job.Serialize(s));
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1068 }
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1069
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1070 {
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1071 std::list<std::string> tmp;
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1072 GetContext().GetIndex().GetAllUuids(tmp, ResourceType_Study);
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1073 ASSERT_EQ(2u, tmp.size());
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1074 GetContext().GetIndex().GetAllUuids(tmp, ResourceType_Series);
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1075 ASSERT_EQ(3u, tmp.size());
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1076 }
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1077
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1078 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
1079 std::unique_ptr<IJob> job;
2853
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1080 job.reset(unserializer.UnserializeJob(s));
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1081
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1082 MergeStudyJob& tmp = dynamic_cast<MergeStudyJob&>(*job);
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1083 ASSERT_TRUE(tmp.IsKeepSource());
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1084 ASSERT_EQ(study, tmp.GetTargetStudy());
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1085 ASSERT_EQ(RequestOrigin_Lua, tmp.GetOrigin().GetRequestOrigin());
52b017d22a4f New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2847
diff changeset
1086 }
2666
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2665
diff changeset
1087 }
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
1088
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
1089
3878
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1090
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1091 TEST_F(OrthancJobsSerialization, DicomAssociationParameters)
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1092 {
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1093 Json::Value v;
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1094
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1095 {
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1096 v = Json::objectValue;
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1097 DicomAssociationParameters p;
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1098 p.SerializeJob(v);
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1099 }
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1100
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1101 {
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1102 DicomAssociationParameters p = DicomAssociationParameters::UnserializeJob(v);
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1103 ASSERT_EQ("ORTHANC", p.GetLocalApplicationEntityTitle());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1104 ASSERT_EQ("ANY-SCP", p.GetRemoteModality().GetApplicationEntityTitle());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1105 ASSERT_EQ(104u, p.GetRemoteModality().GetPortNumber());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1106 ASSERT_EQ(ModalityManufacturer_Generic, p.GetRemoteModality().GetManufacturer());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1107 ASSERT_EQ("127.0.0.1", p.GetRemoteModality().GetHost());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1108 ASSERT_EQ(DicomAssociationParameters::GetDefaultTimeout(), p.GetTimeout());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1109 }
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1110
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1111 {
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1112 v = Json::objectValue;
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1113 DicomAssociationParameters p;
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1114 p.SetLocalApplicationEntityTitle("HELLO");
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1115 p.SetRemoteApplicationEntityTitle("WORLD");
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1116 p.SetRemotePort(42);
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1117 p.SetRemoteHost("MY_HOST");
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1118 p.SetTimeout(43);
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1119 p.SerializeJob(v);
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1120 }
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1121
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1122 {
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1123 DicomAssociationParameters p = DicomAssociationParameters::UnserializeJob(v);
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1124 ASSERT_EQ("HELLO", p.GetLocalApplicationEntityTitle());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1125 ASSERT_EQ("WORLD", p.GetRemoteModality().GetApplicationEntityTitle());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1126 ASSERT_EQ(42u, p.GetRemoteModality().GetPortNumber());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1127 ASSERT_EQ(ModalityManufacturer_Generic, p.GetRemoteModality().GetManufacturer());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1128 ASSERT_EQ("MY_HOST", p.GetRemoteModality().GetHost());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1129 ASSERT_EQ(43u, p.GetTimeout());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1130 }
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1131
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1132 {
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1133 DicomModalityStoreJob job(GetContext());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1134 job.Serialize(v);
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1135 }
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1136
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1137 {
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1138 OrthancJobUnserializer unserializer(GetContext());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1139 std::unique_ptr<DicomModalityStoreJob> job(
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1140 dynamic_cast<DicomModalityStoreJob*>(unserializer.UnserializeJob(v)));
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1141 ASSERT_EQ("ORTHANC", job->GetParameters().GetLocalApplicationEntityTitle());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1142 ASSERT_EQ("ANY-SCP", job->GetParameters().GetRemoteModality().GetApplicationEntityTitle());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1143 ASSERT_EQ("127.0.0.1", job->GetParameters().GetRemoteModality().GetHost());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1144 ASSERT_EQ(104u, job->GetParameters().GetRemoteModality().GetPortNumber());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1145 ASSERT_EQ(ModalityManufacturer_Generic, job->GetParameters().GetRemoteModality().GetManufacturer());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1146 ASSERT_EQ(DicomAssociationParameters::GetDefaultTimeout(), job->GetParameters().GetTimeout());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1147 ASSERT_FALSE(job->HasMoveOriginator());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1148 ASSERT_THROW(job->GetMoveOriginatorAet(), OrthancException);
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1149 ASSERT_THROW(job->GetMoveOriginatorId(), OrthancException);
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1150 ASSERT_FALSE(job->HasStorageCommitment());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1151 }
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1152
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1153 {
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1154 RemoteModalityParameters r;
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1155 r.SetApplicationEntityTitle("HELLO");
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1156 r.SetPortNumber(42);
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1157 r.SetHost("MY_HOST");
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1158
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1159 DicomModalityStoreJob job(GetContext());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1160 job.SetLocalAet("WORLD");
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1161 job.SetRemoteModality(r);
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1162 job.SetTimeout(43);
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1163 job.SetMoveOriginator("ORIGINATOR", 100);
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1164 job.EnableStorageCommitment(true);
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1165 job.Serialize(v);
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1166 }
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1167
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1168 {
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1169 OrthancJobUnserializer unserializer(GetContext());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1170 std::unique_ptr<DicomModalityStoreJob> job(
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1171 dynamic_cast<DicomModalityStoreJob*>(unserializer.UnserializeJob(v)));
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1172 ASSERT_EQ("WORLD", job->GetParameters().GetLocalApplicationEntityTitle());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1173 ASSERT_EQ("HELLO", job->GetParameters().GetRemoteModality().GetApplicationEntityTitle());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1174 ASSERT_EQ("MY_HOST", job->GetParameters().GetRemoteModality().GetHost());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1175 ASSERT_EQ(42u, job->GetParameters().GetRemoteModality().GetPortNumber());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1176 ASSERT_EQ(ModalityManufacturer_Generic, job->GetParameters().GetRemoteModality().GetManufacturer());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1177 ASSERT_EQ(43u, job->GetParameters().GetTimeout());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1178 ASSERT_TRUE(job->HasMoveOriginator());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1179 ASSERT_EQ("ORIGINATOR", job->GetMoveOriginatorAet());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1180 ASSERT_EQ(100, job->GetMoveOriginatorId());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1181 ASSERT_TRUE(job->HasStorageCommitment());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1182 }
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1183
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1184 {
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1185 DicomMoveScuJob job(GetContext());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1186 job.Serialize(v);
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1187 }
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1188
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1189 {
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1190 OrthancJobUnserializer unserializer(GetContext());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1191 std::unique_ptr<DicomMoveScuJob> job(
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1192 dynamic_cast<DicomMoveScuJob*>(unserializer.UnserializeJob(v)));
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1193 ASSERT_EQ("ORTHANC", job->GetParameters().GetLocalApplicationEntityTitle());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1194 ASSERT_EQ("ANY-SCP", job->GetParameters().GetRemoteModality().GetApplicationEntityTitle());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1195 ASSERT_EQ("127.0.0.1", job->GetParameters().GetRemoteModality().GetHost());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1196 ASSERT_EQ(104u, job->GetParameters().GetRemoteModality().GetPortNumber());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1197 ASSERT_EQ(ModalityManufacturer_Generic, job->GetParameters().GetRemoteModality().GetManufacturer());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1198 ASSERT_EQ(DicomAssociationParameters::GetDefaultTimeout(), job->GetParameters().GetTimeout());
4730
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1199 ASSERT_EQ(DicomToJsonFormat_Short, job->GetQueryFormat());
3878
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1200 }
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1201
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1202 {
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1203 RemoteModalityParameters r;
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1204 r.SetApplicationEntityTitle("HELLO");
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1205 r.SetPortNumber(42);
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1206 r.SetHost("MY_HOST");
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1207
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1208 DicomMoveScuJob job(GetContext());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1209 job.SetLocalAet("WORLD");
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1210 job.SetRemoteModality(r);
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1211 job.SetTimeout(43);
4730
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1212 job.SetQueryFormat(DicomToJsonFormat_Human);
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1213
3878
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1214 job.Serialize(v);
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1215 }
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1216
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1217 {
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1218 OrthancJobUnserializer unserializer(GetContext());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1219 std::unique_ptr<DicomMoveScuJob> job(
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1220 dynamic_cast<DicomMoveScuJob*>(unserializer.UnserializeJob(v)));
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1221 ASSERT_EQ("WORLD", job->GetParameters().GetLocalApplicationEntityTitle());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1222 ASSERT_EQ("HELLO", job->GetParameters().GetRemoteModality().GetApplicationEntityTitle());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1223 ASSERT_EQ("MY_HOST", job->GetParameters().GetRemoteModality().GetHost());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1224 ASSERT_EQ(42u, job->GetParameters().GetRemoteModality().GetPortNumber());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1225 ASSERT_EQ(ModalityManufacturer_Generic, job->GetParameters().GetRemoteModality().GetManufacturer());
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1226 ASSERT_EQ(43u, job->GetParameters().GetTimeout());
4730
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1227 ASSERT_EQ(DicomToJsonFormat_Human, job->GetQueryFormat());
3878
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1228 }
661c931f22ad new unit test: OrthancJobsSerialization.DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1229 }
4730
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1230
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1231
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1232 TEST_F(OrthancJobsSerialization, DicomMoveScuJob)
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1233 {
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1234 Json::Value command = Json::objectValue;
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1235 command["0008,0005"]["Type"] = "String";
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1236 command["0008,0005"]["Content"] = "ISO_IR 100";
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1237 command["0010,0020"]["Type"] = "String";
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1238 command["0010,0020"]["Content"] = "1234";
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1239
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1240 Json::Value query = Json::objectValue;
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1241 query["0010,0020"] = "456";
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1242 query["0008,0052"] = "STUDY";
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1243
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1244 Json::Value remote = Json::objectValue;
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1245 remote["AET"] = "REMOTE";
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1246 remote["Host"] = "192.168.1.1";
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1247 remote["Port"] = 4242;
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1248
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1249 Json::Value s = Json::objectValue;
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1250 s["Permissive"] = true;
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1251 s["Position"] = 1;
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1252 s["Description"] = "test";
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1253 s["Remote"] = remote;
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1254 s["LocalAet"] = "LOCAL";
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1255 s["TargetAet"] = "TARGET";
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1256 s["QueryFormat"] = "Full";
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1257 s["Query"] = Json::arrayValue;
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1258 s["Query"].append(query);
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1259 s["Commands"] = Json::arrayValue;
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1260 s["Commands"].append(command);
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1261
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1262 Json::Value s2;
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1263
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1264 {
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1265 DicomMoveScuJob job(GetContext(), s);
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1266 job.Serialize(s2);
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1267 }
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1268
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1269 {
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1270 DicomMoveScuJob job(GetContext(), s2);
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1271 ASSERT_EQ("TARGET", job.GetTargetAet());
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1272 ASSERT_EQ("LOCAL", job.GetParameters().GetLocalApplicationEntityTitle());
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1273 ASSERT_EQ("REMOTE", job.GetParameters().GetRemoteModality().GetApplicationEntityTitle());
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1274 ASSERT_EQ("192.168.1.1", job.GetParameters().GetRemoteModality().GetHost());
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1275 ASSERT_EQ(4242u, job.GetParameters().GetRemoteModality().GetPortNumber());
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1276 ASSERT_EQ("test", job.GetDescription());
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1277 ASSERT_TRUE(job.IsPermissive());
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1278 ASSERT_EQ(1u, job.GetPosition());
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1279 ASSERT_EQ(1u, job.GetCommandsCount());
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1280 ASSERT_EQ(DicomToJsonFormat_Full, job.GetQueryFormat());
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1281 ASSERT_EQ(1u, s2["Commands"].size());
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1282 ASSERT_EQ(command.toStyledString(), s2["Commands"][0].toStyledString());
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1283 ASSERT_EQ(1u, s2["Query"].size());
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1284 ASSERT_EQ(query.toStyledString(), s2["Query"][0].toStyledString());
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1285 }
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
1286 }