annotate OrthancServer/UnitTestsSources/ServerJobsTests.cpp @ 4215:28e9457dc7ab

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