comparison OrthancServer/UnitTestsSources/ServerIndexTests.cpp @ 4591:ff8170d17d90 db-changes

moving all accesses to databases from IDatabaseWrapper to ITransaction
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 15 Mar 2021 15:30:42 +0100
parents bec74e29f86b
children f75c63aa9de0
comparison
equal deleted inserted replaced
4590:4a0bf1019335 4591:ff8170d17d90
94 class DatabaseWrapperTest : public ::testing::Test 94 class DatabaseWrapperTest : public ::testing::Test
95 { 95 {
96 protected: 96 protected:
97 std::unique_ptr<TestDatabaseListener> listener_; 97 std::unique_ptr<TestDatabaseListener> listener_;
98 std::unique_ptr<SQLiteDatabaseWrapper> index_; 98 std::unique_ptr<SQLiteDatabaseWrapper> index_;
99 std::unique_ptr<IDatabaseWrapper::ITransaction> transaction_; 99 std::unique_ptr<SQLiteDatabaseWrapper::UnitTestsTransaction> transaction_;
100 100
101 public: 101 public:
102 DatabaseWrapperTest() 102 DatabaseWrapperTest()
103 { 103 {
104 } 104 }
106 virtual void SetUp() ORTHANC_OVERRIDE 106 virtual void SetUp() ORTHANC_OVERRIDE
107 { 107 {
108 listener_.reset(new TestDatabaseListener); 108 listener_.reset(new TestDatabaseListener);
109 index_.reset(new SQLiteDatabaseWrapper); 109 index_.reset(new SQLiteDatabaseWrapper);
110 index_->Open(); 110 index_->Open();
111 transaction_.reset(index_->StartTransaction(TransactionType_ReadWrite, *listener_)); 111 transaction_.reset(dynamic_cast<SQLiteDatabaseWrapper::UnitTestsTransaction*>(
112 index_->StartTransaction(TransactionType_ReadWrite, *listener_)));
112 } 113 }
113 114
114 virtual void TearDown() ORTHANC_OVERRIDE 115 virtual void TearDown() ORTHANC_OVERRIDE
115 { 116 {
116 transaction_->Commit(0); 117 transaction_->Commit(0);
121 listener_.reset(NULL); 122 listener_.reset(NULL);
122 } 123 }
123 124
124 void CheckTableRecordCount(uint32_t expected, const char* table) 125 void CheckTableRecordCount(uint32_t expected, const char* table)
125 { 126 {
126 ASSERT_EQ(expected, index_->GetTableRecordCount(table)); 127 ASSERT_EQ(expected, transaction_->GetTableRecordCount(table));
127 } 128 }
128 129
129 void CheckNoParent(int64_t id) 130 void CheckNoParent(int64_t id)
130 { 131 {
131 std::string s; 132 std::string s;
132 ASSERT_FALSE(index_->GetParentPublicId(s, id)); 133 ASSERT_FALSE(transaction_->GetParentPublicId(s, id));
133 } 134 }
134 135
135 void CheckParentPublicId(const char* expected, int64_t id) 136 void CheckParentPublicId(const char* expected, int64_t id)
136 { 137 {
137 std::string s; 138 std::string s;
138 ASSERT_TRUE(index_->GetParentPublicId(s, id)); 139 ASSERT_TRUE(transaction_->GetParentPublicId(s, id));
139 ASSERT_EQ(expected, s); 140 ASSERT_EQ(expected, s);
140 } 141 }
141 142
142 void CheckNoChild(int64_t id) 143 void CheckNoChild(int64_t id)
143 { 144 {
144 std::list<std::string> j; 145 std::list<std::string> j;
145 index_->GetChildren(j, id); 146 transaction_->GetChildren(j, id);
146 ASSERT_EQ(0u, j.size()); 147 ASSERT_EQ(0u, j.size());
147 } 148 }
148 149
149 void CheckOneChild(const char* expected, int64_t id) 150 void CheckOneChild(const char* expected, int64_t id)
150 { 151 {
151 std::list<std::string> j; 152 std::list<std::string> j;
152 index_->GetChildren(j, id); 153 transaction_->GetChildren(j, id);
153 ASSERT_EQ(1u, j.size()); 154 ASSERT_EQ(1u, j.size());
154 ASSERT_EQ(expected, j.front()); 155 ASSERT_EQ(expected, j.front());
155 } 156 }
156 157
157 void CheckTwoChildren(const char* expected1, 158 void CheckTwoChildren(const char* expected1,
158 const char* expected2, 159 const char* expected2,
159 int64_t id) 160 int64_t id)
160 { 161 {
161 std::list<std::string> j; 162 std::list<std::string> j;
162 index_->GetChildren(j, id); 163 transaction_->GetChildren(j, id);
163 ASSERT_EQ(2u, j.size()); 164 ASSERT_EQ(2u, j.size());
164 ASSERT_TRUE((expected1 == j.front() && expected2 == j.back()) || 165 ASSERT_TRUE((expected1 == j.front() && expected2 == j.back()) ||
165 (expected1 == j.back() && expected2 == j.front())); 166 (expected1 == j.back() && expected2 == j.front()));
166 } 167 }
167 168
176 DicomTagConstraint c(tag, type, value, true, true); 177 DicomTagConstraint c(tag, type, value, true, true);
177 178
178 std::vector<DatabaseConstraint> lookup; 179 std::vector<DatabaseConstraint> lookup;
179 lookup.push_back(c.ConvertToDatabaseConstraint(level, DicomTagType_Identifier)); 180 lookup.push_back(c.ConvertToDatabaseConstraint(level, DicomTagType_Identifier));
180 181
181 index_->ApplyLookupResources(result, NULL, lookup, level, 0 /* no limit */); 182 transaction_->ApplyLookupResources(result, NULL, lookup, level, 0 /* no limit */);
182 } 183 }
183 184
184 void DoLookupIdentifier2(std::list<std::string>& result, 185 void DoLookupIdentifier2(std::list<std::string>& result,
185 ResourceType level, 186 ResourceType level,
186 const DicomTag& tag, 187 const DicomTag& tag,
196 197
197 std::vector<DatabaseConstraint> lookup; 198 std::vector<DatabaseConstraint> lookup;
198 lookup.push_back(c1.ConvertToDatabaseConstraint(level, DicomTagType_Identifier)); 199 lookup.push_back(c1.ConvertToDatabaseConstraint(level, DicomTagType_Identifier));
199 lookup.push_back(c2.ConvertToDatabaseConstraint(level, DicomTagType_Identifier)); 200 lookup.push_back(c2.ConvertToDatabaseConstraint(level, DicomTagType_Identifier));
200 201
201 index_->ApplyLookupResources(result, NULL, lookup, level, 0 /* no limit */); 202 transaction_->ApplyLookupResources(result, NULL, lookup, level, 0 /* no limit */);
202 } 203 }
203 }; 204 };
204 } 205 }
205 206
206 207
207 TEST_F(DatabaseWrapperTest, Simple) 208 TEST_F(DatabaseWrapperTest, Simple)
208 { 209 {
209 int64_t a[] = { 210 int64_t a[] = {
210 index_->CreateResource("a", ResourceType_Patient), // 0 211 transaction_->CreateResource("a", ResourceType_Patient), // 0
211 index_->CreateResource("b", ResourceType_Study), // 1 212 transaction_->CreateResource("b", ResourceType_Study), // 1
212 index_->CreateResource("c", ResourceType_Series), // 2 213 transaction_->CreateResource("c", ResourceType_Series), // 2
213 index_->CreateResource("d", ResourceType_Instance), // 3 214 transaction_->CreateResource("d", ResourceType_Instance), // 3
214 index_->CreateResource("e", ResourceType_Instance), // 4 215 transaction_->CreateResource("e", ResourceType_Instance), // 4
215 index_->CreateResource("f", ResourceType_Instance), // 5 216 transaction_->CreateResource("f", ResourceType_Instance), // 5
216 index_->CreateResource("g", ResourceType_Study) // 6 217 transaction_->CreateResource("g", ResourceType_Study) // 6
217 }; 218 };
218 219
219 ASSERT_EQ("a", index_->GetPublicId(a[0])); 220 ASSERT_EQ("a", transaction_->GetPublicId(a[0]));
220 ASSERT_EQ("b", index_->GetPublicId(a[1])); 221 ASSERT_EQ("b", transaction_->GetPublicId(a[1]));
221 ASSERT_EQ("c", index_->GetPublicId(a[2])); 222 ASSERT_EQ("c", transaction_->GetPublicId(a[2]));
222 ASSERT_EQ("d", index_->GetPublicId(a[3])); 223 ASSERT_EQ("d", transaction_->GetPublicId(a[3]));
223 ASSERT_EQ("e", index_->GetPublicId(a[4])); 224 ASSERT_EQ("e", transaction_->GetPublicId(a[4]));
224 ASSERT_EQ("f", index_->GetPublicId(a[5])); 225 ASSERT_EQ("f", transaction_->GetPublicId(a[5]));
225 ASSERT_EQ("g", index_->GetPublicId(a[6])); 226 ASSERT_EQ("g", transaction_->GetPublicId(a[6]));
226 227
227 ASSERT_EQ(ResourceType_Patient, index_->GetResourceType(a[0])); 228 ASSERT_EQ(ResourceType_Patient, transaction_->GetResourceType(a[0]));
228 ASSERT_EQ(ResourceType_Study, index_->GetResourceType(a[1])); 229 ASSERT_EQ(ResourceType_Study, transaction_->GetResourceType(a[1]));
229 ASSERT_EQ(ResourceType_Series, index_->GetResourceType(a[2])); 230 ASSERT_EQ(ResourceType_Series, transaction_->GetResourceType(a[2]));
230 ASSERT_EQ(ResourceType_Instance, index_->GetResourceType(a[3])); 231 ASSERT_EQ(ResourceType_Instance, transaction_->GetResourceType(a[3]));
231 ASSERT_EQ(ResourceType_Instance, index_->GetResourceType(a[4])); 232 ASSERT_EQ(ResourceType_Instance, transaction_->GetResourceType(a[4]));
232 ASSERT_EQ(ResourceType_Instance, index_->GetResourceType(a[5])); 233 ASSERT_EQ(ResourceType_Instance, transaction_->GetResourceType(a[5]));
233 ASSERT_EQ(ResourceType_Study, index_->GetResourceType(a[6])); 234 ASSERT_EQ(ResourceType_Study, transaction_->GetResourceType(a[6]));
234 235
235 { 236 {
236 std::list<std::string> t; 237 std::list<std::string> t;
237 index_->GetAllPublicIds(t, ResourceType_Patient); 238 transaction_->GetAllPublicIds(t, ResourceType_Patient);
238 239
239 ASSERT_EQ(1u, t.size()); 240 ASSERT_EQ(1u, t.size());
240 ASSERT_EQ("a", t.front()); 241 ASSERT_EQ("a", t.front());
241 242
242 index_->GetAllPublicIds(t, ResourceType_Series); 243 transaction_->GetAllPublicIds(t, ResourceType_Series);
243 ASSERT_EQ(1u, t.size()); 244 ASSERT_EQ(1u, t.size());
244 ASSERT_EQ("c", t.front()); 245 ASSERT_EQ("c", t.front());
245 246
246 index_->GetAllPublicIds(t, ResourceType_Study); 247 transaction_->GetAllPublicIds(t, ResourceType_Study);
247 ASSERT_EQ(2u, t.size()); 248 ASSERT_EQ(2u, t.size());
248 249
249 index_->GetAllPublicIds(t, ResourceType_Instance); 250 transaction_->GetAllPublicIds(t, ResourceType_Instance);
250 ASSERT_EQ(3u, t.size()); 251 ASSERT_EQ(3u, t.size());
251 } 252 }
252 253
253 index_->SetGlobalProperty(GlobalProperty_FlushSleep, "World"); 254 transaction_->SetGlobalProperty(GlobalProperty_FlushSleep, "World");
254 255
255 index_->AttachChild(a[0], a[1]); 256 transaction_->AttachChild(a[0], a[1]);
256 index_->AttachChild(a[1], a[2]); 257 transaction_->AttachChild(a[1], a[2]);
257 index_->AttachChild(a[2], a[3]); 258 transaction_->AttachChild(a[2], a[3]);
258 index_->AttachChild(a[2], a[4]); 259 transaction_->AttachChild(a[2], a[4]);
259 index_->AttachChild(a[6], a[5]); 260 transaction_->AttachChild(a[6], a[5]);
260 261
261 int64_t parent; 262 int64_t parent;
262 ASSERT_FALSE(index_->LookupParent(parent, a[0])); 263 ASSERT_FALSE(transaction_->LookupParent(parent, a[0]));
263 ASSERT_TRUE(index_->LookupParent(parent, a[1])); ASSERT_EQ(a[0], parent); 264 ASSERT_TRUE(transaction_->LookupParent(parent, a[1])); ASSERT_EQ(a[0], parent);
264 ASSERT_TRUE(index_->LookupParent(parent, a[2])); ASSERT_EQ(a[1], parent); 265 ASSERT_TRUE(transaction_->LookupParent(parent, a[2])); ASSERT_EQ(a[1], parent);
265 ASSERT_TRUE(index_->LookupParent(parent, a[3])); ASSERT_EQ(a[2], parent); 266 ASSERT_TRUE(transaction_->LookupParent(parent, a[3])); ASSERT_EQ(a[2], parent);
266 ASSERT_TRUE(index_->LookupParent(parent, a[4])); ASSERT_EQ(a[2], parent); 267 ASSERT_TRUE(transaction_->LookupParent(parent, a[4])); ASSERT_EQ(a[2], parent);
267 ASSERT_TRUE(index_->LookupParent(parent, a[5])); ASSERT_EQ(a[6], parent); 268 ASSERT_TRUE(transaction_->LookupParent(parent, a[5])); ASSERT_EQ(a[6], parent);
268 ASSERT_FALSE(index_->LookupParent(parent, a[6])); 269 ASSERT_FALSE(transaction_->LookupParent(parent, a[6]));
269 270
270 std::string s; 271 std::string s;
271 272
272 CheckNoParent(a[0]); 273 CheckNoParent(a[0]);
273 CheckNoParent(a[6]); 274 CheckNoParent(a[6]);
276 CheckParentPublicId("c", a[3]); 277 CheckParentPublicId("c", a[3]);
277 CheckParentPublicId("c", a[4]); 278 CheckParentPublicId("c", a[4]);
278 CheckParentPublicId("g", a[5]); 279 CheckParentPublicId("g", a[5]);
279 280
280 std::list<std::string> l; 281 std::list<std::string> l;
281 index_->GetChildrenPublicId(l, a[0]); ASSERT_EQ(1u, l.size()); ASSERT_EQ("b", l.front()); 282 transaction_->GetChildrenPublicId(l, a[0]); ASSERT_EQ(1u, l.size()); ASSERT_EQ("b", l.front());
282 index_->GetChildrenPublicId(l, a[1]); ASSERT_EQ(1u, l.size()); ASSERT_EQ("c", l.front()); 283 transaction_->GetChildrenPublicId(l, a[1]); ASSERT_EQ(1u, l.size()); ASSERT_EQ("c", l.front());
283 index_->GetChildrenPublicId(l, a[3]); ASSERT_EQ(0u, l.size()); 284 transaction_->GetChildrenPublicId(l, a[3]); ASSERT_EQ(0u, l.size());
284 index_->GetChildrenPublicId(l, a[4]); ASSERT_EQ(0u, l.size()); 285 transaction_->GetChildrenPublicId(l, a[4]); ASSERT_EQ(0u, l.size());
285 index_->GetChildrenPublicId(l, a[5]); ASSERT_EQ(0u, l.size()); 286 transaction_->GetChildrenPublicId(l, a[5]); ASSERT_EQ(0u, l.size());
286 index_->GetChildrenPublicId(l, a[6]); ASSERT_EQ(1u, l.size()); ASSERT_EQ("f", l.front()); 287 transaction_->GetChildrenPublicId(l, a[6]); ASSERT_EQ(1u, l.size()); ASSERT_EQ("f", l.front());
287 288
288 index_->GetChildrenPublicId(l, a[2]); ASSERT_EQ(2u, l.size()); 289 transaction_->GetChildrenPublicId(l, a[2]); ASSERT_EQ(2u, l.size());
289 if (l.front() == "d") 290 if (l.front() == "d")
290 { 291 {
291 ASSERT_EQ("e", l.back()); 292 ASSERT_EQ("e", l.back());
292 } 293 }
293 else 294 else
295 ASSERT_EQ("d", l.back()); 296 ASSERT_EQ("d", l.back());
296 ASSERT_EQ("e", l.front()); 297 ASSERT_EQ("e", l.front());
297 } 298 }
298 299
299 std::map<MetadataType, std::string> md; 300 std::map<MetadataType, std::string> md;
300 index_->GetAllMetadata(md, a[4]); 301 transaction_->GetAllMetadata(md, a[4]);
301 ASSERT_EQ(0u, md.size()); 302 ASSERT_EQ(0u, md.size());
302 303
303 index_->AddAttachment(a[4], FileInfo("my json file", FileContentType_DicomAsJson, 42, "md5", 304 transaction_->AddAttachment(a[4], FileInfo("my json file", FileContentType_DicomAsJson, 42, "md5",
304 CompressionType_ZlibWithSize, 21, "compressedMD5")); 305 CompressionType_ZlibWithSize, 21, "compressedMD5"));
305 index_->AddAttachment(a[4], FileInfo("my dicom file", FileContentType_Dicom, 42, "md5")); 306 transaction_->AddAttachment(a[4], FileInfo("my dicom file", FileContentType_Dicom, 42, "md5"));
306 index_->AddAttachment(a[6], FileInfo("world", FileContentType_Dicom, 44, "md5")); 307 transaction_->AddAttachment(a[6], FileInfo("world", FileContentType_Dicom, 44, "md5"));
307 index_->SetMetadata(a[4], MetadataType_RemoteAet, "PINNACLE"); 308 transaction_->SetMetadata(a[4], MetadataType_RemoteAet, "PINNACLE");
308 309
309 index_->GetAllMetadata(md, a[4]); 310 transaction_->GetAllMetadata(md, a[4]);
310 ASSERT_EQ(1u, md.size()); 311 ASSERT_EQ(1u, md.size());
311 ASSERT_EQ("PINNACLE", md[MetadataType_RemoteAet]); 312 ASSERT_EQ("PINNACLE", md[MetadataType_RemoteAet]);
312 index_->SetMetadata(a[4], MetadataType_ModifiedFrom, "TUTU"); 313 transaction_->SetMetadata(a[4], MetadataType_ModifiedFrom, "TUTU");
313 index_->GetAllMetadata(md, a[4]); 314 transaction_->GetAllMetadata(md, a[4]);
314 ASSERT_EQ(2u, md.size()); 315 ASSERT_EQ(2u, md.size());
315 316
316 std::map<MetadataType, std::string> md2; 317 std::map<MetadataType, std::string> md2;
317 index_->GetAllMetadata(md2, a[4]); 318 transaction_->GetAllMetadata(md2, a[4]);
318 ASSERT_EQ(2u, md2.size()); 319 ASSERT_EQ(2u, md2.size());
319 ASSERT_EQ("TUTU", md2[MetadataType_ModifiedFrom]); 320 ASSERT_EQ("TUTU", md2[MetadataType_ModifiedFrom]);
320 ASSERT_EQ("PINNACLE", md2[MetadataType_RemoteAet]); 321 ASSERT_EQ("PINNACLE", md2[MetadataType_RemoteAet]);
321 322
322 index_->DeleteMetadata(a[4], MetadataType_ModifiedFrom); 323 transaction_->DeleteMetadata(a[4], MetadataType_ModifiedFrom);
323 index_->GetAllMetadata(md, a[4]); 324 transaction_->GetAllMetadata(md, a[4]);
324 ASSERT_EQ(1u, md.size()); 325 ASSERT_EQ(1u, md.size());
325 ASSERT_EQ("PINNACLE", md[MetadataType_RemoteAet]); 326 ASSERT_EQ("PINNACLE", md[MetadataType_RemoteAet]);
326 327
327 index_->GetAllMetadata(md2, a[4]); 328 transaction_->GetAllMetadata(md2, a[4]);
328 ASSERT_EQ(1u, md2.size()); 329 ASSERT_EQ(1u, md2.size());
329 ASSERT_EQ("PINNACLE", md2[MetadataType_RemoteAet]); 330 ASSERT_EQ("PINNACLE", md2[MetadataType_RemoteAet]);
330 331
331 332
332 ASSERT_EQ(21u + 42u + 44u, index_->GetTotalCompressedSize()); 333 ASSERT_EQ(21u + 42u + 44u, transaction_->GetTotalCompressedSize());
333 ASSERT_EQ(42u + 42u + 44u, index_->GetTotalUncompressedSize()); 334 ASSERT_EQ(42u + 42u + 44u, transaction_->GetTotalUncompressedSize());
334 335
335 index_->SetMainDicomTag(a[3], DicomTag(0x0010, 0x0010), "PatientName"); 336 transaction_->SetMainDicomTag(a[3], DicomTag(0x0010, 0x0010), "PatientName");
336 337
337 int64_t b; 338 int64_t b;
338 ResourceType t; 339 ResourceType t;
339 ASSERT_TRUE(index_->LookupResource(b, t, "g")); 340 ASSERT_TRUE(transaction_->LookupResource(b, t, "g"));
340 ASSERT_EQ(7, b); 341 ASSERT_EQ(7, b);
341 ASSERT_EQ(ResourceType_Study, t); 342 ASSERT_EQ(ResourceType_Study, t);
342 343
343 ASSERT_TRUE(index_->LookupMetadata(s, a[4], MetadataType_RemoteAet)); 344 ASSERT_TRUE(transaction_->LookupMetadata(s, a[4], MetadataType_RemoteAet));
344 ASSERT_FALSE(index_->LookupMetadata(s, a[4], MetadataType_Instance_IndexInSeries)); 345 ASSERT_FALSE(transaction_->LookupMetadata(s, a[4], MetadataType_Instance_IndexInSeries));
345 ASSERT_EQ("PINNACLE", s); 346 ASSERT_EQ("PINNACLE", s);
346 347
347 std::string u; 348 std::string u;
348 ASSERT_TRUE(index_->LookupMetadata(u, a[4], MetadataType_RemoteAet)); 349 ASSERT_TRUE(transaction_->LookupMetadata(u, a[4], MetadataType_RemoteAet));
349 ASSERT_EQ("PINNACLE", u); 350 ASSERT_EQ("PINNACLE", u);
350 ASSERT_FALSE(index_->LookupMetadata(u, a[4], MetadataType_Instance_IndexInSeries)); 351 ASSERT_FALSE(transaction_->LookupMetadata(u, a[4], MetadataType_Instance_IndexInSeries));
351 352
352 ASSERT_TRUE(index_->LookupGlobalProperty(s, GlobalProperty_FlushSleep)); 353 ASSERT_TRUE(transaction_->LookupGlobalProperty(s, GlobalProperty_FlushSleep));
353 ASSERT_FALSE(index_->LookupGlobalProperty(s, static_cast<GlobalProperty>(42))); 354 ASSERT_FALSE(transaction_->LookupGlobalProperty(s, static_cast<GlobalProperty>(42)));
354 ASSERT_EQ("World", s); 355 ASSERT_EQ("World", s);
355 356
356 FileInfo att; 357 FileInfo att;
357 ASSERT_TRUE(index_->LookupAttachment(att, a[4], FileContentType_DicomAsJson)); 358 ASSERT_TRUE(transaction_->LookupAttachment(att, a[4], FileContentType_DicomAsJson));
358 ASSERT_EQ("my json file", att.GetUuid()); 359 ASSERT_EQ("my json file", att.GetUuid());
359 ASSERT_EQ(21u, att.GetCompressedSize()); 360 ASSERT_EQ(21u, att.GetCompressedSize());
360 ASSERT_EQ("md5", att.GetUncompressedMD5()); 361 ASSERT_EQ("md5", att.GetUncompressedMD5());
361 ASSERT_EQ("compressedMD5", att.GetCompressedMD5()); 362 ASSERT_EQ("compressedMD5", att.GetCompressedMD5());
362 ASSERT_EQ(42u, att.GetUncompressedSize()); 363 ASSERT_EQ(42u, att.GetUncompressedSize());
363 ASSERT_EQ(CompressionType_ZlibWithSize, att.GetCompressionType()); 364 ASSERT_EQ(CompressionType_ZlibWithSize, att.GetCompressionType());
364 365
365 ASSERT_TRUE(index_->LookupAttachment(att, a[6], FileContentType_Dicom)); 366 ASSERT_TRUE(transaction_->LookupAttachment(att, a[6], FileContentType_Dicom));
366 ASSERT_EQ("world", att.GetUuid()); 367 ASSERT_EQ("world", att.GetUuid());
367 ASSERT_EQ(44u, att.GetCompressedSize()); 368 ASSERT_EQ(44u, att.GetCompressedSize());
368 ASSERT_EQ("md5", att.GetUncompressedMD5()); 369 ASSERT_EQ("md5", att.GetUncompressedMD5());
369 ASSERT_EQ("md5", att.GetCompressedMD5()); 370 ASSERT_EQ("md5", att.GetCompressedMD5());
370 ASSERT_EQ(44u, att.GetUncompressedSize()); 371 ASSERT_EQ(44u, att.GetUncompressedSize());
376 CheckTableRecordCount(7, "Resources"); 377 CheckTableRecordCount(7, "Resources");
377 CheckTableRecordCount(3, "AttachedFiles"); 378 CheckTableRecordCount(3, "AttachedFiles");
378 CheckTableRecordCount(1, "Metadata"); 379 CheckTableRecordCount(1, "Metadata");
379 CheckTableRecordCount(1, "MainDicomTags"); 380 CheckTableRecordCount(1, "MainDicomTags");
380 381
381 index_->DeleteResource(a[0]); 382 transaction_->DeleteResource(a[0]);
382 ASSERT_EQ(5u, listener_->deletedResources_.size()); 383 ASSERT_EQ(5u, listener_->deletedResources_.size());
383 ASSERT_EQ(2u, listener_->deletedFiles_.size()); 384 ASSERT_EQ(2u, listener_->deletedFiles_.size());
384 ASSERT_FALSE(std::find(listener_->deletedFiles_.begin(), 385 ASSERT_FALSE(std::find(listener_->deletedFiles_.begin(),
385 listener_->deletedFiles_.end(), 386 listener_->deletedFiles_.end(),
386 "my json file") == listener_->deletedFiles_.end()); 387 "my json file") == listener_->deletedFiles_.end());
391 CheckTableRecordCount(2, "Resources"); 392 CheckTableRecordCount(2, "Resources");
392 CheckTableRecordCount(0, "Metadata"); 393 CheckTableRecordCount(0, "Metadata");
393 CheckTableRecordCount(1, "AttachedFiles"); 394 CheckTableRecordCount(1, "AttachedFiles");
394 CheckTableRecordCount(0, "MainDicomTags"); 395 CheckTableRecordCount(0, "MainDicomTags");
395 396
396 index_->DeleteResource(a[5]); 397 transaction_->DeleteResource(a[5]);
397 ASSERT_EQ(7u, listener_->deletedResources_.size()); 398 ASSERT_EQ(7u, listener_->deletedResources_.size());
398 399
399 CheckTableRecordCount(0, "Resources"); 400 CheckTableRecordCount(0, "Resources");
400 CheckTableRecordCount(0, "AttachedFiles"); 401 CheckTableRecordCount(0, "AttachedFiles");
401 CheckTableRecordCount(3, "GlobalProperties"); 402 CheckTableRecordCount(3, "GlobalProperties");
402 403
403 std::string tmp; 404 std::string tmp;
404 ASSERT_TRUE(index_->LookupGlobalProperty(tmp, GlobalProperty_DatabaseSchemaVersion)); 405 ASSERT_TRUE(transaction_->LookupGlobalProperty(tmp, GlobalProperty_DatabaseSchemaVersion));
405 ASSERT_EQ("6", tmp); 406 ASSERT_EQ("6", tmp);
406 ASSERT_TRUE(index_->LookupGlobalProperty(tmp, GlobalProperty_FlushSleep)); 407 ASSERT_TRUE(transaction_->LookupGlobalProperty(tmp, GlobalProperty_FlushSleep));
407 ASSERT_EQ("World", tmp); 408 ASSERT_EQ("World", tmp);
408 ASSERT_TRUE(index_->LookupGlobalProperty(tmp, GlobalProperty_GetTotalSizeIsFast)); 409 ASSERT_TRUE(transaction_->LookupGlobalProperty(tmp, GlobalProperty_GetTotalSizeIsFast));
409 ASSERT_EQ("1", tmp); 410 ASSERT_EQ("1", tmp);
410 411
411 ASSERT_EQ(3u, listener_->deletedFiles_.size()); 412 ASSERT_EQ(3u, listener_->deletedFiles_.size());
412 ASSERT_FALSE(std::find(listener_->deletedFiles_.begin(), 413 ASSERT_FALSE(std::find(listener_->deletedFiles_.begin(),
413 listener_->deletedFiles_.end(), 414 listener_->deletedFiles_.end(),
416 417
417 418
418 TEST_F(DatabaseWrapperTest, Upward) 419 TEST_F(DatabaseWrapperTest, Upward)
419 { 420 {
420 int64_t a[] = { 421 int64_t a[] = {
421 index_->CreateResource("a", ResourceType_Patient), // 0 422 transaction_->CreateResource("a", ResourceType_Patient), // 0
422 index_->CreateResource("b", ResourceType_Study), // 1 423 transaction_->CreateResource("b", ResourceType_Study), // 1
423 index_->CreateResource("c", ResourceType_Series), // 2 424 transaction_->CreateResource("c", ResourceType_Series), // 2
424 index_->CreateResource("d", ResourceType_Instance), // 3 425 transaction_->CreateResource("d", ResourceType_Instance), // 3
425 index_->CreateResource("e", ResourceType_Instance), // 4 426 transaction_->CreateResource("e", ResourceType_Instance), // 4
426 index_->CreateResource("f", ResourceType_Study), // 5 427 transaction_->CreateResource("f", ResourceType_Study), // 5
427 index_->CreateResource("g", ResourceType_Series), // 6 428 transaction_->CreateResource("g", ResourceType_Series), // 6
428 index_->CreateResource("h", ResourceType_Series) // 7 429 transaction_->CreateResource("h", ResourceType_Series) // 7
429 }; 430 };
430 431
431 index_->AttachChild(a[0], a[1]); 432 transaction_->AttachChild(a[0], a[1]);
432 index_->AttachChild(a[1], a[2]); 433 transaction_->AttachChild(a[1], a[2]);
433 index_->AttachChild(a[2], a[3]); 434 transaction_->AttachChild(a[2], a[3]);
434 index_->AttachChild(a[2], a[4]); 435 transaction_->AttachChild(a[2], a[4]);
435 index_->AttachChild(a[1], a[6]); 436 transaction_->AttachChild(a[1], a[6]);
436 index_->AttachChild(a[0], a[5]); 437 transaction_->AttachChild(a[0], a[5]);
437 index_->AttachChild(a[5], a[7]); 438 transaction_->AttachChild(a[5], a[7]);
438 439
439 CheckTwoChildren("b", "f", a[0]); 440 CheckTwoChildren("b", "f", a[0]);
440 CheckTwoChildren("c", "g", a[1]); 441 CheckTwoChildren("c", "g", a[1]);
441 CheckTwoChildren("d", "e", a[2]); 442 CheckTwoChildren("d", "e", a[2]);
442 CheckNoChild(a[3]); 443 CheckNoChild(a[3]);
444 CheckOneChild("h", a[5]); 445 CheckOneChild("h", a[5]);
445 CheckNoChild(a[6]); 446 CheckNoChild(a[6]);
446 CheckNoChild(a[7]); 447 CheckNoChild(a[7]);
447 448
448 listener_->Reset(); 449 listener_->Reset();
449 index_->DeleteResource(a[3]); 450 transaction_->DeleteResource(a[3]);
450 ASSERT_EQ("c", listener_->ancestorId_); 451 ASSERT_EQ("c", listener_->ancestorId_);
451 ASSERT_EQ(ResourceType_Series, listener_->ancestorType_); 452 ASSERT_EQ(ResourceType_Series, listener_->ancestorType_);
452 453
453 listener_->Reset(); 454 listener_->Reset();
454 index_->DeleteResource(a[4]); 455 transaction_->DeleteResource(a[4]);
455 ASSERT_EQ("b", listener_->ancestorId_); 456 ASSERT_EQ("b", listener_->ancestorId_);
456 ASSERT_EQ(ResourceType_Study, listener_->ancestorType_); 457 ASSERT_EQ(ResourceType_Study, listener_->ancestorType_);
457 458
458 listener_->Reset(); 459 listener_->Reset();
459 index_->DeleteResource(a[7]); 460 transaction_->DeleteResource(a[7]);
460 ASSERT_EQ("a", listener_->ancestorId_); 461 ASSERT_EQ("a", listener_->ancestorId_);
461 ASSERT_EQ(ResourceType_Patient, listener_->ancestorType_); 462 ASSERT_EQ(ResourceType_Patient, listener_->ancestorType_);
462 463
463 listener_->Reset(); 464 listener_->Reset();
464 index_->DeleteResource(a[6]); 465 transaction_->DeleteResource(a[6]);
465 ASSERT_EQ("", listener_->ancestorId_); // No more ancestor 466 ASSERT_EQ("", listener_->ancestorId_); // No more ancestor
466 } 467 }
467 468
468 469
469 TEST_F(DatabaseWrapperTest, PatientRecycling) 470 TEST_F(DatabaseWrapperTest, PatientRecycling)
470 { 471 {
471 std::vector<int64_t> patients; 472 std::vector<int64_t> patients;
472 for (int i = 0; i < 10; i++) 473 for (int i = 0; i < 10; i++)
473 { 474 {
474 std::string p = "Patient " + boost::lexical_cast<std::string>(i); 475 std::string p = "Patient " + boost::lexical_cast<std::string>(i);
475 patients.push_back(index_->CreateResource(p, ResourceType_Patient)); 476 patients.push_back(transaction_->CreateResource(p, ResourceType_Patient));
476 index_->AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10, 477 transaction_->AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10,
477 "md5-" + boost::lexical_cast<std::string>(i))); 478 "md5-" + boost::lexical_cast<std::string>(i)));
478 ASSERT_FALSE(index_->IsProtectedPatient(patients[i])); 479 ASSERT_FALSE(transaction_->IsProtectedPatient(patients[i]));
479 } 480 }
480 481
481 CheckTableRecordCount(10u, "Resources"); 482 CheckTableRecordCount(10u, "Resources");
482 CheckTableRecordCount(10u, "PatientRecyclingOrder"); 483 CheckTableRecordCount(10u, "PatientRecyclingOrder");
483 484
484 listener_->Reset(); 485 listener_->Reset();
485 ASSERT_EQ(0u, listener_->deletedResources_.size()); 486 ASSERT_EQ(0u, listener_->deletedResources_.size());
486 487
487 index_->DeleteResource(patients[5]); 488 transaction_->DeleteResource(patients[5]);
488 index_->DeleteResource(patients[0]); 489 transaction_->DeleteResource(patients[0]);
489 ASSERT_EQ(2u, listener_->deletedResources_.size()); 490 ASSERT_EQ(2u, listener_->deletedResources_.size());
490 491
491 CheckTableRecordCount(8u, "Resources"); 492 CheckTableRecordCount(8u, "Resources");
492 CheckTableRecordCount(8u, "PatientRecyclingOrder"); 493 CheckTableRecordCount(8u, "PatientRecyclingOrder");
493 494
494 ASSERT_EQ(2u, listener_->deletedFiles_.size()); 495 ASSERT_EQ(2u, listener_->deletedFiles_.size());
495 ASSERT_EQ("Patient 5", listener_->deletedFiles_[0]); 496 ASSERT_EQ("Patient 5", listener_->deletedFiles_[0]);
496 ASSERT_EQ("Patient 0", listener_->deletedFiles_[1]); 497 ASSERT_EQ("Patient 0", listener_->deletedFiles_[1]);
497 498
498 int64_t p; 499 int64_t p;
499 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[1]); 500 ASSERT_TRUE(transaction_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[1]);
500 index_->DeleteResource(p); 501 transaction_->DeleteResource(p);
501 ASSERT_EQ(3u, listener_->deletedResources_.size()); 502 ASSERT_EQ(3u, listener_->deletedResources_.size());
502 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[2]); 503 ASSERT_TRUE(transaction_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[2]);
503 index_->DeleteResource(p); 504 transaction_->DeleteResource(p);
504 ASSERT_EQ(4u, listener_->deletedResources_.size()); 505 ASSERT_EQ(4u, listener_->deletedResources_.size());
505 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[3]); 506 ASSERT_TRUE(transaction_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[3]);
506 index_->DeleteResource(p); 507 transaction_->DeleteResource(p);
507 ASSERT_EQ(5u, listener_->deletedResources_.size()); 508 ASSERT_EQ(5u, listener_->deletedResources_.size());
508 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[4]); 509 ASSERT_TRUE(transaction_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[4]);
509 index_->DeleteResource(p); 510 transaction_->DeleteResource(p);
510 ASSERT_EQ(6u, listener_->deletedResources_.size()); 511 ASSERT_EQ(6u, listener_->deletedResources_.size());
511 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[6]); 512 ASSERT_TRUE(transaction_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[6]);
512 index_->DeleteResource(p); 513 transaction_->DeleteResource(p);
513 index_->DeleteResource(patients[8]); 514 transaction_->DeleteResource(patients[8]);
514 ASSERT_EQ(8u, listener_->deletedResources_.size()); 515 ASSERT_EQ(8u, listener_->deletedResources_.size());
515 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[7]); 516 ASSERT_TRUE(transaction_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[7]);
516 index_->DeleteResource(p); 517 transaction_->DeleteResource(p);
517 ASSERT_EQ(9u, listener_->deletedResources_.size()); 518 ASSERT_EQ(9u, listener_->deletedResources_.size());
518 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[9]); 519 ASSERT_TRUE(transaction_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[9]);
519 index_->DeleteResource(p); 520 transaction_->DeleteResource(p);
520 ASSERT_FALSE(index_->SelectPatientToRecycle(p)); 521 ASSERT_FALSE(transaction_->SelectPatientToRecycle(p));
521 ASSERT_EQ(10u, listener_->deletedResources_.size()); 522 ASSERT_EQ(10u, listener_->deletedResources_.size());
522 523
523 ASSERT_EQ(10u, listener_->deletedFiles_.size()); 524 ASSERT_EQ(10u, listener_->deletedFiles_.size());
524 525
525 CheckTableRecordCount(0, "Resources"); 526 CheckTableRecordCount(0, "Resources");
531 { 532 {
532 std::vector<int64_t> patients; 533 std::vector<int64_t> patients;
533 for (int i = 0; i < 5; i++) 534 for (int i = 0; i < 5; i++)
534 { 535 {
535 std::string p = "Patient " + boost::lexical_cast<std::string>(i); 536 std::string p = "Patient " + boost::lexical_cast<std::string>(i);
536 patients.push_back(index_->CreateResource(p, ResourceType_Patient)); 537 patients.push_back(transaction_->CreateResource(p, ResourceType_Patient));
537 index_->AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10, 538 transaction_->AddAttachment(patients[i], FileInfo(p, FileContentType_Dicom, i + 10,
538 "md5-" + boost::lexical_cast<std::string>(i))); 539 "md5-" + boost::lexical_cast<std::string>(i)));
539 ASSERT_FALSE(index_->IsProtectedPatient(patients[i])); 540 ASSERT_FALSE(transaction_->IsProtectedPatient(patients[i]));
540 } 541 }
541 542
542 CheckTableRecordCount(5, "Resources"); 543 CheckTableRecordCount(5, "Resources");
543 CheckTableRecordCount(5, "PatientRecyclingOrder"); 544 CheckTableRecordCount(5, "PatientRecyclingOrder");
544 545
545 ASSERT_FALSE(index_->IsProtectedPatient(patients[2])); 546 ASSERT_FALSE(transaction_->IsProtectedPatient(patients[2]));
546 index_->SetProtectedPatient(patients[2], true); 547 transaction_->SetProtectedPatient(patients[2], true);
547 ASSERT_TRUE(index_->IsProtectedPatient(patients[2])); 548 ASSERT_TRUE(transaction_->IsProtectedPatient(patients[2]));
548 CheckTableRecordCount(5, "Resources"); 549 CheckTableRecordCount(5, "Resources");
549 CheckTableRecordCount(4, "PatientRecyclingOrder"); 550 CheckTableRecordCount(4, "PatientRecyclingOrder");
550 551
551 index_->SetProtectedPatient(patients[2], true); 552 transaction_->SetProtectedPatient(patients[2], true);
552 ASSERT_TRUE(index_->IsProtectedPatient(patients[2])); 553 ASSERT_TRUE(transaction_->IsProtectedPatient(patients[2]));
553 CheckTableRecordCount(4, "PatientRecyclingOrder"); 554 CheckTableRecordCount(4, "PatientRecyclingOrder");
554 index_->SetProtectedPatient(patients[2], false); 555 transaction_->SetProtectedPatient(patients[2], false);
555 ASSERT_FALSE(index_->IsProtectedPatient(patients[2])); 556 ASSERT_FALSE(transaction_->IsProtectedPatient(patients[2]));
556 CheckTableRecordCount(5, "PatientRecyclingOrder"); 557 CheckTableRecordCount(5, "PatientRecyclingOrder");
557 index_->SetProtectedPatient(patients[2], false); 558 transaction_->SetProtectedPatient(patients[2], false);
558 ASSERT_FALSE(index_->IsProtectedPatient(patients[2])); 559 ASSERT_FALSE(transaction_->IsProtectedPatient(patients[2]));
559 CheckTableRecordCount(5, "PatientRecyclingOrder"); 560 CheckTableRecordCount(5, "PatientRecyclingOrder");
560 CheckTableRecordCount(5, "Resources"); 561 CheckTableRecordCount(5, "Resources");
561 index_->SetProtectedPatient(patients[2], true); 562 transaction_->SetProtectedPatient(patients[2], true);
562 ASSERT_TRUE(index_->IsProtectedPatient(patients[2])); 563 ASSERT_TRUE(transaction_->IsProtectedPatient(patients[2]));
563 CheckTableRecordCount(4, "PatientRecyclingOrder"); 564 CheckTableRecordCount(4, "PatientRecyclingOrder");
564 index_->SetProtectedPatient(patients[2], false); 565 transaction_->SetProtectedPatient(patients[2], false);
565 ASSERT_FALSE(index_->IsProtectedPatient(patients[2])); 566 ASSERT_FALSE(transaction_->IsProtectedPatient(patients[2]));
566 CheckTableRecordCount(5, "PatientRecyclingOrder"); 567 CheckTableRecordCount(5, "PatientRecyclingOrder");
567 index_->SetProtectedPatient(patients[3], true); 568 transaction_->SetProtectedPatient(patients[3], true);
568 ASSERT_TRUE(index_->IsProtectedPatient(patients[3])); 569 ASSERT_TRUE(transaction_->IsProtectedPatient(patients[3]));
569 CheckTableRecordCount(4, "PatientRecyclingOrder"); 570 CheckTableRecordCount(4, "PatientRecyclingOrder");
570 571
571 CheckTableRecordCount(5, "Resources"); 572 CheckTableRecordCount(5, "Resources");
572 ASSERT_EQ(0u, listener_->deletedFiles_.size()); 573 ASSERT_EQ(0u, listener_->deletedFiles_.size());
573 574
574 // Unprotecting a patient puts it at the last position in the recycling queue 575 // Unprotecting a patient puts it at the last position in the recycling queue
575 int64_t p; 576 int64_t p;
576 ASSERT_EQ(0u, listener_->deletedResources_.size()); 577 ASSERT_EQ(0u, listener_->deletedResources_.size());
577 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[0]); 578 ASSERT_TRUE(transaction_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[0]);
578 index_->DeleteResource(p); 579 transaction_->DeleteResource(p);
579 ASSERT_EQ(1u, listener_->deletedResources_.size()); 580 ASSERT_EQ(1u, listener_->deletedResources_.size());
580 ASSERT_TRUE(index_->SelectPatientToRecycle(p, patients[1])); ASSERT_EQ(p, patients[4]); 581 ASSERT_TRUE(transaction_->SelectPatientToRecycle(p, patients[1])); ASSERT_EQ(p, patients[4]);
581 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[1]); 582 ASSERT_TRUE(transaction_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[1]);
582 index_->DeleteResource(p); 583 transaction_->DeleteResource(p);
583 ASSERT_EQ(2u, listener_->deletedResources_.size()); 584 ASSERT_EQ(2u, listener_->deletedResources_.size());
584 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[4]); 585 ASSERT_TRUE(transaction_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[4]);
585 index_->DeleteResource(p); 586 transaction_->DeleteResource(p);
586 ASSERT_EQ(3u, listener_->deletedResources_.size()); 587 ASSERT_EQ(3u, listener_->deletedResources_.size());
587 ASSERT_FALSE(index_->SelectPatientToRecycle(p, patients[2])); 588 ASSERT_FALSE(transaction_->SelectPatientToRecycle(p, patients[2]));
588 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[2]); 589 ASSERT_TRUE(transaction_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[2]);
589 index_->DeleteResource(p); 590 transaction_->DeleteResource(p);
590 ASSERT_EQ(4u, listener_->deletedResources_.size()); 591 ASSERT_EQ(4u, listener_->deletedResources_.size());
591 // "patients[3]" is still protected 592 // "patients[3]" is still protected
592 ASSERT_FALSE(index_->SelectPatientToRecycle(p)); 593 ASSERT_FALSE(transaction_->SelectPatientToRecycle(p));
593 594
594 ASSERT_EQ(4u, listener_->deletedFiles_.size()); 595 ASSERT_EQ(4u, listener_->deletedFiles_.size());
595 CheckTableRecordCount(1, "Resources"); 596 CheckTableRecordCount(1, "Resources");
596 CheckTableRecordCount(0, "PatientRecyclingOrder"); 597 CheckTableRecordCount(0, "PatientRecyclingOrder");
597 598
598 index_->SetProtectedPatient(patients[3], false); 599 transaction_->SetProtectedPatient(patients[3], false);
599 CheckTableRecordCount(1, "PatientRecyclingOrder"); 600 CheckTableRecordCount(1, "PatientRecyclingOrder");
600 ASSERT_FALSE(index_->SelectPatientToRecycle(p, patients[3])); 601 ASSERT_FALSE(transaction_->SelectPatientToRecycle(p, patients[3]));
601 ASSERT_TRUE(index_->SelectPatientToRecycle(p, patients[2])); 602 ASSERT_TRUE(transaction_->SelectPatientToRecycle(p, patients[2]));
602 ASSERT_TRUE(index_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[3]); 603 ASSERT_TRUE(transaction_->SelectPatientToRecycle(p)); ASSERT_EQ(p, patients[3]);
603 index_->DeleteResource(p); 604 transaction_->DeleteResource(p);
604 ASSERT_EQ(5u, listener_->deletedResources_.size()); 605 ASSERT_EQ(5u, listener_->deletedResources_.size());
605 606
606 ASSERT_EQ(5u, listener_->deletedFiles_.size()); 607 ASSERT_EQ(5u, listener_->deletedFiles_.size());
607 CheckTableRecordCount(0, "Resources"); 608 CheckTableRecordCount(0, "Resources");
608 CheckTableRecordCount(0, "PatientRecyclingOrder"); 609 CheckTableRecordCount(0, "PatientRecyclingOrder");
633 634
634 635
635 TEST_F(DatabaseWrapperTest, LookupIdentifier) 636 TEST_F(DatabaseWrapperTest, LookupIdentifier)
636 { 637 {
637 int64_t a[] = { 638 int64_t a[] = {
638 index_->CreateResource("a", ResourceType_Study), // 0 639 transaction_->CreateResource("a", ResourceType_Study), // 0
639 index_->CreateResource("b", ResourceType_Study), // 1 640 transaction_->CreateResource("b", ResourceType_Study), // 1
640 index_->CreateResource("c", ResourceType_Study), // 2 641 transaction_->CreateResource("c", ResourceType_Study), // 2
641 index_->CreateResource("d", ResourceType_Series) // 3 642 transaction_->CreateResource("d", ResourceType_Series) // 3
642 }; 643 };
643 644
644 index_->SetIdentifierTag(a[0], DICOM_TAG_STUDY_INSTANCE_UID, "0"); 645 transaction_->SetIdentifierTag(a[0], DICOM_TAG_STUDY_INSTANCE_UID, "0");
645 index_->SetIdentifierTag(a[1], DICOM_TAG_STUDY_INSTANCE_UID, "1"); 646 transaction_->SetIdentifierTag(a[1], DICOM_TAG_STUDY_INSTANCE_UID, "1");
646 index_->SetIdentifierTag(a[2], DICOM_TAG_STUDY_INSTANCE_UID, "0"); 647 transaction_->SetIdentifierTag(a[2], DICOM_TAG_STUDY_INSTANCE_UID, "0");
647 index_->SetIdentifierTag(a[3], DICOM_TAG_SERIES_INSTANCE_UID, "0"); 648 transaction_->SetIdentifierTag(a[3], DICOM_TAG_SERIES_INSTANCE_UID, "0");
648 649
649 std::list<std::string> s; 650 std::list<std::string> s;
650 651
651 DoLookupIdentifier(s, ResourceType_Study, DICOM_TAG_STUDY_INSTANCE_UID, ConstraintType_Equal, "0"); 652 DoLookupIdentifier(s, ResourceType_Study, DICOM_TAG_STUDY_INSTANCE_UID, ConstraintType_Equal, "0");
652 ASSERT_EQ(2u, s.size()); 653 ASSERT_EQ(2u, s.size());