Mercurial > hg > orthanc
annotate UnitTestsSources/MultiThreadingTests.cpp @ 2899:5dd649de253d
POST-ing a DICOM file to "/instances" also answers the patient/study/series ID
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 18 Oct 2018 12:03:51 +0200 |
parents | 9d08edde614b |
children | 22524fd06225 |
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 |
2447
878b59270859
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
6 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
8 * modify it under the terms of the GNU General Public License as |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
9 * published by the Free Software Foundation, either version 3 of the |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
10 * License, or (at your option) any later version. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
11 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
12 * In addition, as a special exception, the copyright holders of this |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
13 * program give permission to link the code of its release with the |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
15 * that use the same license as the "OpenSSL" library), and distribute |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
16 * the linked executables. You must obey the GNU General Public License |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
17 * in all respects for all of the code used other than "OpenSSL". If you |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
18 * modify file(s) with this exception, you may extend this exception to |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
19 * your version of the file(s), but you are not obligated to do so. If |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
20 * you do not wish to do so, delete this exception statement from your |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
21 * version. If you delete this exception statement from all source files |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
22 * in the program, then also delete it here. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
23 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
24 * This program is distributed in the hope that it will be useful, but |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
25 * WITHOUT ANY WARRANTY; without even the implied warranty of |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
27 * General Public License for more details. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
28 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
29 * You should have received a copy of the GNU General Public License |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
31 **/ |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
32 |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
33 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
827
diff
changeset
|
34 #include "PrecompiledHeadersUnitTests.h" |
723 | 35 #include "gtest/gtest.h" |
36 | |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
37 #include "../Core/FileStorage/MemoryStorageArea.h" |
2569 | 38 #include "../Core/JobsEngine/JobsEngine.h" |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
39 #include "../Core/Logging.h" |
2610
3ff4c50647ea
moving the old scheduler to the graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2606
diff
changeset
|
40 #include "../Core/MultiThreading/SharedMessageQueue.h" |
723 | 41 #include "../Core/OrthancException.h" |
2656
a6d3e45eeff5
SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2655
diff
changeset
|
42 #include "../Core/SerializationToolbox.h" |
2143
fd5875662670
creation of namespace SystemToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
43 #include "../Core/SystemToolbox.h" |
723 | 44 #include "../Core/Toolbox.h" |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
45 #include "../OrthancServer/DatabaseWrapper.h" |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
46 #include "../OrthancServer/ServerContext.h" |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
47 #include "../OrthancServer/ServerJobs/LuaJobManager.h" |
2655 | 48 #include "../OrthancServer/ServerJobs/OrthancJobUnserializer.h" |
49 | |
50 #include "../Core/JobsEngine/Operations/JobOperationValues.h" | |
51 #include "../Core/JobsEngine/Operations/NullOperationValue.h" | |
52 #include "../Core/JobsEngine/Operations/StringOperationValue.h" | |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
53 #include "../OrthancServer/ServerJobs/Operations/DicomInstanceOperationValue.h" |
2655 | 54 |
55 #include "../Core/JobsEngine/Operations/LogJobOperation.h" | |
56 #include "../OrthancServer/ServerJobs/Operations/DeleteResourceOperation.h" | |
57 #include "../OrthancServer/ServerJobs/Operations/ModifyInstanceOperation.h" | |
58 #include "../OrthancServer/ServerJobs/Operations/StorePeerOperation.h" | |
59 #include "../OrthancServer/ServerJobs/Operations/StoreScuOperation.h" | |
60 #include "../OrthancServer/ServerJobs/Operations/SystemCallOperation.h" | |
61 | |
2663
228e2783ce83
some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2662
diff
changeset
|
62 #include "../OrthancServer/ServerJobs/ArchiveJob.h" |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
63 #include "../OrthancServer/ServerJobs/DicomModalityStoreJob.h" |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
64 #include "../OrthancServer/ServerJobs/MergeStudyJob.h" |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
65 #include "../OrthancServer/ServerJobs/OrthancPeerStoreJob.h" |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
66 #include "../OrthancServer/ServerJobs/ResourceModificationJob.h" |
2845
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
67 #include "../OrthancServer/ServerJobs/SplitStudyJob.h" |
2655 | 68 |
723 | 69 |
70 using namespace Orthanc; | |
71 | |
72 namespace | |
73 { | |
2652 | 74 class DummyJob : public IJob |
75 { | |
76 private: | |
77 bool fails_; | |
78 unsigned int count_; | |
79 unsigned int steps_; | |
80 | |
81 public: | |
82 DummyJob() : | |
83 fails_(false), | |
84 count_(0), | |
85 steps_(4) | |
86 { | |
87 } | |
88 | |
89 explicit DummyJob(bool fails) : | |
90 fails_(fails), | |
91 count_(0), | |
92 steps_(4) | |
93 { | |
94 } | |
95 | |
96 virtual void Start() | |
97 { | |
98 } | |
99 | |
2812
ea7aea6f6a95
improved naming of methods in IJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2811
diff
changeset
|
100 virtual void Reset() |
2652 | 101 { |
102 } | |
103 | |
2812
ea7aea6f6a95
improved naming of methods in IJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2811
diff
changeset
|
104 virtual JobStepResult Step() |
2652 | 105 { |
106 if (fails_) | |
107 { | |
108 return JobStepResult::Failure(ErrorCode_ParameterOutOfRange); | |
109 } | |
110 else if (count_ == steps_ - 1) | |
111 { | |
112 return JobStepResult::Success(); | |
113 } | |
114 else | |
115 { | |
116 count_++; | |
117 return JobStepResult::Continue(); | |
118 } | |
119 } | |
120 | |
2812
ea7aea6f6a95
improved naming of methods in IJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2811
diff
changeset
|
121 virtual void Stop(JobStopReason reason) |
2652 | 122 { |
123 } | |
124 | |
125 virtual float GetProgress() | |
126 { | |
127 return static_cast<float>(count_) / static_cast<float>(steps_ - 1); | |
128 } | |
129 | |
130 virtual void GetJobType(std::string& type) | |
131 { | |
132 type = "DummyJob"; | |
133 } | |
134 | |
2663
228e2783ce83
some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2662
diff
changeset
|
135 virtual bool Serialize(Json::Value& value) |
2652 | 136 { |
2667
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
137 value = Json::objectValue; |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
138 value["Type"] = "DummyJob"; |
2663
228e2783ce83
some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2662
diff
changeset
|
139 return true; |
2652 | 140 } |
141 | |
142 virtual void GetPublicContent(Json::Value& value) | |
143 { | |
144 value["hello"] = "world"; | |
145 } | |
146 }; | |
147 | |
148 | |
149 class DummyInstancesJob : public SetOfInstancesJob | |
150 { | |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
151 private: |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
152 bool trailingStepDone_; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
153 |
2652 | 154 protected: |
155 virtual bool HandleInstance(const std::string& instance) | |
156 { | |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
157 return (instance != "nope"); |
2652 | 158 } |
159 | |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
160 virtual bool HandleTrailingStep() |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
161 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
162 if (HasTrailingStep()) |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
163 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
164 if (trailingStepDone_) |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
165 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
166 throw OrthancException(ErrorCode_InternalError); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
167 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
168 else |
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 trailingStepDone_ = true; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
171 return true; |
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 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
174 else |
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 throw OrthancException(ErrorCode_InternalError); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
177 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
178 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
179 |
2652 | 180 public: |
2860 | 181 DummyInstancesJob() : |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
182 trailingStepDone_(false) |
2652 | 183 { |
184 } | |
185 | |
186 DummyInstancesJob(const Json::Value& value) : | |
187 SetOfInstancesJob(value) | |
188 { | |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
189 if (HasTrailingStep()) |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
190 { |
2860 | 191 trailingStepDone_ = (GetPosition() == GetCommandsCount()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
192 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
193 else |
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 trailingStepDone_ = false; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
196 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
197 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
198 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
199 bool IsTrailingStepDone() const |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
200 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
201 return trailingStepDone_; |
2652 | 202 } |
203 | |
2812
ea7aea6f6a95
improved naming of methods in IJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2811
diff
changeset
|
204 virtual void Stop(JobStopReason reason) |
2652 | 205 { |
206 } | |
207 | |
208 virtual void GetJobType(std::string& s) | |
209 { | |
210 s = "DummyInstancesJob"; | |
211 } | |
212 }; | |
213 | |
214 | |
215 class DummyUnserializer : public GenericJobUnserializer | |
216 { | |
217 public: | |
218 virtual IJob* UnserializeJob(const Json::Value& value) | |
219 { | |
2656
a6d3e45eeff5
SerializationToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2655
diff
changeset
|
220 if (SerializationToolbox::ReadString(value, "Type") == "DummyInstancesJob") |
2652 | 221 { |
222 return new DummyInstancesJob(value); | |
223 } | |
2667
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
224 else if (SerializationToolbox::ReadString(value, "Type") == "DummyJob") |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
225 { |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
226 return new DummyJob; |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
227 } |
2652 | 228 else |
229 { | |
230 return GenericJobUnserializer::UnserializeJob(value); | |
231 } | |
232 } | |
233 }; | |
234 | |
235 | |
1396
ac4efabeb80c
Migration of the orthanc-client as a separate project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1304
diff
changeset
|
236 class DynamicInteger : public IDynamicObject |
723 | 237 { |
238 private: | |
239 int value_; | |
240 std::set<int>& target_; | |
241 | |
242 public: | |
243 DynamicInteger(int value, std::set<int>& target) : | |
244 value_(value), target_(target) | |
245 { | |
246 } | |
247 | |
248 int GetValue() const | |
249 { | |
250 return value_; | |
251 } | |
252 }; | |
253 } | |
254 | |
255 | |
256 TEST(MultiThreading, SharedMessageQueueBasic) | |
257 { | |
258 std::set<int> s; | |
259 | |
260 SharedMessageQueue q; | |
261 ASSERT_TRUE(q.WaitEmpty(0)); | |
262 q.Enqueue(new DynamicInteger(10, s)); | |
263 ASSERT_FALSE(q.WaitEmpty(1)); | |
264 q.Enqueue(new DynamicInteger(20, s)); | |
265 q.Enqueue(new DynamicInteger(30, s)); | |
266 q.Enqueue(new DynamicInteger(40, s)); | |
267 | |
268 std::auto_ptr<DynamicInteger> i; | |
269 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(10, i->GetValue()); | |
270 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(20, i->GetValue()); | |
271 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(30, i->GetValue()); | |
272 ASSERT_FALSE(q.WaitEmpty(1)); | |
273 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(40, i->GetValue()); | |
274 ASSERT_TRUE(q.WaitEmpty(0)); | |
275 ASSERT_EQ(NULL, q.Dequeue(1)); | |
276 } | |
277 | |
278 | |
279 TEST(MultiThreading, SharedMessageQueueClean) | |
280 { | |
281 std::set<int> s; | |
282 | |
283 try | |
284 { | |
285 SharedMessageQueue q; | |
286 q.Enqueue(new DynamicInteger(10, s)); | |
287 q.Enqueue(new DynamicInteger(20, s)); | |
1583
9ea3d082b064
got rid of custom exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
288 throw OrthancException(ErrorCode_InternalError); |
723 | 289 } |
290 catch (OrthancException&) | |
291 { | |
292 } | |
293 } | |
294 | |
295 | |
769
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
296 |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
297 |
2652 | 298 static bool CheckState(JobsRegistry& registry, |
299 const std::string& id, | |
300 JobState state) | |
2557 | 301 { |
2652 | 302 JobState s; |
2558 | 303 if (registry.GetState(s, id)) |
2557 | 304 { |
305 return state == s; | |
306 } | |
307 else | |
308 { | |
309 return false; | |
310 } | |
311 } | |
312 | |
313 | |
2652 | 314 static bool CheckErrorCode(JobsRegistry& registry, |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
315 const std::string& id, |
2652 | 316 ErrorCode code) |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
317 { |
2652 | 318 JobInfo s; |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
319 if (registry.GetJobInfo(s, id)) |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
320 { |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
321 return code == s.GetStatus().GetErrorCode(); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
322 } |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
323 else |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
324 { |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
325 return false; |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
326 } |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
327 } |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
328 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
329 |
2558 | 330 TEST(JobsRegistry, Priority) |
2557 | 331 { |
2558 | 332 JobsRegistry registry; |
2557 | 333 |
334 std::string i1, i2, i3, i4; | |
2558 | 335 registry.Submit(i1, new DummyJob(), 10); |
336 registry.Submit(i2, new DummyJob(), 30); | |
337 registry.Submit(i3, new DummyJob(), 20); | |
338 registry.Submit(i4, new DummyJob(), 5); | |
2557 | 339 |
2558 | 340 registry.SetMaxCompletedJobs(2); |
2557 | 341 |
342 std::set<std::string> id; | |
2558 | 343 registry.ListJobs(id); |
2557 | 344 |
345 ASSERT_EQ(4u, id.size()); | |
346 ASSERT_TRUE(id.find(i1) != id.end()); | |
347 ASSERT_TRUE(id.find(i2) != id.end()); | |
348 ASSERT_TRUE(id.find(i3) != id.end()); | |
349 ASSERT_TRUE(id.find(i4) != id.end()); | |
350 | |
2652 | 351 ASSERT_TRUE(CheckState(registry, i2, JobState_Pending)); |
2557 | 352 |
353 { | |
2558 | 354 JobsRegistry::RunningJob job(registry, 0); |
2557 | 355 ASSERT_TRUE(job.IsValid()); |
356 ASSERT_EQ(30, job.GetPriority()); | |
357 ASSERT_EQ(i2, job.GetId()); | |
358 | |
2652 | 359 ASSERT_TRUE(CheckState(registry, i2, JobState_Running)); |
2557 | 360 } |
361 | |
2652 | 362 ASSERT_TRUE(CheckState(registry, i2, JobState_Failure)); |
363 ASSERT_TRUE(CheckState(registry, i3, JobState_Pending)); | |
2557 | 364 |
365 { | |
2558 | 366 JobsRegistry::RunningJob job(registry, 0); |
2557 | 367 ASSERT_TRUE(job.IsValid()); |
368 ASSERT_EQ(20, job.GetPriority()); | |
369 ASSERT_EQ(i3, job.GetId()); | |
370 | |
371 job.MarkSuccess(); | |
372 | |
2652 | 373 ASSERT_TRUE(CheckState(registry, i3, JobState_Running)); |
2557 | 374 } |
375 | |
2652 | 376 ASSERT_TRUE(CheckState(registry, i3, JobState_Success)); |
2557 | 377 |
378 { | |
2558 | 379 JobsRegistry::RunningJob job(registry, 0); |
2557 | 380 ASSERT_TRUE(job.IsValid()); |
381 ASSERT_EQ(10, job.GetPriority()); | |
382 ASSERT_EQ(i1, job.GetId()); | |
383 } | |
384 | |
385 { | |
2558 | 386 JobsRegistry::RunningJob job(registry, 0); |
2557 | 387 ASSERT_TRUE(job.IsValid()); |
388 ASSERT_EQ(5, job.GetPriority()); | |
389 ASSERT_EQ(i4, job.GetId()); | |
390 } | |
391 | |
392 { | |
2558 | 393 JobsRegistry::RunningJob job(registry, 1); |
2557 | 394 ASSERT_FALSE(job.IsValid()); |
395 } | |
396 | |
2652 | 397 JobState s; |
2558 | 398 ASSERT_TRUE(registry.GetState(s, i1)); |
399 ASSERT_FALSE(registry.GetState(s, i2)); // Removed because oldest | |
400 ASSERT_FALSE(registry.GetState(s, i3)); // Removed because second oldest | |
401 ASSERT_TRUE(registry.GetState(s, i4)); | |
2557 | 402 |
2558 | 403 registry.SetMaxCompletedJobs(1); // (*) |
404 ASSERT_FALSE(registry.GetState(s, i1)); // Just discarded by (*) | |
405 ASSERT_TRUE(registry.GetState(s, i4)); | |
2557 | 406 } |
407 | |
408 | |
2558 | 409 TEST(JobsRegistry, Simultaneous) |
2557 | 410 { |
2558 | 411 JobsRegistry registry; |
412 | |
413 std::string i1, i2; | |
414 registry.Submit(i1, new DummyJob(), 20); | |
415 registry.Submit(i2, new DummyJob(), 10); | |
416 | |
2652 | 417 ASSERT_TRUE(CheckState(registry, i1, JobState_Pending)); |
418 ASSERT_TRUE(CheckState(registry, i2, JobState_Pending)); | |
2558 | 419 |
420 { | |
421 JobsRegistry::RunningJob job1(registry, 0); | |
422 JobsRegistry::RunningJob job2(registry, 0); | |
423 | |
424 ASSERT_TRUE(job1.IsValid()); | |
425 ASSERT_TRUE(job2.IsValid()); | |
426 | |
427 job1.MarkFailure(); | |
428 job2.MarkSuccess(); | |
429 | |
2652 | 430 ASSERT_TRUE(CheckState(registry, i1, JobState_Running)); |
431 ASSERT_TRUE(CheckState(registry, i2, JobState_Running)); | |
2558 | 432 } |
433 | |
2652 | 434 ASSERT_TRUE(CheckState(registry, i1, JobState_Failure)); |
435 ASSERT_TRUE(CheckState(registry, i2, JobState_Success)); | |
2558 | 436 } |
437 | |
438 | |
439 TEST(JobsRegistry, Resubmit) | |
440 { | |
441 JobsRegistry registry; | |
2557 | 442 |
443 std::string id; | |
2558 | 444 registry.Submit(id, new DummyJob(), 10); |
2557 | 445 |
2652 | 446 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2557 | 447 |
2558 | 448 registry.Resubmit(id); |
2652 | 449 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2557 | 450 |
451 { | |
2558 | 452 JobsRegistry::RunningJob job(registry, 0); |
2557 | 453 ASSERT_TRUE(job.IsValid()); |
454 job.MarkFailure(); | |
455 | |
2652 | 456 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2557 | 457 |
2558 | 458 registry.Resubmit(id); |
2652 | 459 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2557 | 460 } |
461 | |
2652 | 462 ASSERT_TRUE(CheckState(registry, id, JobState_Failure)); |
2557 | 463 |
2558 | 464 registry.Resubmit(id); |
2652 | 465 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2557 | 466 |
467 { | |
2558 | 468 JobsRegistry::RunningJob job(registry, 0); |
2557 | 469 ASSERT_TRUE(job.IsValid()); |
470 ASSERT_EQ(id, job.GetId()); | |
471 | |
472 job.MarkSuccess(); | |
2652 | 473 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2558 | 474 } |
475 | |
2652 | 476 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2558 | 477 |
478 registry.Resubmit(id); | |
2652 | 479 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2558 | 480 } |
481 | |
482 | |
483 TEST(JobsRegistry, Retry) | |
484 { | |
485 JobsRegistry registry; | |
486 | |
487 std::string id; | |
488 registry.Submit(id, new DummyJob(), 10); | |
489 | |
2652 | 490 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 491 |
492 { | |
493 JobsRegistry::RunningJob job(registry, 0); | |
494 ASSERT_TRUE(job.IsValid()); | |
495 job.MarkRetry(0); | |
496 | |
2652 | 497 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2558 | 498 } |
499 | |
2652 | 500 ASSERT_TRUE(CheckState(registry, id, JobState_Retry)); |
2558 | 501 |
502 registry.Resubmit(id); | |
2652 | 503 ASSERT_TRUE(CheckState(registry, id, JobState_Retry)); |
2558 | 504 |
505 registry.ScheduleRetries(); | |
2652 | 506 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 507 |
508 { | |
509 JobsRegistry::RunningJob job(registry, 0); | |
510 ASSERT_TRUE(job.IsValid()); | |
511 job.MarkSuccess(); | |
512 | |
2652 | 513 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2557 | 514 } |
515 | |
2652 | 516 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2558 | 517 } |
518 | |
519 | |
520 TEST(JobsRegistry, PausePending) | |
521 { | |
522 JobsRegistry registry; | |
523 | |
524 std::string id; | |
525 registry.Submit(id, new DummyJob(), 10); | |
526 | |
2652 | 527 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 528 |
529 registry.Pause(id); | |
2652 | 530 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2558 | 531 |
532 registry.Pause(id); | |
2652 | 533 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2558 | 534 |
535 registry.Resubmit(id); | |
2652 | 536 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2558 | 537 |
538 registry.Resume(id); | |
2652 | 539 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2557 | 540 } |
2558 | 541 |
542 | |
543 TEST(JobsRegistry, PauseRunning) | |
544 { | |
545 JobsRegistry registry; | |
546 | |
547 std::string id; | |
548 registry.Submit(id, new DummyJob(), 10); | |
549 | |
2652 | 550 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 551 |
552 { | |
553 JobsRegistry::RunningJob job(registry, 0); | |
554 ASSERT_TRUE(job.IsValid()); | |
555 | |
556 registry.Resubmit(id); | |
2562 | 557 job.MarkPause(); |
2652 | 558 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2558 | 559 } |
560 | |
2652 | 561 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2558 | 562 |
563 registry.Resubmit(id); | |
2652 | 564 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2558 | 565 |
566 registry.Resume(id); | |
2652 | 567 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 568 |
569 { | |
570 JobsRegistry::RunningJob job(registry, 0); | |
571 ASSERT_TRUE(job.IsValid()); | |
572 | |
573 job.MarkSuccess(); | |
2652 | 574 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2558 | 575 } |
576 | |
2652 | 577 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2558 | 578 } |
579 | |
580 | |
581 TEST(JobsRegistry, PauseRetry) | |
582 { | |
583 JobsRegistry registry; | |
584 | |
585 std::string id; | |
586 registry.Submit(id, new DummyJob(), 10); | |
587 | |
2652 | 588 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 589 |
590 { | |
591 JobsRegistry::RunningJob job(registry, 0); | |
592 ASSERT_TRUE(job.IsValid()); | |
593 | |
594 job.MarkRetry(0); | |
2652 | 595 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2558 | 596 } |
597 | |
2652 | 598 ASSERT_TRUE(CheckState(registry, id, JobState_Retry)); |
2558 | 599 |
600 registry.Pause(id); | |
2652 | 601 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2558 | 602 |
603 registry.Resume(id); | |
2652 | 604 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2558 | 605 |
606 { | |
607 JobsRegistry::RunningJob job(registry, 0); | |
608 ASSERT_TRUE(job.IsValid()); | |
609 | |
610 job.MarkSuccess(); | |
2652 | 611 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2558 | 612 } |
613 | |
2652 | 614 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2558 | 615 } |
2565 | 616 |
617 | |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
618 TEST(JobsRegistry, Cancel) |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
619 { |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
620 JobsRegistry registry; |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
621 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
622 std::string id; |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
623 registry.Submit(id, new DummyJob(), 10); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
624 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
625 ASSERT_FALSE(registry.Cancel("nope")); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
626 |
2652 | 627 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
628 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
629 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
630 ASSERT_TRUE(registry.Cancel(id)); |
2652 | 631 ASSERT_TRUE(CheckState(registry, id, JobState_Failure)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
632 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
633 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
634 ASSERT_TRUE(registry.Cancel(id)); |
2652 | 635 ASSERT_TRUE(CheckState(registry, id, JobState_Failure)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
636 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
637 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
638 ASSERT_TRUE(registry.Resubmit(id)); |
2652 | 639 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
640 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
641 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
642 { |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
643 JobsRegistry::RunningJob job(registry, 0); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
644 ASSERT_TRUE(job.IsValid()); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
645 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
646 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
647 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
648 job.MarkSuccess(); |
2652 | 649 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
650 } |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
651 |
2652 | 652 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
653 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
654 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
655 ASSERT_TRUE(registry.Cancel(id)); |
2652 | 656 ASSERT_TRUE(CheckState(registry, id, JobState_Success)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
657 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
658 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
659 registry.Submit(id, new DummyJob(), 10); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
660 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
661 { |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
662 JobsRegistry::RunningJob job(registry, 0); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
663 ASSERT_TRUE(job.IsValid()); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
664 ASSERT_EQ(id, job.GetId()); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
665 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
666 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
2652 | 667 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
668 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
669 job.MarkCanceled(); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
670 } |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
671 |
2652 | 672 ASSERT_TRUE(CheckState(registry, id, JobState_Failure)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
673 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
674 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
675 ASSERT_TRUE(registry.Resubmit(id)); |
2652 | 676 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
677 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
678 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
679 ASSERT_TRUE(registry.Pause(id)); |
2652 | 680 ASSERT_TRUE(CheckState(registry, id, JobState_Paused)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
681 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
682 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
683 ASSERT_TRUE(registry.Cancel(id)); |
2652 | 684 ASSERT_TRUE(CheckState(registry, id, JobState_Failure)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
685 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
686 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
687 ASSERT_TRUE(registry.Resubmit(id)); |
2652 | 688 ASSERT_TRUE(CheckState(registry, id, JobState_Pending)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
689 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
690 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
691 { |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
692 JobsRegistry::RunningJob job(registry, 0); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
693 ASSERT_TRUE(job.IsValid()); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
694 ASSERT_EQ(id, job.GetId()); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
695 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
696 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
2652 | 697 ASSERT_TRUE(CheckState(registry, id, JobState_Running)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
698 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
699 job.MarkRetry(500); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
700 } |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
701 |
2652 | 702 ASSERT_TRUE(CheckState(registry, id, JobState_Retry)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
703 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_Success)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
704 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
705 ASSERT_TRUE(registry.Cancel(id)); |
2652 | 706 ASSERT_TRUE(CheckState(registry, id, JobState_Failure)); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
707 ASSERT_TRUE(CheckErrorCode(registry, id, ErrorCode_CanceledJob)); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
708 } |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
709 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
710 |
2570
2e879c796ec7
JobsRegistry::SubmitAndWait(), StoreScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2569
diff
changeset
|
711 |
2599 | 712 TEST(JobsEngine, SubmitAndWait) |
2565 | 713 { |
714 JobsEngine engine; | |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
715 engine.SetThreadSleep(10); |
2565 | 716 engine.SetWorkersCount(3); |
717 engine.Start(); | |
718 | |
2867 | 719 Json::Value content = Json::nullValue; |
720 ASSERT_TRUE(engine.GetRegistry().SubmitAndWait(content, new DummyJob(), rand() % 10)); | |
721 ASSERT_EQ(Json::objectValue, content.type()); | |
722 ASSERT_EQ("world", content["hello"].asString()); | |
723 | |
724 content = Json::nullValue; | |
725 ASSERT_FALSE(engine.GetRegistry().SubmitAndWait(content, new DummyJob(true), rand() % 10)); | |
726 ASSERT_EQ(Json::nullValue, content.type()); | |
2599 | 727 |
728 engine.Stop(); | |
729 } | |
730 | |
731 | |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
732 TEST(JobsEngine, DISABLED_SequenceOfOperationsJob) |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
733 { |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
734 JobsEngine engine; |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
735 engine.SetThreadSleep(10); |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
736 engine.SetWorkersCount(3); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
737 engine.Start(); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
738 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
739 std::string id; |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
740 SequenceOfOperationsJob* job = NULL; |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
741 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
742 { |
2601 | 743 std::auto_ptr<SequenceOfOperationsJob> a(new SequenceOfOperationsJob); |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
744 job = a.get(); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
745 engine.GetRegistry().Submit(id, a.release(), 0); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
746 } |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
747 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
748 boost::this_thread::sleep(boost::posix_time::milliseconds(500)); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
749 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
750 { |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
751 SequenceOfOperationsJob::Lock lock(*job); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
752 size_t i = lock.AddOperation(new LogJobOperation); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
753 size_t j = lock.AddOperation(new LogJobOperation); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
754 size_t k = lock.AddOperation(new LogJobOperation); |
2730 | 755 |
756 StringOperationValue a("Hello"); | |
757 StringOperationValue b("World"); | |
758 lock.AddInput(i, a); | |
759 lock.AddInput(i, b); | |
760 | |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
761 lock.Connect(i, j); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
762 lock.Connect(j, k); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
763 } |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
764 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
765 boost::this_thread::sleep(boost::posix_time::milliseconds(2000)); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
766 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
767 engine.Stop(); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
768 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
769 } |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
770 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
771 |
2621
83ac5a05ce84
primitives for unserializing jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2610
diff
changeset
|
772 TEST(JobsEngine, DISABLED_Lua) |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
773 { |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
774 JobsEngine engine; |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
775 engine.SetThreadSleep(10); |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
776 engine.SetWorkersCount(2); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
777 engine.Start(); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
778 |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
779 LuaJobManager lua; |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
780 lua.SetMaxOperationsPerJob(5); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
781 lua.SetTrailingOperationTimeout(200); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
782 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
783 for (size_t i = 0; i < 30; i++) |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
784 { |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
785 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
|
786 |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
787 LuaJobManager::Lock lock(lua, engine); |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
788 size_t a = lock.AddLogOperation(); |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
789 size_t b = lock.AddLogOperation(); |
2606
f2b9d3256060
SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2604
diff
changeset
|
790 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
|
791 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
|
792 lock.AddNullInput(a); |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
793 lock.Connect(a, b); |
2606
f2b9d3256060
SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2604
diff
changeset
|
794 lock.Connect(a, c); |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
795 } |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
796 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
797 boost::this_thread::sleep(boost::posix_time::milliseconds(2000)); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
798 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
799 engine.Stop(); |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
800 } |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
801 |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
802 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
803 static bool CheckSameJson(const Json::Value& a, |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
804 const Json::Value& b) |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
805 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
806 std::string s = a.toStyledString(); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
807 std::string t = b.toStyledString(); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
808 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
809 if (s == t) |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
810 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
811 return true; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
812 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
813 else |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
814 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
815 LOG(ERROR) << "Expected serialization: " << s; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
816 LOG(ERROR) << "Actual serialization: " << t; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
817 return false; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
818 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
819 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
820 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
821 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
822 static bool CheckIdempotentSerialization(IJobUnserializer& unserializer, |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
823 IJob& job) |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
824 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
825 Json::Value a = 42; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
826 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
827 if (!job.Serialize(a)) |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
828 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
829 return false; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
830 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
831 else |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
832 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
833 std::auto_ptr<IJob> unserialized(unserializer.UnserializeJob(a)); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
834 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
835 Json::Value b = 43; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
836 if (unserialized->Serialize(b)) |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
837 { |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
838 return (CheckSameJson(a, b)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
839 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
840 else |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
841 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
842 return false; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
843 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
844 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
845 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
846 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
847 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
848 static bool CheckIdempotentSetOfInstances(IJobUnserializer& unserializer, |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
849 SetOfInstancesJob& job) |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
850 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
851 Json::Value a = 42; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
852 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
853 if (!job.Serialize(a)) |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
854 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
855 return false; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
856 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
857 else |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
858 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
859 std::auto_ptr<SetOfInstancesJob> unserialized |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
860 (dynamic_cast<SetOfInstancesJob*>(unserializer.UnserializeJob(a))); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
861 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
862 Json::Value b = 43; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
863 if (unserialized->Serialize(b)) |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
864 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
865 return (CheckSameJson(a, b) && |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
866 job.HasTrailingStep() == unserialized->HasTrailingStep() && |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
867 job.GetPosition() == unserialized->GetPosition() && |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
868 job.GetInstancesCount() == unserialized->GetInstancesCount() && |
2860 | 869 job.GetCommandsCount() == unserialized->GetCommandsCount()); |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
870 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
871 else |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
872 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
873 return false; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
874 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
875 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
876 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
877 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
878 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
879 static bool CheckIdempotentSerialization(IJobUnserializer& unserializer, |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
880 IJobOperation& operation) |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
881 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
882 Json::Value a = 42; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
883 operation.Serialize(a); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
884 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
885 std::auto_ptr<IJobOperation> unserialized(unserializer.UnserializeOperation(a)); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
886 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
887 Json::Value b = 43; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
888 unserialized->Serialize(b); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
889 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
890 return CheckSameJson(a, b); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
891 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
892 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
893 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
894 static bool CheckIdempotentSerialization(IJobUnserializer& unserializer, |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
895 JobOperationValue& value) |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
896 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
897 Json::Value a = 42; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
898 value.Serialize(a); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
899 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
900 std::auto_ptr<JobOperationValue> unserialized(unserializer.UnserializeValue(a)); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
901 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
902 Json::Value b = 43; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
903 unserialized->Serialize(b); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
904 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
905 return CheckSameJson(a, b); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
906 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
907 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
908 |
2655 | 909 TEST(JobsSerialization, BadFileFormat) |
910 { | |
911 GenericJobUnserializer unserializer; | |
912 | |
913 Json::Value s; | |
914 | |
915 s = Json::objectValue; | |
916 ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); | |
917 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); | |
918 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
919 | |
920 s = Json::arrayValue; | |
921 ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); | |
922 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); | |
923 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
924 | |
925 s = "hello"; | |
926 ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); | |
927 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); | |
928 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
929 | |
930 s = 42; | |
931 ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); | |
932 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); | |
933 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
934 } | |
935 | |
936 | |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
937 TEST(JobsSerialization, JobOperationValues) |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
938 { |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
939 Json::Value s; |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
940 |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
941 { |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
942 JobOperationValues values; |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
943 values.Append(new NullOperationValue); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
944 values.Append(new StringOperationValue("hello")); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
945 values.Append(new StringOperationValue("world")); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
946 |
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
947 s = 42; |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
948 values.Serialize(s); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
949 } |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
950 |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
951 { |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
952 GenericJobUnserializer unserializer; |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
953 std::auto_ptr<JobOperationValues> values(JobOperationValues::Unserialize(unserializer, s)); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
954 ASSERT_EQ(3u, values->GetSize()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
955 ASSERT_EQ(JobOperationValue::Type_Null, values->GetValue(0).GetType()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
956 ASSERT_EQ(JobOperationValue::Type_String, values->GetValue(1).GetType()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
957 ASSERT_EQ(JobOperationValue::Type_String, values->GetValue(2).GetType()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
958 |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
959 ASSERT_EQ("hello", dynamic_cast<const StringOperationValue&>(values->GetValue(1)).GetContent()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
960 ASSERT_EQ("world", dynamic_cast<const StringOperationValue&>(values->GetValue(2)).GetContent()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
961 } |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
962 } |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
963 |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
964 |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
965 TEST(JobsSerialization, GenericValues) |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
966 { |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
967 GenericJobUnserializer unserializer; |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
968 Json::Value s; |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
969 |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
970 { |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
971 NullOperationValue null; |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
972 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
973 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, null)); |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
974 null.Serialize(s); |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
975 } |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
976 |
2652 | 977 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); |
978 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
2655 | 979 |
980 std::auto_ptr<JobOperationValue> value; | |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
981 value.reset(unserializer.UnserializeValue(s)); |
2652 | 982 |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
983 ASSERT_EQ(JobOperationValue::Type_Null, value->GetType()); |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
984 |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
985 { |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
986 StringOperationValue str("Hello"); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
987 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
988 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, str)); |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
989 str.Serialize(s); |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
990 } |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
991 |
2652 | 992 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); |
993 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
994 value.reset(unserializer.UnserializeValue(s)); |
2652 | 995 |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
996 ASSERT_EQ(JobOperationValue::Type_String, value->GetType()); |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
997 ASSERT_EQ("Hello", dynamic_cast<StringOperationValue&>(*value).GetContent()); |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2599
diff
changeset
|
998 } |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
999 |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
1000 |
2655 | 1001 TEST(JobsSerialization, GenericOperations) |
1002 { | |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1003 DummyUnserializer unserializer; |
2655 | 1004 Json::Value s; |
1005 | |
1006 { | |
1007 LogJobOperation operation; | |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1008 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1009 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, operation)); |
2655 | 1010 operation.Serialize(s); |
1011 } | |
1012 | |
1013 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); | |
1014 ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); | |
1015 | |
1016 { | |
1017 std::auto_ptr<IJobOperation> operation; | |
1018 operation.reset(unserializer.UnserializeOperation(s)); | |
1019 | |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
1020 // Make sure that we have indeed unserialized a log operation |
2731 | 1021 Json::Value dummy; |
1022 ASSERT_THROW(dynamic_cast<DeleteResourceOperation&>(*operation).Serialize(dummy), std::bad_cast); | |
1023 dynamic_cast<LogJobOperation&>(*operation).Serialize(dummy); | |
2655 | 1024 } |
1025 } | |
1026 | |
1027 | |
1028 TEST(JobsSerialization, GenericJobs) | |
1029 { | |
2652 | 1030 Json::Value s; |
1031 | |
2658 | 1032 // This tests SetOfInstancesJob |
1033 | |
2652 | 1034 { |
2860 | 1035 DummyInstancesJob job; |
2652 | 1036 job.SetDescription("description"); |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
1037 job.AddInstance("hello"); |
2652 | 1038 job.AddInstance("nope"); |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
1039 job.AddInstance("world"); |
2652 | 1040 job.SetPermissive(true); |
2812
ea7aea6f6a95
improved naming of methods in IJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2811
diff
changeset
|
1041 ASSERT_THROW(job.Step(), OrthancException); // Not started yet |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1042 ASSERT_FALSE(job.HasTrailingStep()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1043 ASSERT_FALSE(job.IsTrailingStepDone()); |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
1044 job.Start(); |
2847
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1045 ASSERT_EQ(JobStepCode_Continue, job.Step().GetCode()); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1046 ASSERT_EQ(JobStepCode_Continue, job.Step().GetCode()); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1047 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1048 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1049 DummyUnserializer unserializer; |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1050 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1051 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1052 |
2663
228e2783ce83
some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2662
diff
changeset
|
1053 ASSERT_TRUE(job.Serialize(s)); |
2652 | 1054 } |
1055 | |
2655 | 1056 { |
1057 DummyUnserializer unserializer; | |
1058 ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); | |
1059 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | |
2652 | 1060 |
2655 | 1061 std::auto_ptr<IJob> job; |
1062 job.reset(unserializer.UnserializeJob(s)); | |
2657
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
1063 |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
1064 const DummyInstancesJob& tmp = dynamic_cast<const DummyInstancesJob&>(*job); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
1065 ASSERT_FALSE(tmp.IsStarted()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
1066 ASSERT_TRUE(tmp.IsPermissive()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
1067 ASSERT_EQ("description", tmp.GetDescription()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
1068 ASSERT_EQ(3u, tmp.GetInstancesCount()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
1069 ASSERT_EQ(2u, tmp.GetPosition()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
1070 ASSERT_EQ(1u, tmp.GetFailedInstances().size()); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
1071 ASSERT_EQ("hello", tmp.GetInstance(0)); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
1072 ASSERT_EQ("nope", tmp.GetInstance(1)); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
1073 ASSERT_EQ("world", tmp.GetInstance(2)); |
5eea2f11e8df
JobsSerialization.GenericJobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2656
diff
changeset
|
1074 ASSERT_TRUE(tmp.IsFailedInstance("nope")); |
2655 | 1075 } |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1076 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1077 // SequenceOfOperationsJob |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1078 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1079 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1080 SequenceOfOperationsJob job; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1081 job.SetDescription("hello"); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1082 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1083 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1084 SequenceOfOperationsJob::Lock lock(job); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1085 size_t a = lock.AddOperation(new LogJobOperation); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1086 size_t b = lock.AddOperation(new LogJobOperation); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1087 lock.Connect(a, b); |
2730 | 1088 |
1089 StringOperationValue s1("hello"); | |
1090 StringOperationValue s2("world"); | |
1091 lock.AddInput(a, s1); | |
1092 lock.AddInput(a, s2); | |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1093 lock.SetDicomAssociationTimeout(200); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1094 lock.SetTrailingOperationTimeout(300); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1095 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1096 |
2812
ea7aea6f6a95
improved naming of methods in IJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2811
diff
changeset
|
1097 ASSERT_EQ(JobStepCode_Continue, job.Step().GetCode()); |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1098 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1099 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1100 GenericJobUnserializer unserializer; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1101 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, job)); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1102 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1103 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1104 ASSERT_TRUE(job.Serialize(s)); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1105 } |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1106 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1107 { |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1108 GenericJobUnserializer unserializer; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1109 ASSERT_THROW(unserializer.UnserializeValue(s), OrthancException); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1110 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1111 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1112 std::auto_ptr<IJob> job; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1113 job.reset(unserializer.UnserializeJob(s)); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1114 |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1115 std::string tmp; |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1116 dynamic_cast<SequenceOfOperationsJob&>(*job).GetDescription(tmp); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1117 ASSERT_EQ("hello", tmp); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1118 } |
2658 | 1119 } |
1120 | |
1121 | |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1122 static bool IsSameTagValue(ParsedDicomFile& dicom1, |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1123 ParsedDicomFile& dicom2, |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1124 DicomTag tag) |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1125 { |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1126 std::string a, b; |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1127 return (dicom1.GetTagValue(a, tag) && |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1128 dicom2.GetTagValue(b, tag) && |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1129 (a == b)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1130 } |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1131 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1132 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1133 |
2660 | 1134 TEST(JobsSerialization, DicomModification) |
1135 { | |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1136 Json::Value s; |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1137 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1138 ParsedDicomFile source(true); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1139 source.Insert(DICOM_TAG_STUDY_DESCRIPTION, "Test 1", false); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1140 source.Insert(DICOM_TAG_SERIES_DESCRIPTION, "Test 2", false); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1141 source.Insert(DICOM_TAG_PATIENT_NAME, "Test 3", false); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1142 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1143 std::auto_ptr<ParsedDicomFile> modified(source.Clone(true)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1144 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1145 { |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1146 DicomModification modification; |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1147 modification.SetLevel(ResourceType_Series); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1148 modification.Clear(DICOM_TAG_STUDY_DESCRIPTION); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1149 modification.Remove(DICOM_TAG_SERIES_DESCRIPTION); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1150 modification.Replace(DICOM_TAG_PATIENT_NAME, "Test 4", true); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1151 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1152 modification.Apply(*modified); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1153 |
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1154 s = 42; |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1155 modification.Serialize(s); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1156 } |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1157 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1158 { |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1159 DicomModification modification(s); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1160 ASSERT_EQ(ResourceType_Series, modification.GetLevel()); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1161 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1162 std::auto_ptr<ParsedDicomFile> second(source.Clone(true)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1163 modification.Apply(*second); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1164 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1165 std::string s; |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1166 ASSERT_TRUE(second->GetTagValue(s, DICOM_TAG_STUDY_DESCRIPTION)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1167 ASSERT_TRUE(s.empty()); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1168 ASSERT_FALSE(second->GetTagValue(s, DICOM_TAG_SERIES_DESCRIPTION)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1169 ASSERT_TRUE(second->GetTagValue(s, DICOM_TAG_PATIENT_NAME)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1170 ASSERT_EQ("Test 4", s); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1171 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1172 ASSERT_TRUE(IsSameTagValue(source, *modified, DICOM_TAG_STUDY_INSTANCE_UID)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1173 ASSERT_TRUE(IsSameTagValue(source, *second, DICOM_TAG_STUDY_INSTANCE_UID)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1174 |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1175 ASSERT_FALSE(IsSameTagValue(source, *second, DICOM_TAG_SERIES_INSTANCE_UID)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1176 ASSERT_TRUE(IsSameTagValue(*modified, *second, DICOM_TAG_SERIES_INSTANCE_UID)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1177 } |
2660 | 1178 } |
1179 | |
1180 | |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1181 TEST(JobsSerialization, DicomInstanceOrigin) |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1182 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1183 Json::Value s; |
2726
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
1184 std::string t; |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1185 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1186 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1187 DicomInstanceOrigin origin; |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1188 |
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1189 s = 42; |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1190 origin.Serialize(s); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1191 } |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1192 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1193 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1194 DicomInstanceOrigin origin(s); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1195 ASSERT_EQ(RequestOrigin_Unknown, origin.GetRequestOrigin()); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1196 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
|
1197 ASSERT_FALSE(origin.LookupRemoteIp(t)); |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
1198 ASSERT_FALSE(origin.LookupRemoteAet(t)); |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
1199 ASSERT_FALSE(origin.LookupCalledAet(t)); |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
1200 ASSERT_FALSE(origin.LookupHttpUsername(t)); |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1201 } |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1202 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1203 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1204 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
|
1205 |
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1206 s = 42; |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1207 origin.Serialize(s); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1208 } |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1209 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1210 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1211 DicomInstanceOrigin origin(s); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1212 ASSERT_EQ(RequestOrigin_DicomProtocol, origin.GetRequestOrigin()); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1213 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
|
1214 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
|
1215 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
|
1216 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
|
1217 ASSERT_FALSE(origin.LookupHttpUsername(t)); |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1218 } |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1219 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1220 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1221 DicomInstanceOrigin origin(DicomInstanceOrigin::FromHttp("host", "username")); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1222 |
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1223 s = 42; |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1224 origin.Serialize(s); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1225 } |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1226 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1227 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1228 DicomInstanceOrigin origin(s); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1229 ASSERT_EQ(RequestOrigin_RestApi, origin.GetRequestOrigin()); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1230 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
|
1231 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
|
1232 ASSERT_FALSE(origin.LookupRemoteAet(t)); |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
1233 ASSERT_FALSE(origin.LookupCalledAet(t)); |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
1234 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
|
1235 } |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1236 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1237 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1238 DicomInstanceOrigin origin(DicomInstanceOrigin::FromLua()); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1239 |
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1240 s = 42; |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1241 origin.Serialize(s); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1242 } |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1243 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1244 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1245 DicomInstanceOrigin origin(s); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1246 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
|
1247 ASSERT_FALSE(origin.LookupRemoteIp(t)); |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
1248 ASSERT_FALSE(origin.LookupRemoteAet(t)); |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
1249 ASSERT_FALSE(origin.LookupCalledAet(t)); |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
1250 ASSERT_FALSE(origin.LookupHttpUsername(t)); |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1251 } |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1252 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1253 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1254 DicomInstanceOrigin origin(DicomInstanceOrigin::FromPlugins()); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1255 |
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1256 s = 42; |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1257 origin.Serialize(s); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1258 } |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1259 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1260 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1261 DicomInstanceOrigin origin(s); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1262 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
|
1263 ASSERT_FALSE(origin.LookupRemoteIp(t)); |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
1264 ASSERT_FALSE(origin.LookupRemoteAet(t)); |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
1265 ASSERT_FALSE(origin.LookupCalledAet(t)); |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
1266 ASSERT_FALSE(origin.LookupHttpUsername(t)); |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1267 } |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1268 } |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1269 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1270 |
2655 | 1271 namespace |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
1272 { |
2655 | 1273 class OrthancJobsSerialization : public testing::Test |
1274 { | |
1275 private: | |
1276 MemoryStorageArea storage_; | |
1277 DatabaseWrapper db_; // The SQLite DB is in memory | |
1278 std::auto_ptr<ServerContext> context_; | |
1279 TimeoutDicomConnectionManager manager_; | |
1280 | |
1281 public: | |
1282 OrthancJobsSerialization() | |
1283 { | |
1284 db_.Open(); | |
2815
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
1285 context_.reset(new ServerContext(db_, storage_, true /* running unit tests */)); |
925d8dc03a23
unserialization of jobs from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2812
diff
changeset
|
1286 context_->SetupJobsEngine(true, false); |
2655 | 1287 } |
1288 | |
1289 virtual ~OrthancJobsSerialization() | |
1290 { | |
1291 context_->Stop(); | |
1292 context_.reset(NULL); | |
1293 db_.Close(); | |
1294 } | |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
1295 |
2655 | 1296 ServerContext& GetContext() |
1297 { | |
1298 return *context_; | |
1299 } | |
1300 | |
1301 bool CreateInstance(std::string& id) | |
1302 { | |
1303 // Create a sample DICOM file | |
1304 ParsedDicomFile dicom(true); | |
1305 dicom.Replace(DICOM_TAG_PATIENT_NAME, std::string("JODOGNE"), | |
1306 false, DicomReplaceMode_InsertIfAbsent); | |
1307 | |
1308 DicomInstanceToStore toStore; | |
1309 toStore.SetParsedDicomFile(dicom); | |
1310 | |
1311 return (context_->Store(id, toStore) == StoreStatus_Success); | |
1312 } | |
1313 }; | |
1314 } | |
1315 | |
1316 | |
1317 TEST_F(OrthancJobsSerialization, Values) | |
1318 { | |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
1319 std::string id; |
2655 | 1320 ASSERT_TRUE(CreateInstance(id)); |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
1321 |
2655 | 1322 Json::Value s; |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1323 OrthancJobUnserializer unserializer(GetContext()); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1324 |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
1325 { |
2655 | 1326 DicomInstanceOperationValue instance(GetContext(), id); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1327 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1328 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, instance)); |
2655 | 1329 instance.Serialize(s); |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
1330 } |
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
1331 |
2655 | 1332 std::auto_ptr<JobOperationValue> value; |
1333 value.reset(unserializer.UnserializeValue(s)); | |
1334 ASSERT_EQ(JobOperationValue::Type_DicomInstance, value->GetType()); | |
1335 ASSERT_EQ(id, dynamic_cast<DicomInstanceOperationValue&>(*value).GetId()); | |
1336 | |
1337 { | |
1338 std::string content; | |
1339 dynamic_cast<DicomInstanceOperationValue&>(*value).ReadDicom(content); | |
1340 | |
1341 ParsedDicomFile dicom(content); | |
1342 ASSERT_TRUE(dicom.GetTagValue(content, DICOM_TAG_PATIENT_NAME)); | |
1343 ASSERT_EQ("JODOGNE", content); | |
1344 } | |
2651
1da5a052c777
testing value serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
1345 } |
2655 | 1346 |
1347 | |
1348 TEST_F(OrthancJobsSerialization, Operations) | |
1349 { | |
1350 std::string id; | |
1351 ASSERT_TRUE(CreateInstance(id)); | |
1352 | |
1353 Json::Value s; | |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1354 OrthancJobUnserializer unserializer(GetContext()); |
2655 | 1355 |
2659 | 1356 // DeleteResourceOperation |
1357 | |
2655 | 1358 { |
1359 DeleteResourceOperation operation(GetContext()); | |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1360 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1361 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, operation)); |
2655 | 1362 operation.Serialize(s); |
1363 } | |
1364 | |
1365 std::auto_ptr<IJobOperation> operation; | |
2659 | 1366 |
1367 { | |
1368 operation.reset(unserializer.UnserializeOperation(s)); | |
1369 | |
2731 | 1370 Json::Value dummy; |
1371 ASSERT_THROW(dynamic_cast<LogJobOperation&>(*operation).Serialize(dummy), std::bad_cast); | |
1372 dynamic_cast<DeleteResourceOperation&>(*operation).Serialize(dummy); | |
2659 | 1373 } |
1374 | |
1375 // StorePeerOperation | |
1376 | |
1377 { | |
1378 WebServiceParameters peer; | |
1379 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
|
1380 peer.SetCredentials("username", "password"); |
2659 | 1381 peer.SetPkcs11Enabled(true); |
1382 | |
1383 StorePeerOperation operation(peer); | |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1384 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1385 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, operation)); |
2659 | 1386 operation.Serialize(s); |
1387 } | |
1388 | |
1389 { | |
1390 operation.reset(unserializer.UnserializeOperation(s)); | |
1391 | |
1392 const StorePeerOperation& tmp = dynamic_cast<StorePeerOperation&>(*operation); | |
1393 ASSERT_EQ("http://localhost/", tmp.GetPeer().GetUrl()); | |
1394 ASSERT_EQ("username", tmp.GetPeer().GetUsername()); | |
1395 ASSERT_EQ("password", tmp.GetPeer().GetPassword()); | |
1396 ASSERT_TRUE(tmp.GetPeer().IsPkcs11Enabled()); | |
1397 } | |
1398 | |
1399 // StoreScuOperation | |
2658 | 1400 |
2659 | 1401 { |
1402 RemoteModalityParameters modality; | |
1403 modality.SetApplicationEntityTitle("REMOTE"); | |
1404 modality.SetHost("192.168.1.1"); | |
2715
73bc0c32547c
fix embedding openssl within a DLL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
1405 modality.SetPortNumber(1000); |
2659 | 1406 modality.SetManufacturer(ModalityManufacturer_StoreScp); |
1407 | |
1408 StoreScuOperation operation("TEST", modality); | |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1409 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1410 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, operation)); |
2659 | 1411 operation.Serialize(s); |
1412 } | |
1413 | |
1414 { | |
1415 operation.reset(unserializer.UnserializeOperation(s)); | |
1416 | |
1417 const StoreScuOperation& tmp = dynamic_cast<StoreScuOperation&>(*operation); | |
1418 ASSERT_EQ("REMOTE", tmp.GetRemoteModality().GetApplicationEntityTitle()); | |
1419 ASSERT_EQ("192.168.1.1", tmp.GetRemoteModality().GetHost()); | |
2715
73bc0c32547c
fix embedding openssl within a DLL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
1420 ASSERT_EQ(1000, tmp.GetRemoteModality().GetPortNumber()); |
2659 | 1421 ASSERT_EQ(ModalityManufacturer_StoreScp, tmp.GetRemoteModality().GetManufacturer()); |
1422 ASSERT_EQ("TEST", tmp.GetLocalAet()); | |
1423 } | |
2658 | 1424 |
2659 | 1425 // SystemCallOperation |
1426 | |
1427 { | |
1428 SystemCallOperation operation(std::string("echo")); | |
1429 operation.AddPreArgument("a"); | |
1430 operation.AddPreArgument("b"); | |
1431 operation.AddPostArgument("c"); | |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1432 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1433 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, operation)); |
2659 | 1434 operation.Serialize(s); |
1435 } | |
2658 | 1436 |
2659 | 1437 { |
1438 operation.reset(unserializer.UnserializeOperation(s)); | |
1439 | |
1440 const SystemCallOperation& tmp = dynamic_cast<SystemCallOperation&>(*operation); | |
1441 ASSERT_EQ("echo", tmp.GetCommand()); | |
1442 ASSERT_EQ(2u, tmp.GetPreArgumentsCount()); | |
1443 ASSERT_EQ(1u, tmp.GetPostArgumentsCount()); | |
1444 ASSERT_EQ("a", tmp.GetPreArgument(0)); | |
1445 ASSERT_EQ("b", tmp.GetPreArgument(1)); | |
1446 ASSERT_EQ("c", tmp.GetPostArgument(0)); | |
1447 } | |
2658 | 1448 |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1449 // ModifyInstanceOperation |
2659 | 1450 |
1451 { | |
1452 std::auto_ptr<DicomModification> modification(new DicomModification); | |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1453 modification->SetupAnonymization(DicomVersion_2008); |
2659 | 1454 |
1455 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
|
1456 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1457 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, operation)); |
2659 | 1458 operation.Serialize(s); |
1459 } | |
1460 | |
1461 { | |
1462 operation.reset(unserializer.UnserializeOperation(s)); | |
1463 | |
1464 const ModifyInstanceOperation& tmp = dynamic_cast<ModifyInstanceOperation&>(*operation); | |
1465 ASSERT_EQ(RequestOrigin_Lua, tmp.GetRequestOrigin()); | |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1466 ASSERT_TRUE(tmp.GetModification().IsRemoved(DICOM_TAG_STUDY_DESCRIPTION)); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2660
diff
changeset
|
1467 } |
2655 | 1468 } |
2658 | 1469 |
1470 | |
1471 TEST_F(OrthancJobsSerialization, Jobs) | |
1472 { | |
2845
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
1473 Json::Value s; |
2663
228e2783ce83
some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2662
diff
changeset
|
1474 |
2845
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
1475 // ArchiveJob |
2663
228e2783ce83
some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2662
diff
changeset
|
1476 |
228e2783ce83
some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2662
diff
changeset
|
1477 { |
228e2783ce83
some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2662
diff
changeset
|
1478 boost::shared_ptr<TemporaryFile> tmp(new TemporaryFile); |
228e2783ce83
some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2662
diff
changeset
|
1479 ArchiveJob job(tmp, GetContext(), false, false); |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1480 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
|
1481 } |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1482 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1483 // DicomModalityStoreJob |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1484 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1485 OrthancJobUnserializer unserializer(GetContext()); |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1486 |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1487 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1488 RemoteModalityParameters modality; |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1489 modality.SetApplicationEntityTitle("REMOTE"); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1490 modality.SetHost("192.168.1.1"); |
2715
73bc0c32547c
fix embedding openssl within a DLL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
1491 modality.SetPortNumber(1000); |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1492 modality.SetManufacturer(ModalityManufacturer_StoreScp); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1493 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1494 DicomModalityStoreJob job(GetContext()); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1495 job.SetLocalAet("LOCAL"); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1496 job.SetRemoteModality(modality); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1497 job.SetMoveOriginator("MOVESCU", 42); |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1498 |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1499 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1500 ASSERT_TRUE(job.Serialize(s)); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1501 } |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1502 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1503 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1504 std::auto_ptr<IJob> job; |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1505 job.reset(unserializer.UnserializeJob(s)); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1506 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1507 DicomModalityStoreJob& tmp = dynamic_cast<DicomModalityStoreJob&>(*job); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1508 ASSERT_EQ("LOCAL", tmp.GetLocalAet()); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1509 ASSERT_EQ("REMOTE", tmp.GetRemoteModality().GetApplicationEntityTitle()); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1510 ASSERT_EQ("192.168.1.1", tmp.GetRemoteModality().GetHost()); |
2715
73bc0c32547c
fix embedding openssl within a DLL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2671
diff
changeset
|
1511 ASSERT_EQ(1000, tmp.GetRemoteModality().GetPortNumber()); |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1512 ASSERT_EQ(ModalityManufacturer_StoreScp, tmp.GetRemoteModality().GetManufacturer()); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1513 ASSERT_TRUE(tmp.HasMoveOriginator()); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1514 ASSERT_EQ("MOVESCU", tmp.GetMoveOriginatorAet()); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1515 ASSERT_EQ(42, tmp.GetMoveOriginatorId()); |
2663
228e2783ce83
some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2662
diff
changeset
|
1516 } |
2658 | 1517 |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1518 // OrthancPeerStoreJob |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1519 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1520 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1521 WebServiceParameters peer; |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1522 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
|
1523 peer.SetCredentials("username", "password"); |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1524 peer.SetPkcs11Enabled(true); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1525 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1526 OrthancPeerStoreJob job(GetContext()); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1527 job.SetPeer(peer); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1528 |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1529 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1530 ASSERT_TRUE(job.Serialize(s)); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1531 } |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1532 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1533 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1534 std::auto_ptr<IJob> job; |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1535 job.reset(unserializer.UnserializeJob(s)); |
2658 | 1536 |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1537 OrthancPeerStoreJob& tmp = dynamic_cast<OrthancPeerStoreJob&>(*job); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1538 ASSERT_EQ("http://localhost/", tmp.GetPeer().GetUrl()); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1539 ASSERT_EQ("username", tmp.GetPeer().GetUsername()); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1540 ASSERT_EQ("password", tmp.GetPeer().GetPassword()); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1541 ASSERT_TRUE(tmp.GetPeer().IsPkcs11Enabled()); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1542 } |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1543 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1544 // ResourceModificationJob |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1545 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1546 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1547 std::auto_ptr<DicomModification> modification(new DicomModification); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1548 modification->SetupAnonymization(DicomVersion_2008); |
2658 | 1549 |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1550 ResourceModificationJob job(GetContext()); |
2868
abce036683cd
sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
1551 job.SetModification(modification.release(), ResourceType_Patient, true); |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1552 job.SetOrigin(DicomInstanceOrigin::FromLua()); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1553 |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1554 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
2664
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1555 ASSERT_TRUE(job.Serialize(s)); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1556 } |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1557 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1558 { |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1559 std::auto_ptr<IJob> job; |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1560 job.reset(unserializer.UnserializeJob(s)); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1561 |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1562 ResourceModificationJob& tmp = dynamic_cast<ResourceModificationJob&>(*job); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1563 ASSERT_TRUE(tmp.IsAnonymization()); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1564 ASSERT_EQ(RequestOrigin_Lua, tmp.GetOrigin().GetRequestOrigin()); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1565 ASSERT_TRUE(tmp.GetModification().IsRemoved(DICOM_TAG_STUDY_DESCRIPTION)); |
a21b244efb37
serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2663
diff
changeset
|
1566 } |
2845
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
1567 |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
1568 // SplitStudyJob |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
1569 |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1570 std::string instance; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1571 ASSERT_TRUE(CreateInstance(instance)); |
2845
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
1572 |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
1573 std::string study, series; |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
1574 |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
1575 { |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1576 ServerContext::DicomCacheLocker lock(GetContext(), instance); |
2845
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
1577 study = lock.GetDicom().GetHasher().HashStudy(); |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
1578 series = lock.GetDicom().GetHasher().HashSeries(); |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
1579 } |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
1580 |
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
1581 { |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1582 std::list<std::string> tmp; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1583 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
|
1584 ASSERT_EQ(1u, tmp.size()); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1585 ASSERT_EQ(study, tmp.front()); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1586 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
|
1587 ASSERT_EQ(1u, tmp.size()); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1588 ASSERT_EQ(series, tmp.front()); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1589 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1590 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1591 std::string study2; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1592 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1593 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1594 std::string a, b; |
2847
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1595 |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1596 { |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1597 ASSERT_THROW(SplitStudyJob(GetContext(), std::string("nope")), OrthancException); |
2845
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
1598 |
2847
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1599 SplitStudyJob job(GetContext(), study); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1600 job.SetKeepSource(true); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1601 job.AddSourceSeries(series); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1602 ASSERT_THROW(job.AddSourceSeries("nope"), OrthancException); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1603 job.SetOrigin(DicomInstanceOrigin::FromLua()); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1604 job.Replace(DICOM_TAG_PATIENT_NAME, "hello"); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1605 job.Remove(DICOM_TAG_PATIENT_BIRTH_DATE); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1606 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
|
1607 ASSERT_THROW(job.Remove(DICOM_TAG_SERIES_DESCRIPTION), OrthancException); |
2845
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
1608 |
2847
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1609 ASSERT_TRUE(job.GetTargetStudy().empty()); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1610 a = job.GetTargetStudyUid(); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1611 ASSERT_TRUE(job.LookupTargetSeriesUid(b, series)); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1612 |
2860 | 1613 job.AddTrailingStep(); |
2847
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1614 job.Start(); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1615 ASSERT_EQ(JobStepCode_Continue, job.Step().GetCode()); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1616 ASSERT_EQ(JobStepCode_Success, job.Step().GetCode()); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1617 |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1618 study2 = job.GetTargetStudy(); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1619 ASSERT_FALSE(study2.empty()); |
2847
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1620 |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1621 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1622 ASSERT_TRUE(job.Serialize(s)); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1623 } |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1624 |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1625 { |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1626 std::auto_ptr<IJob> job; |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1627 job.reset(unserializer.UnserializeJob(s)); |
2845
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
1628 |
2847
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1629 SplitStudyJob& tmp = dynamic_cast<SplitStudyJob&>(*job); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1630 ASSERT_TRUE(tmp.IsKeepSource()); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1631 ASSERT_EQ(study, tmp.GetSourceStudy()); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1632 ASSERT_EQ(a, tmp.GetTargetStudyUid()); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1633 ASSERT_EQ(RequestOrigin_Lua, tmp.GetOrigin().GetRequestOrigin()); |
2845
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
1634 |
2847
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1635 std::string s; |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1636 ASSERT_EQ(study2, tmp.GetTargetStudy()); |
2847
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1637 ASSERT_FALSE(tmp.LookupTargetSeriesUid(s, "nope")); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1638 ASSERT_TRUE(tmp.LookupTargetSeriesUid(s, series)); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1639 ASSERT_EQ(b, s); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1640 |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1641 ASSERT_FALSE(tmp.LookupReplacement(s, DICOM_TAG_STUDY_DESCRIPTION)); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1642 ASSERT_TRUE(tmp.LookupReplacement(s, DICOM_TAG_PATIENT_NAME)); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1643 ASSERT_EQ("hello", s); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1644 ASSERT_FALSE(tmp.IsRemoved(DICOM_TAG_PATIENT_NAME)); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1645 ASSERT_TRUE(tmp.IsRemoved(DICOM_TAG_PATIENT_BIRTH_DATE)); |
2da68edacab6
unit testing of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2845
diff
changeset
|
1646 } |
2845
218e2c864d1d
serialization of SplitStudyJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2842
diff
changeset
|
1647 } |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1648 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1649 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1650 std::list<std::string> tmp; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1651 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
|
1652 ASSERT_EQ(2u, tmp.size()); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1653 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
|
1654 ASSERT_EQ(2u, tmp.size()); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1655 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1656 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1657 // MergeStudyJob |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1658 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1659 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1660 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
|
1661 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1662 MergeStudyJob job(GetContext(), study); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1663 job.SetKeepSource(true); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1664 job.AddSource(study2); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1665 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
|
1666 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
|
1667 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
|
1668 job.SetOrigin(DicomInstanceOrigin::FromLua()); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1669 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1670 ASSERT_EQ(job.GetTargetStudy(), study); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1671 |
2860 | 1672 job.AddTrailingStep(); |
2853
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1673 job.Start(); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1674 ASSERT_EQ(JobStepCode_Continue, job.Step().GetCode()); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1675 ASSERT_EQ(JobStepCode_Success, job.Step().GetCode()); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1676 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1677 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1678 ASSERT_TRUE(job.Serialize(s)); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1679 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1680 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1681 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1682 std::list<std::string> tmp; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1683 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
|
1684 ASSERT_EQ(2u, tmp.size()); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1685 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
|
1686 ASSERT_EQ(3u, tmp.size()); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1687 } |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1688 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1689 { |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1690 std::auto_ptr<IJob> job; |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1691 job.reset(unserializer.UnserializeJob(s)); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1692 |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1693 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
|
1694 ASSERT_TRUE(tmp.IsKeepSource()); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1695 ASSERT_EQ(study, tmp.GetTargetStudy()); |
52b017d22a4f
New URI: "/studies/.../merge" to merge a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2847
diff
changeset
|
1696 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
|
1697 } |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1698 } |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1699 |
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
1700 |
2666
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1701 TEST(JobsSerialization, Registry) |
2540ac79ab6c
SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2665
diff
changeset
|
1702 { |
2667
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1703 Json::Value s; |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1704 std::string i1, i2; |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1705 |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1706 { |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1707 JobsRegistry registry; |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1708 registry.Submit(i1, new DummyJob(), 10); |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1709 registry.Submit(i2, new SequenceOfOperationsJob(), 30); |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1710 registry.Serialize(s); |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1711 } |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1712 |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1713 { |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1714 DummyUnserializer unserializer; |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1715 JobsRegistry registry(unserializer, s); |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1716 |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1717 Json::Value t; |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1718 registry.Serialize(t); |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1719 ASSERT_TRUE(CheckSameJson(s, t)); |
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2666
diff
changeset
|
1720 } |
2658 | 1721 } |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1722 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1723 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1724 TEST(JobsSerialization, TrailingStep) |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1725 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1726 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1727 Json::Value s; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1728 |
2860 | 1729 DummyInstancesJob job; |
1730 ASSERT_EQ(0, job.GetCommandsCount()); | |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1731 ASSERT_EQ(0, job.GetInstancesCount()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1732 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1733 job.Start(); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1734 ASSERT_EQ(0, job.GetPosition()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1735 ASSERT_FALSE(job.HasTrailingStep()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1736 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1737 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1738 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1739 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1740 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1741 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1742 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1743 ASSERT_EQ(JobStepCode_Success, job.Step().GetCode()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1744 ASSERT_EQ(1, job.GetPosition()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1745 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1746 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1747 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1748 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1749 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1750 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1751 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1752 ASSERT_THROW(job.Step(), OrthancException); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1753 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1754 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1755 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1756 Json::Value s; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1757 |
2860 | 1758 DummyInstancesJob job; |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1759 job.AddInstance("hello"); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1760 job.AddInstance("world"); |
2860 | 1761 ASSERT_EQ(2, job.GetCommandsCount()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1762 ASSERT_EQ(2, job.GetInstancesCount()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1763 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1764 job.Start(); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1765 ASSERT_EQ(0, job.GetPosition()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1766 ASSERT_FALSE(job.HasTrailingStep()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1767 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1768 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1769 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1770 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1771 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1772 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1773 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1774 ASSERT_EQ(JobStepCode_Continue, job.Step().GetCode()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1775 ASSERT_EQ(1, job.GetPosition()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1776 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1777 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1778 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1779 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1780 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1781 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1782 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1783 ASSERT_EQ(JobStepCode_Success, job.Step().GetCode()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1784 ASSERT_EQ(2, job.GetPosition()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1785 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1786 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1787 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1788 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1789 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1790 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1791 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1792 ASSERT_THROW(job.Step(), OrthancException); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1793 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1794 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1795 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1796 Json::Value s; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1797 |
2860 | 1798 DummyInstancesJob job; |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1799 ASSERT_EQ(0, job.GetInstancesCount()); |
2860 | 1800 ASSERT_EQ(0, job.GetCommandsCount()); |
1801 job.AddTrailingStep(); | |
1802 ASSERT_EQ(0, job.GetInstancesCount()); | |
1803 ASSERT_EQ(1, job.GetCommandsCount()); | |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1804 |
2860 | 1805 job.Start(); // This adds the trailing step |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1806 ASSERT_EQ(0, job.GetPosition()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1807 ASSERT_TRUE(job.HasTrailingStep()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1808 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1809 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1810 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1811 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1812 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1813 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1814 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1815 ASSERT_EQ(JobStepCode_Success, job.Step().GetCode()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1816 ASSERT_EQ(1, job.GetPosition()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1817 ASSERT_TRUE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1818 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1819 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1820 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1821 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1822 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1823 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1824 ASSERT_THROW(job.Step(), OrthancException); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1825 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1826 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1827 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1828 Json::Value s; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1829 |
2860 | 1830 DummyInstancesJob job; |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1831 job.AddInstance("hello"); |
2860 | 1832 ASSERT_EQ(1, job.GetInstancesCount()); |
1833 ASSERT_EQ(1, job.GetCommandsCount()); | |
1834 job.AddTrailingStep(); | |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1835 ASSERT_EQ(1, job.GetInstancesCount()); |
2860 | 1836 ASSERT_EQ(2, job.GetCommandsCount()); |
1837 | |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1838 job.Start(); |
2860 | 1839 ASSERT_EQ(2, job.GetCommandsCount()); |
2842
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1840 ASSERT_EQ(0, job.GetPosition()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1841 ASSERT_TRUE(job.HasTrailingStep()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1842 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1843 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1844 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1845 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1846 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1847 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1848 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1849 ASSERT_EQ(JobStepCode_Continue, job.Step().GetCode()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1850 ASSERT_EQ(1, job.GetPosition()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1851 ASSERT_FALSE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1852 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1853 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1854 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1855 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1856 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1857 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1858 ASSERT_EQ(JobStepCode_Success, job.Step().GetCode()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1859 ASSERT_EQ(2, job.GetPosition()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1860 ASSERT_TRUE(job.IsTrailingStepDone()); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1861 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1862 { |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1863 DummyUnserializer unserializer; |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1864 ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job)); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1865 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1866 |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1867 ASSERT_THROW(job.Step(), OrthancException); |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1868 } |
ff0ed5ea9e4e
trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2815
diff
changeset
|
1869 } |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1870 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1871 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1872 TEST(JobsSerialization, RemoteModalityParameters) |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1873 { |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1874 Json::Value s; |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1875 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1876 { |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1877 RemoteModalityParameters modality; |
2872
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1878 ASSERT_FALSE(modality.IsAdvancedFormatNeeded()); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1879 modality.Serialize(s, false); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1880 ASSERT_EQ(Json::arrayValue, s.type()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1881 } |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1882 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1883 { |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1884 RemoteModalityParameters modality(s); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1885 ASSERT_EQ("ORTHANC", modality.GetApplicationEntityTitle()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1886 ASSERT_EQ("127.0.0.1", modality.GetHost()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1887 ASSERT_EQ(104u, modality.GetPortNumber()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1888 ASSERT_EQ(ModalityManufacturer_Generic, modality.GetManufacturer()); |
2872
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1889 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Echo)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1890 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Find)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1891 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Get)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1892 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Store)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1893 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Move)); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1894 } |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1895 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1896 s = Json::nullValue; |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1897 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1898 { |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1899 RemoteModalityParameters modality; |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1900 ASSERT_FALSE(modality.IsAdvancedFormatNeeded()); |
2872
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1901 ASSERT_THROW(modality.SetPortNumber(0), OrthancException); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1902 ASSERT_THROW(modality.SetPortNumber(65535), OrthancException); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1903 modality.SetApplicationEntityTitle("HELLO"); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1904 modality.SetHost("world"); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1905 modality.SetPortNumber(45); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1906 modality.SetManufacturer(ModalityManufacturer_Dcm4Chee); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1907 modality.Serialize(s, true); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1908 ASSERT_EQ(Json::objectValue, s.type()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1909 } |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1910 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1911 { |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1912 RemoteModalityParameters modality(s); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1913 ASSERT_EQ("HELLO", modality.GetApplicationEntityTitle()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1914 ASSERT_EQ("world", modality.GetHost()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1915 ASSERT_EQ(45u, modality.GetPortNumber()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1916 ASSERT_EQ(ModalityManufacturer_Dcm4Chee, modality.GetManufacturer()); |
2872
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1917 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Echo)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1918 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Find)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1919 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Get)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1920 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Store)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1921 ASSERT_TRUE(modality.IsRequestAllowed(DicomRequestType_Move)); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1922 } |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1923 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1924 s["Port"] = "46"; |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1925 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1926 { |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1927 RemoteModalityParameters modality(s); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1928 ASSERT_EQ(46u, modality.GetPortNumber()); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1929 } |
2872
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1930 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1931 s["Port"] = -1; ASSERT_THROW(RemoteModalityParameters m(s), OrthancException); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1932 s["Port"] = 65535; ASSERT_THROW(RemoteModalityParameters m(s), OrthancException); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1933 s["Port"] = "nope"; ASSERT_THROW(RemoteModalityParameters m(s), OrthancException); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1934 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1935 std::set<DicomRequestType> operations; |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1936 operations.insert(DicomRequestType_Echo); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1937 operations.insert(DicomRequestType_Find); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1938 operations.insert(DicomRequestType_Get); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1939 operations.insert(DicomRequestType_Move); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1940 operations.insert(DicomRequestType_Store); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1941 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1942 ASSERT_EQ(5u, operations.size()); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1943 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1944 for (std::set<DicomRequestType>::const_iterator |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1945 it = operations.begin(); it != operations.end(); ++it) |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1946 { |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1947 { |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1948 RemoteModalityParameters modality; |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1949 modality.SetRequestAllowed(*it, false); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1950 ASSERT_TRUE(modality.IsAdvancedFormatNeeded()); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1951 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1952 modality.Serialize(s, false); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1953 ASSERT_EQ(Json::objectValue, s.type()); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1954 } |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1955 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1956 { |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1957 RemoteModalityParameters modality(s); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1958 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1959 ASSERT_FALSE(modality.IsRequestAllowed(*it)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1960 |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1961 for (std::set<DicomRequestType>::const_iterator |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1962 it2 = operations.begin(); it2 != operations.end(); ++it2) |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1963 { |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1964 if (*it2 != *it) |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1965 { |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1966 ASSERT_TRUE(modality.IsRequestAllowed(*it2)); |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1967 } |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1968 } |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1969 } |
9d08edde614b
Possibility to restrict the allowed DICOM commands for each modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2871
diff
changeset
|
1970 } |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1971 } |