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/requester/mctp_endpoint_discovery.cpp b/requester/mctp_endpoint_discovery.cpp
index 1a8a6a9..a962228 100644
--- a/requester/mctp_endpoint_discovery.cpp
+++ b/requester/mctp_endpoint_discovery.cpp
@@ -20,15 +20,12 @@
                            "/xyz/openbmc_project/mctp"),
                        std::bind_front(&MctpDiscovery::dicoverEndpoints, this))
 {
-    dbus::ObjectValueTree objects;
+    pldm::utils::ObjectValueTree objects;
 
     try
     {
-        auto method = bus.new_method_call(
-            "xyz.openbmc_project.MCTP", "/xyz/openbmc_project/mctp",
-            "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
-        auto reply = bus.call(method, dbusTimeout);
-        reply.read(objects);
+        objects = pldm::utils::DBusHandler::getManagedObj(MCTPService,
+                                                          MCTPPath);
     }
     catch (const std::exception& e)
     {
diff --git a/requester/mctp_endpoint_discovery.hpp b/requester/mctp_endpoint_discovery.hpp
index 7fbe069..de3a6bd 100644
--- a/requester/mctp_endpoint_discovery.hpp
+++ b/requester/mctp_endpoint_discovery.hpp
@@ -7,6 +7,9 @@
 namespace pldm
 {
 
+constexpr auto MCTPService = "xyz.openbmc_project.MCTP";
+constexpr auto MCTPPath = "/xyz/openbmc_project/mctp";
+
 class MctpDiscovery
 {
   public: