comparison OrthancServer/UnitTestsSources/ServerIndexTests.cpp @ 5084:9770d537880d attach-custom-data

added support for revision in SQLite + avoid upgrading DB version
author Alain Mazy <am@osimis.io>
date Thu, 15 Sep 2022 09:02:07 +0200
parents d7274e43ea7c
children 8279eaab0d1d
comparison
equal deleted inserted replaced
5083:75e949689c08 5084:9770d537880d
293 transaction_->AddAttachment(a[4], FileInfo("my json file", FileContentType_DicomAsJson, 42, "md5", 293 transaction_->AddAttachment(a[4], FileInfo("my json file", FileContentType_DicomAsJson, 42, "md5",
294 CompressionType_ZlibWithSize, 21, "compressedMD5", "customData"), 42); 294 CompressionType_ZlibWithSize, 21, "compressedMD5", "customData"), 42);
295 transaction_->AddAttachment(a[4], FileInfo("my dicom file", FileContentType_Dicom, 42, "md5", "customData"), 43); 295 transaction_->AddAttachment(a[4], FileInfo("my dicom file", FileContentType_Dicom, 42, "md5", "customData"), 43);
296 transaction_->AddAttachment(a[6], FileInfo("world", FileContentType_Dicom, 44, "md5", "customData"), 44); 296 transaction_->AddAttachment(a[6], FileInfo("world", FileContentType_Dicom, 44, "md5", "customData"), 44);
297 297
298 // TODO - REVISIONS - "42" is revision number, that is not currently stored (*)
299 transaction_->SetMetadata(a[4], MetadataType_RemoteAet, "PINNACLE", 42); 298 transaction_->SetMetadata(a[4], MetadataType_RemoteAet, "PINNACLE", 42);
300 299
301 transaction_->GetAllMetadata(md, a[4]); 300 transaction_->GetAllMetadata(md, a[4]);
302 ASSERT_EQ(1u, md.size()); 301 ASSERT_EQ(1u, md.size());
303 ASSERT_EQ("PINNACLE", md[MetadataType_RemoteAet]); 302 ASSERT_EQ("PINNACLE", md[MetadataType_RemoteAet]);
332 ASSERT_EQ(7, b); 331 ASSERT_EQ(7, b);
333 ASSERT_EQ(ResourceType_Study, t); 332 ASSERT_EQ(ResourceType_Study, t);
334 333
335 int64_t revision; 334 int64_t revision;
336 ASSERT_TRUE(transaction_->LookupMetadata(s, revision, a[4], MetadataType_RemoteAet)); 335 ASSERT_TRUE(transaction_->LookupMetadata(s, revision, a[4], MetadataType_RemoteAet));
337 ASSERT_EQ(0, revision); // "0" instead of "42" because of (*) 336 ASSERT_EQ(42, revision);
338 ASSERT_FALSE(transaction_->LookupMetadata(s, revision, a[4], MetadataType_Instance_IndexInSeries)); 337 ASSERT_FALSE(transaction_->LookupMetadata(s, revision, a[4], MetadataType_Instance_IndexInSeries));
339 ASSERT_EQ(0, revision); 338 ASSERT_EQ(42, revision);
340 ASSERT_EQ("PINNACLE", s); 339 ASSERT_EQ("PINNACLE", s);
341 340
342 std::string u; 341 std::string u;
343 ASSERT_TRUE(transaction_->LookupMetadata(u, revision, a[4], MetadataType_RemoteAet)); 342 ASSERT_TRUE(transaction_->LookupMetadata(u, revision, a[4], MetadataType_RemoteAet));
344 ASSERT_EQ(0, revision); 343 ASSERT_EQ(42, revision);
345 ASSERT_EQ("PINNACLE", u); 344 ASSERT_EQ("PINNACLE", u);
346 ASSERT_FALSE(transaction_->LookupMetadata(u, revision, a[4], MetadataType_Instance_IndexInSeries)); 345 ASSERT_FALSE(transaction_->LookupMetadata(u, revision, a[4], MetadataType_Instance_IndexInSeries));
347 ASSERT_EQ(0, revision); 346 ASSERT_EQ(42, revision);
348 347
349 ASSERT_TRUE(transaction_->LookupGlobalProperty(s, GlobalProperty_FlushSleep, true)); 348 ASSERT_TRUE(transaction_->LookupGlobalProperty(s, GlobalProperty_FlushSleep, true));
350 ASSERT_FALSE(transaction_->LookupGlobalProperty(s, static_cast<GlobalProperty>(42), true)); 349 ASSERT_FALSE(transaction_->LookupGlobalProperty(s, static_cast<GlobalProperty>(42), true));
351 ASSERT_EQ("World", s); 350 ASSERT_EQ("World", s);
352 351
353 FileInfo att; 352 FileInfo att;
354 ASSERT_TRUE(transaction_->LookupAttachment(att, revision, a[4], FileContentType_DicomAsJson)); 353 ASSERT_TRUE(transaction_->LookupAttachment(att, revision, a[4], FileContentType_DicomAsJson));
355 ASSERT_EQ(0, revision); // "0" instead of "42" because of (*) 354 ASSERT_EQ(42, revision);
356 ASSERT_EQ("my json file", att.GetUuid()); 355 ASSERT_EQ("my json file", att.GetUuid());
357 ASSERT_EQ(21u, att.GetCompressedSize()); 356 ASSERT_EQ(21u, att.GetCompressedSize());
358 ASSERT_EQ("md5", att.GetUncompressedMD5()); 357 ASSERT_EQ("md5", att.GetUncompressedMD5());
359 ASSERT_EQ("compressedMD5", att.GetCompressedMD5()); 358 ASSERT_EQ("compressedMD5", att.GetCompressedMD5());
360 ASSERT_EQ(42u, att.GetUncompressedSize()); 359 ASSERT_EQ(42u, att.GetUncompressedSize());
361 ASSERT_EQ(CompressionType_ZlibWithSize, att.GetCompressionType()); 360 ASSERT_EQ(CompressionType_ZlibWithSize, att.GetCompressionType());
362 361
363 ASSERT_TRUE(transaction_->LookupAttachment(att, revision, a[6], FileContentType_Dicom)); 362 ASSERT_TRUE(transaction_->LookupAttachment(att, revision, a[6], FileContentType_Dicom));
364 ASSERT_EQ(0, revision); // "0" instead of "42" because of (*) 363 ASSERT_EQ(44, revision);
365 ASSERT_EQ("world", att.GetUuid()); 364 ASSERT_EQ("world", att.GetUuid());
366 ASSERT_EQ(44u, att.GetCompressedSize()); 365 ASSERT_EQ(44u, att.GetCompressedSize());
367 ASSERT_EQ("md5", att.GetUncompressedMD5()); 366 ASSERT_EQ("md5", att.GetUncompressedMD5());
368 ASSERT_EQ("md5", att.GetCompressedMD5()); 367 ASSERT_EQ("md5", att.GetCompressedMD5());
369 ASSERT_EQ(44u, att.GetUncompressedSize()); 368 ASSERT_EQ(44u, att.GetUncompressedSize());
395 transaction_->DeleteResource(a[5]); 394 transaction_->DeleteResource(a[5]);
396 ASSERT_EQ(7u, listener_->deletedResources_.size()); 395 ASSERT_EQ(7u, listener_->deletedResources_.size());
397 396
398 CheckTableRecordCount(0, "Resources"); 397 CheckTableRecordCount(0, "Resources");
399 CheckTableRecordCount(0, "AttachedFiles"); 398 CheckTableRecordCount(0, "AttachedFiles");
400 CheckTableRecordCount(3, "GlobalProperties"); 399 CheckTableRecordCount(4, "GlobalProperties");
401 400
402 std::string tmp; 401 std::string tmp;
403 ASSERT_TRUE(transaction_->LookupGlobalProperty(tmp, GlobalProperty_DatabaseSchemaVersion, true)); 402 ASSERT_TRUE(transaction_->LookupGlobalProperty(tmp, GlobalProperty_DatabaseSchemaVersion, true));
404 ASSERT_EQ("7", tmp); 403 ASSERT_EQ("6", tmp);
405 ASSERT_TRUE(transaction_->LookupGlobalProperty(tmp, GlobalProperty_FlushSleep, true)); 404 ASSERT_TRUE(transaction_->LookupGlobalProperty(tmp, GlobalProperty_FlushSleep, true));
406 ASSERT_EQ("World", tmp); 405 ASSERT_EQ("World", tmp);
407 ASSERT_TRUE(transaction_->LookupGlobalProperty(tmp, GlobalProperty_GetTotalSizeIsFast, true)); 406 ASSERT_TRUE(transaction_->LookupGlobalProperty(tmp, GlobalProperty_GetTotalSizeIsFast, true));
408 ASSERT_EQ("1", tmp); 407 ASSERT_EQ("1", tmp);
409 408