diff options
Diffstat (limited to 'storage/src/tests/persistence/processalltest.cpp')
-rw-r--r-- | storage/src/tests/persistence/processalltest.cpp | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/storage/src/tests/persistence/processalltest.cpp b/storage/src/tests/persistence/processalltest.cpp index 5462b4a5b0a..0d482ebe5b7 100644 --- a/storage/src/tests/persistence/processalltest.cpp +++ b/storage/src/tests/persistence/processalltest.cpp @@ -20,10 +20,10 @@ TEST_F(ProcessAllHandlerTest, remove_location) { doPut(4, spi::Timestamp(1234)); doPut(4, spi::Timestamp(2345)); - api::RemoveLocationCommand removeLocation("id.user == 4", makeDocumentBucket(bucketId)); + document::Bucket bucket = makeDocumentBucket(bucketId); + auto cmd = std::make_shared<api::RemoveLocationCommand>("id.user == 4", bucket); ProcessAllHandler handler(getEnv(), getPersistenceProvider()); - spi::Context context(documentapi::LoadType::DEFAULT, 0, 0); - auto tracker = handler.handleRemoveLocation(removeLocation, context); + auto tracker = handler.handleRemoveLocation(*cmd, std::make_unique<MessageTracker>(getEnv(), NoBucketLock::make(bucket), cmd)); EXPECT_EQ("DocEntry(1234, 1, id:mail:testdoctype1:n=4:3619.html)\n" "DocEntry(2345, 1, id:mail:testdoctype1:n=4:4008.html)\n", @@ -45,10 +45,9 @@ TEST_F(ProcessAllHandlerTest, remove_location_document_subset) { doPut(doc, bucketId, spi::Timestamp(100 + i), 0); } - api::RemoveLocationCommand - removeLocation("testdoctype1.headerval % 2 == 0", makeDocumentBucket(bucketId)); - spi::Context context(documentapi::LoadType::DEFAULT, 0, 0); - auto tracker = handler.handleRemoveLocation(removeLocation, context); + document::Bucket bucket = makeDocumentBucket(bucketId); + auto cmd = std::make_shared<api::RemoveLocationCommand>("testdoctype1.headerval % 2 == 0", bucket); + auto tracker = handler.handleRemoveLocation(*cmd, std::make_unique<MessageTracker>(getEnv(), NoBucketLock::make(bucket), cmd)); EXPECT_EQ("DocEntry(100, 1, id:mail:testdoctype1:n=4:3619.html)\n" "DocEntry(101, 0, Doc(id:mail:testdoctype1:n=4:33113.html))\n" @@ -71,12 +70,11 @@ TEST_F(ProcessAllHandlerTest, remove_location_throws_exception_on_unknown_doc_ty document::BucketId bucketId(16, 4); doPut(4, spi::Timestamp(1234)); - api::RemoveLocationCommand - removeLocation("unknowndoctype.headerval % 2 == 0", makeDocumentBucket(bucketId)); + document::Bucket bucket = makeDocumentBucket(bucketId); + auto cmd = std::make_shared<api::RemoveLocationCommand>("unknowndoctype.headerval % 2 == 0", bucket); ProcessAllHandler handler(getEnv(), getPersistenceProvider()); - spi::Context context(documentapi::LoadType::DEFAULT, 0, 0); - ASSERT_THROW(handler.handleRemoveLocation(removeLocation, context), std::exception); + ASSERT_THROW(handler.handleRemoveLocation(*cmd, std::make_unique<MessageTracker>(getEnv(), NoBucketLock::make(bucket), cmd)), std::exception); EXPECT_EQ("DocEntry(1234, 0, Doc(id:mail:testdoctype1:n=4:3619.html))\n", dumpBucket(bucketId)); @@ -86,11 +84,11 @@ TEST_F(ProcessAllHandlerTest, remove_location_throws_exception_on_bogus_selectio document::BucketId bucketId(16, 4); doPut(4, spi::Timestamp(1234)); - api::RemoveLocationCommand removeLocation("id.bogus != badgers", makeDocumentBucket(bucketId)); + document::Bucket bucket = makeDocumentBucket(bucketId); + auto cmd = std::make_shared<api::RemoveLocationCommand>("id.bogus != badgers", bucket); ProcessAllHandler handler(getEnv(), getPersistenceProvider()); - spi::Context context(documentapi::LoadType::DEFAULT, 0, 0); - ASSERT_THROW(handler.handleRemoveLocation(removeLocation, context), std::exception); + ASSERT_THROW(handler.handleRemoveLocation(*cmd, std::make_unique<MessageTracker>(getEnv(), NoBucketLock::make(bucket), cmd)), std::exception); EXPECT_EQ("DocEntry(1234, 0, Doc(id:mail:testdoctype1:n=4:3619.html))\n", dumpBucket(bucketId)); @@ -107,10 +105,9 @@ TEST_F(ProcessAllHandlerTest, bucket_stat_request_returns_document_metadata_matc doPut(doc, bucketId, spi::Timestamp(100 + i), 0); } - api::StatBucketCommand statBucket(makeDocumentBucket(bucketId), - "testdoctype1.headerval % 2 == 0"); - spi::Context context(documentapi::LoadType::DEFAULT, 0, 0); - MessageTracker::UP tracker = handler.handleStatBucket(statBucket, context); + document::Bucket bucket = makeDocumentBucket(bucketId); + auto cmd = std::make_shared<api::StatBucketCommand>(bucket, "testdoctype1.headerval % 2 == 0"); + MessageTracker::UP tracker = handler.handleStatBucket(*cmd, std::make_unique<MessageTracker>(getEnv(), NoBucketLock::make(bucket), cmd)); ASSERT_TRUE(tracker->hasReply()); auto& reply = dynamic_cast<api::StatBucketReply&>(tracker->getReply()); @@ -142,9 +139,9 @@ TEST_F(ProcessAllHandlerTest, stat_bucket_request_can_returned_removed_entries) true); } - api::StatBucketCommand statBucket(makeDocumentBucket(bucketId), "true"); - spi::Context context(documentapi::LoadType::DEFAULT, 0, 0); - MessageTracker::UP tracker = handler.handleStatBucket(statBucket, context); + document::Bucket bucket = makeDocumentBucket(bucketId); + auto cmd = std::make_shared<api::StatBucketCommand>(bucket, "true"); + MessageTracker::UP tracker = handler.handleStatBucket(*cmd, std::make_unique<MessageTracker>(getEnv(), NoBucketLock::make(bucket), cmd)); ASSERT_TRUE(tracker->hasReply()); auto& reply = dynamic_cast<api::StatBucketReply&>(tracker->getReply()); @@ -188,9 +185,9 @@ TEST_F(ProcessAllHandlerTest, bucket_stat_request_can_return_all_put_entries_in_ doPut(doc, bucketId, spi::Timestamp(100 + i), 0); } - api::StatBucketCommand statBucket(makeDocumentBucket(bucketId), "true"); - spi::Context context(documentapi::LoadType::DEFAULT, 0, 0); - MessageTracker::UP tracker = handler.handleStatBucket(statBucket, context); + document::Bucket bucket = makeDocumentBucket(bucketId); + auto cmd = std::make_shared<api::StatBucketCommand>(bucket, "true"); + MessageTracker::UP tracker = handler.handleStatBucket(*cmd, std::make_unique<MessageTracker>(getEnv(), NoBucketLock::make(bucket), cmd)); ASSERT_TRUE(tracker->hasReply()); auto& reply = dynamic_cast<api::StatBucketReply&>(tracker->getReply()); |