utils: Retrieval of managed objects of DBUS
This commit implements functionality to retrieve the managed object of a
specific DBUS service on a particular path. Additionally implements a
function template for inventory objects which efficiently enables
retrieval of managed object for Inventory Manager.
Tested: Added unit test cases for checking the return value.
Change-Id: Ide652f843db1623bdacebf3e269e03895bbb7f1a
Signed-off-by: Riya Dixit <riyadixitagra@gmail.com>
diff --git a/common/test/pldm_utils_test.cpp b/common/test/pldm_utils_test.cpp
index 549e289..93cf335 100644
--- a/common/test/pldm_utils_test.cpp
+++ b/common/test/pldm_utils_test.cpp
@@ -1,4 +1,5 @@
#include "common/utils.hpp"
+#include "mocked_utils.hpp"
#include <libpldm/platform.h>
@@ -6,6 +7,28 @@
using namespace pldm::utils;
+TEST(GetInventoryObjects, testForEmptyObject)
+{
+ ObjectValueTree result =
+ DBusHandler::getInventoryObjects<GetManagedEmptyObject>();
+ EXPECT_TRUE(result.empty());
+}
+
+TEST(GetInventoryObjects, testForObject)
+{
+ std::string path = "/foo/bar";
+ std::string service = "foo.bar";
+ auto result = DBusHandler::getInventoryObjects<GetManagedObject>();
+ EXPECT_EQ(result[path].begin()->first, service);
+ auto function =
+ std::get<bool>(result[path][service][std::string("Functional")]);
+ auto model =
+ std::get<std::string>(result[path][service][std::string("Model")]);
+ EXPECT_FALSE(result.empty());
+ EXPECT_TRUE(function);
+ EXPECT_EQ(model, std::string("1234 - 00Z"));
+}
+
TEST(decodeDate, testGooduintToDate)
{
uint64_t data = 20191212115959;