Test: Add unit test for PSU plug out and in

Split the function into two, one for handling the sdbus::message, the
other for handling the changed properties, so that it's easier to write
unit test cases.

Added the test cases:
* On a system with a PSU present, remove the PSU;
* On a system without PSU, plug the PSU in;
* On a system with a PSU, remove the PSU and add it back, while the
  propertiesChanged callback is invoked with both Present and Version
  properties.
* On a system with two PSUs with same version, remove them one-by-one,
  and add back one-by-one, while PSU1 has a different version.

Tested: Verify ItemUpdater correctly handles the above cases:
        * Remove the activation and version object if PSU is removed;
        * Create activation and version object if PSU is added;
        * When there are two PSUs with same version, removing one only
          update the associations, removing the other shall result in
          the objects to be removed;
          Adding one back will create the objects, and adding the other
          one with different version will create new objects.

Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: I14c7ae9f03ec91bb1c85bb5a18d69f20dc1efd53
diff --git a/src/item_updater.cpp b/src/item_updater.cpp
index 6c55062..89bd388 100644
--- a/src/item_updater.cpp
+++ b/src/item_updater.cpp
@@ -286,20 +286,22 @@
     return version;
 }
 
-void ItemUpdater::onPsuInventoryChanged(sdbusplus::message::message& msg)
+void ItemUpdater::onPsuInventoryChangedMsg(sdbusplus::message::message& msg)
 {
     using Interface = std::string;
-    using Property = std::string;
-    using Properties =
-        std::map<Property, sdbusplus::message::variant<bool, std::string>>;
-
     Interface interface;
     Properties properties;
-    std::optional<bool> present;
-    std::optional<std::string> version;
     std::string psuPath = msg.get_path();
 
     msg.read(interface, properties);
+    onPsuInventoryChanged(psuPath, properties);
+}
+
+void ItemUpdater::onPsuInventoryChanged(const std::string& psuPath,
+                                        const Properties& properties)
+{
+    std::optional<bool> present;
+    std::optional<std::string> version;
 
     // The code was expecting to get callback on mutliple properties changed.
     // But in practice, the callback is received one-by-one for each property.
@@ -370,7 +372,7 @@
             MatchRules::type::signal() + MatchRules::path(p) +
                 MatchRules::member("PropertiesChanged") +
                 MatchRules::interface("org.freedesktop.DBus.Properties"),
-            std::bind(&ItemUpdater::onPsuInventoryChanged, this,
+            std::bind(&ItemUpdater::onPsuInventoryChangedMsg, this,
                       std::placeholders::_1));
     }
 }