diff --git a/services/tunnelbroker/test/DatabaseManagerTest.cpp b/services/tunnelbroker/test/DatabaseManagerTest.cpp --- a/services/tunnelbroker/test/DatabaseManagerTest.cpp +++ b/services/tunnelbroker/test/DatabaseManagerTest.cpp @@ -22,3 +22,29 @@ Aws::ShutdownAPI({}); } }; + +TEST_F(DatabaseManagerTest, TestOperationsOnMessageItem) { + const database::MessageItem item( + tools::generateUUID(), + "mobile:" + tools::generateRandomString(DEVICEID_CHAR_LENGTH), + "mobile:" + tools::generateRandomString(DEVICEID_CHAR_LENGTH), + tools::generateRandomString(256), + tools::generateRandomString(256), + static_cast(std::time(0)) + 600); + EXPECT_EQ( + database::DatabaseManager::getInstance().isTableAvailable( + item.getTableName()), + true); + database::DatabaseManager::getInstance().putMessageItem(item); + std::shared_ptr foundItem = + database::DatabaseManager::getInstance().findMessageItem( + item.getMessageID()); + EXPECT_NE(foundItem, nullptr); + EXPECT_EQ(item.getFromDeviceID(), foundItem->getFromDeviceID()); + EXPECT_EQ(item.getToDeviceID(), foundItem->getToDeviceID()); + EXPECT_EQ(item.getPayload(), foundItem->getPayload()); + EXPECT_EQ(item.getBlobHashes(), foundItem->getBlobHashes()); + EXPECT_EQ(item.getExpire() == foundItem->getExpire(), true); + database::DatabaseManager::getInstance().removeMessageItem( + item.getMessageID()); +}