sensor-cache: Implement inventory::get::assertion()

Implement inventory::get::assertion() similar to get::assertion().
Not tested as we do not use this function.

Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: Iaee109cee4cb947878733a617a466f499fab3e7c
diff --git a/sensordatahandler.cpp b/sensordatahandler.cpp
index ef18a8f..d502268 100644
--- a/sensordatahandler.cpp
+++ b/sensordatahandler.cpp
@@ -459,6 +459,8 @@
 namespace get
 {
 
+#ifndef FEATURE_SENSORS_CACHE
+
 GetSensorResponse assertion(const Info& sensorInfo)
 {
     namespace fs = std::filesystem;
@@ -471,6 +473,45 @@
         sensorInfo.propertyInterfaces.begin()->first);
 }
 
+#else
+
+std::optional<GetSensorResponse> assertion(uint8_t id, const Info& sensorInfo,
+                                           sdbusplus::message::message& msg)
+{
+    auto type = msg.get_type();
+    if (type == msgTypeSignal)
+    {
+        // This is signal callback
+        std::string interfaceName;
+        msg.read(interfaceName);
+        if (interfaceName != sensorInfo.sensorInterface)
+        {
+            // Not the interface we need
+            return {};
+        }
+    }
+
+    // The assertion may contain multiple properties
+    // So we have to get the properties from DBus anyway
+    namespace fs = std::filesystem;
+
+    fs::path path{ipmi::sensor::inventoryRoot};
+    path += sensorInfo.sensorPath;
+
+    auto response = ipmi::sensor::get::mapDbusToAssertion(
+        sensorInfo, path.string(),
+        sensorInfo.propertyInterfaces.begin()->first);
+
+    if (!sensorCacheMap[id].has_value())
+    {
+        sensorCacheMap[id] = SensorData{};
+    }
+    sensorCacheMap[id]->response = response;
+    return response;
+}
+
+#endif
+
 } // namespace get
 
 } // namespace inventory