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