Read persistent triggers from storage

Read json storage file for persistent triggers.
Add trigger to telemetry service.
Cover code with UTs.

Tested:
  - Passed unit tests
  - Tested on QEMU
    * starting app without configuration
    * restart app with configuration stored
    * restart app with configuration in incorrect version
    * restart app with configuration malformed

Change-Id: I2cb9324abdb8323be8a7f0c932ed7f70c5bc2891
Signed-off-by: Cezary Zwolak <cezary.zwolak@intel.com>
Signed-off-by: Lukasz Kazmierczak <lukasz.kazmierczak@intel.com>
diff --git a/tests/src/mocks/trigger_factory_mock.hpp b/tests/src/mocks/trigger_factory_mock.hpp
index 8249799..3682a46 100644
--- a/tests/src/mocks/trigger_factory_mock.hpp
+++ b/tests/src/mocks/trigger_factory_mock.hpp
@@ -3,6 +3,8 @@
 #include "interfaces/trigger_factory.hpp"
 #include "mocks/trigger_mock.hpp"
 #include "params/trigger_params.hpp"
+#include "trigger.hpp"
+#include "utils/conversion_trigger.hpp"
 
 #include <gmock/gmock.h>
 
@@ -13,26 +15,28 @@
     {
         using namespace testing;
 
-        ON_CALL(*this, make(_, _, _, _, _, _, _, _, _, _, _))
-            .WillByDefault(WithArgs<1>(Invoke([](const std::string& name) {
+        ON_CALL(*this, make(A<const std::string&>(), _, _, _, _, _, _, _, _, _))
+            .WillByDefault(WithArgs<0>(Invoke([](const std::string& name) {
                 return std::make_unique<NiceMock<TriggerMock>>(name);
             })));
     }
 
-    MOCK_METHOD(
-        std::unique_ptr<interfaces::Trigger>, make,
-        (boost::asio::yield_context&, const std::string& name, bool isDiscrete,
-         bool logToJournal, bool logToRedfish, bool updateReport,
-         (const std::vector<
-             std::pair<sdbusplus::message::object_path, std::string>>& sensors),
-         const std::vector<std::string>& reportNames,
-         const TriggerThresholdParams& thresholdParams,
-         interfaces::TriggerManager& triggerManager,
-         interfaces::JsonStorage& triggerStorage),
-        (const, override));
+    MOCK_METHOD(std::unique_ptr<interfaces::Trigger>, make,
+                (const std::string& name, bool isDiscrete, bool logToJournal,
+                 bool logToRedfish, bool updateReport,
+                 const std::vector<std::string>& reportNames,
+                 interfaces::TriggerManager& triggerManager,
+                 interfaces::JsonStorage& triggerStorage,
+                 const LabeledTriggerThresholdParams& labeledThresholdParams,
+                 const std::vector<LabeledSensorInfo>& labeledSensorsInfo),
+                (const, override));
+
+    MOCK_METHOD(std::vector<LabeledSensorInfo>, getLabeledSensorsInfo,
+                (boost::asio::yield_context&, const SensorsInfo&),
+                (const, override));
 
     auto& expectMake(
-        std::optional<std::reference_wrapper<const TriggerParams>> paramsOpt,
+        std::optional<TriggerParams> paramsOpt,
         const testing::Matcher<interfaces::TriggerManager&>& tm,
         const testing::Matcher<interfaces::JsonStorage&>& triggerStorage)
     {
@@ -41,17 +45,32 @@
         if (paramsOpt)
         {
             const TriggerParams& params = *paramsOpt;
+
+            const auto sensorInfos =
+                utils::fromLabeledSensorsInfo(params.sensors());
+
+            ON_CALL(*this, getLabeledSensorsInfo(_, sensorInfos))
+                .WillByDefault(Return(params.sensors()));
+
             return EXPECT_CALL(
-                *this, make(_, params.name(), params.isDiscrete(),
-                            params.logToJournal(), params.logToRedfish(),
-                            params.updateReport(), params.sensors(),
-                            params.reportNames(), params.thresholdParams(), tm,
-                            triggerStorage));
+                *this,
+                make(params.name(), params.isDiscrete(), params.logToJournal(),
+                     params.logToRedfish(), params.updateReport(),
+                     params.reportNames(), tm, triggerStorage,
+                     params.thresholdParams(), params.sensors()));
         }
         else
         {
+            const std::vector<LabeledSensorInfo> dummy = {
+                {"service99",
+                 "/xyz/openbmc_project/sensors/temperature/BMC_Temp99",
+                 "metadata99"}};
+
+            ON_CALL(*this, getLabeledSensorsInfo(_, _))
+                .WillByDefault(Return(dummy));
+
             return EXPECT_CALL(
-                *this, make(_, _, _, _, _, _, _, _, _, tm, triggerStorage));
+                *this, make(_, _, _, _, _, _, tm, triggerStorage, _, dummy));
         }
     }
 };