annotate UnitTestsSources/MultiThreadingTests.cpp @ 4010:f0ee3f1db775

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