Trigger: make dbus properties writable

This change allows to modify 'Sensors', 'ReportNames' and 'Thresholds'
dbus properties of Trigger interface. They are required by Redfish to
implement PATCH functionality for Trigger schema.

Some backend changes were required to enable this functionality, and as
such few improvements were made for existing code:
- NumericThreshold and DiscreteThreshold now have common implementation
  where it was possible.
- Internal sensor info structure for Trigger is now the same as the one
  used for Report. This resulted in breaking compatibility with previous
  Trigger persistency data.
- Added getInfo / getParams methods for Sensor and Threshold interfaces.
  They are used by Trigger dbus getters and persistency mechanism now,
  instead of storing this data in Trigger object.

Testing done:
- Unit tests were expanded and are passing
- dbus setters for Sensors and Thresholds are working and modifications
  are reflected by calling appropriate getters.

Signed-off-by: Szymon Dompke <szymon.dompke@intel.com>
Change-Id: I7a14c15a30d78ce872342b5f938aba43c77be9c0
diff --git a/tests/src/mocks/report_factory_mock.hpp b/tests/src/mocks/report_factory_mock.hpp
index 58c71d6..c2e4dd2 100644
--- a/tests/src/mocks/report_factory_mock.hpp
+++ b/tests/src/mocks/report_factory_mock.hpp
@@ -16,7 +16,7 @@
             return LabeledMetricParameters(
                 utils::transform(std::get<0>(params),
                                  [](const auto& sensorData) {
-                                     return LabeledSensorParameters(
+                                     return LabeledSensorInfo(
                                          "Service", std::get<0>(sensorData),
                                          std::get<1>(sensorData));
                                  }),
diff --git a/tests/src/mocks/sensor_mock.hpp b/tests/src/mocks/sensor_mock.hpp
index 9ff72e2..9b7f28b 100644
--- a/tests/src/mocks/sensor_mock.hpp
+++ b/tests/src/mocks/sensor_mock.hpp
@@ -1,6 +1,7 @@
 #pragma once
 
 #include "interfaces/sensor.hpp"
+#include "utils/conv_container.hpp"
 #include "utils/generate_unique_mock_id.hpp"
 
 #include <gmock/gmock.h>
@@ -23,12 +24,30 @@
         return Id("SensorMock", service, path);
     }
 
+    static std::vector<std::shared_ptr<interfaces::Sensor>>
+        makeSensorMocks(const std::vector<LabeledSensorInfo>& sensorsInfo)
+    {
+        using namespace testing;
+        std::vector<std::shared_ptr<NiceMock<SensorMock>>> result;
+        for (const auto& sensorInfo : sensorsInfo)
+        {
+            auto& sensorMock =
+                result.emplace_back(std::make_shared<NiceMock<SensorMock>>());
+            ON_CALL(*sensorMock, getLabeledSensorInfo())
+                .WillByDefault(Return(sensorInfo));
+        }
+        return utils::convContainer<std::shared_ptr<interfaces::Sensor>>(
+            result);
+    }
+
     MOCK_METHOD(Id, id, (), (const, override));
     MOCK_METHOD(std::string, metadata, (), (const, override));
+    MOCK_METHOD(std::string, getName, (), (const, override));
     MOCK_METHOD(void, registerForUpdates,
                 (const std::weak_ptr<interfaces::SensorListener>&), (override));
     MOCK_METHOD(void, unregisterFromUpdates,
                 (const std::weak_ptr<interfaces::SensorListener>&), (override));
+    MOCK_METHOD(LabeledSensorInfo, getLabeledSensorInfo, (), (const, override));
 
     const uint64_t mockId = generateUniqueMockId();
 
diff --git a/tests/src/mocks/threshold_mock.hpp b/tests/src/mocks/threshold_mock.hpp
new file mode 100644
index 0000000..2f81b60
--- /dev/null
+++ b/tests/src/mocks/threshold_mock.hpp
@@ -0,0 +1,64 @@
+#pragma once
+
+#include "interfaces/sensor.hpp"
+#include "interfaces/threshold.hpp"
+#include "utils/conv_container.hpp"
+
+#include <vector>
+
+#include <gmock/gmock.h>
+
+class ThresholdMock :
+    public interfaces::Threshold,
+    public std::enable_shared_from_this<ThresholdMock>
+{
+  public:
+    MOCK_METHOD(void, initialize, (), (override));
+
+    MOCK_METHOD(LabeledThresholdParam, getThresholdParam, (),
+                (const, override));
+
+    MOCK_METHOD(void, updateSensors, (Sensors newSensors), (override));
+
+    static std::vector<std::shared_ptr<interfaces::Threshold>>
+        makeThresholds(const LabeledTriggerThresholdParams& params)
+    {
+        using namespace testing;
+        std::vector<std::shared_ptr<NiceMock<ThresholdMock>>> result;
+        if (std::holds_alternative<std::vector<numeric::LabeledThresholdParam>>(
+                params))
+        {
+            auto unpackedParams =
+                std::get<std::vector<numeric::LabeledThresholdParam>>(params);
+            for (const auto& param : unpackedParams)
+            {
+                auto& thresholdMock = result.emplace_back(
+                    std::make_shared<NiceMock<ThresholdMock>>());
+                ON_CALL(*thresholdMock, getThresholdParam())
+                    .WillByDefault(Return(param));
+            }
+        }
+        else
+        {
+            auto unpackedParams =
+                std::get<std::vector<discrete::LabeledThresholdParam>>(params);
+            for (const auto& param : unpackedParams)
+            {
+                auto& thresholdMock = result.emplace_back(
+                    std::make_shared<NiceMock<ThresholdMock>>());
+                ON_CALL(*thresholdMock, getThresholdParam())
+                    .WillByDefault(Return(param));
+            }
+            if (unpackedParams.empty())
+            {
+                auto& thresholdMock = result.emplace_back(
+                    std::make_shared<NiceMock<ThresholdMock>>());
+                ON_CALL(*thresholdMock, getThresholdParam())
+                    .WillByDefault(Return(std::monostate{}));
+            }
+        }
+
+        return utils::convContainer<std::shared_ptr<interfaces::Threshold>>(
+            result);
+    }
+};
diff --git a/tests/src/mocks/trigger_factory_mock.hpp b/tests/src/mocks/trigger_factory_mock.hpp
index 9fa2f48..80a62a1 100644
--- a/tests/src/mocks/trigger_factory_mock.hpp
+++ b/tests/src/mocks/trigger_factory_mock.hpp
@@ -5,6 +5,7 @@
 #include "params/trigger_params.hpp"
 #include "trigger.hpp"
 #include "utils/conversion_trigger.hpp"
+#include "utils/transform.hpp"
 
 #include <gmock/gmock.h>
 
@@ -35,6 +36,23 @@
                 (boost::asio::yield_context&, const SensorsInfo&),
                 (const, override));
 
+    MOCK_METHOD(std::vector<LabeledSensorInfo>, getLabeledSensorsInfo,
+                (const SensorsInfo&), (const, override));
+
+    MOCK_METHOD(void, updateThresholds,
+                (std::vector<std::shared_ptr<interfaces::Threshold>> &
+                     currentThresholds,
+                 const std::vector<TriggerAction>& triggerActions,
+                 const std::shared_ptr<std::vector<std::string>>& reportIds,
+                 const Sensors& sensors,
+                 const LabeledTriggerThresholdParams& newParams),
+                (const, override));
+
+    MOCK_METHOD(void, updateSensors,
+                (Sensors & currentSensors,
+                 const std::vector<LabeledSensorInfo>& senorParams),
+                (const, override));
+
     auto& expectMake(
         std::optional<TriggerParams> paramsOpt,
         const testing::Matcher<interfaces::TriggerManager&>& tm,
@@ -53,7 +71,11 @@
                 .WillByDefault(Return(params.sensors()));
 
             return EXPECT_CALL(
-                *this, make(params.id(), params.name(), params.triggerActions(),
+                *this, make(params.id(), params.name(),
+                            utils::transform(params.triggerActions(),
+                                             [](const auto& action) {
+                                                 return actionToString(action);
+                                             }),
                             params.reportIds(), tm, triggerStorage,
                             params.thresholdParams(), params.sensors()));
         }
diff --git a/tests/src/params/report_params.hpp b/tests/src/params/report_params.hpp
index 47e74e3..19ea519 100644
--- a/tests/src/params/report_params.hpp
+++ b/tests/src/params/report_params.hpp
@@ -118,17 +118,17 @@
     ReportUpdates reportUpdatesProperty = ReportUpdates::overwrite;
     std::vector<LabeledMetricParameters> metricParametersProperty{
         {LabeledMetricParameters{
-             {LabeledSensorParameters{"Service",
-                                      "/xyz/openbmc_project/sensors/power/p1",
-                                      "metadata1"}},
+             {LabeledSensorInfo{"Service",
+                                "/xyz/openbmc_project/sensors/power/p1",
+                                "metadata1"}},
              OperationType::single,
              "MetricId1",
              CollectionTimeScope::point,
              CollectionDuration(Milliseconds(0u))},
          LabeledMetricParameters{
-             {LabeledSensorParameters{"Service",
-                                      "/xyz/openbmc_project/sensors/power/p2",
-                                      "metadata2"}},
+             {LabeledSensorInfo{"Service",
+                                "/xyz/openbmc_project/sensors/power/p2",
+                                "metadata2"}},
              OperationType::single,
              "MetricId2",
              CollectionTimeScope::point,
diff --git a/tests/src/params/trigger_params.hpp b/tests/src/params/trigger_params.hpp
index 886cf78..ea7f7dc 100644
--- a/tests/src/params/trigger_params.hpp
+++ b/tests/src/params/trigger_params.hpp
@@ -33,13 +33,13 @@
         return nameProperty;
     }
 
-    TriggerParams& triggerActions(const std::vector<std::string>& val)
+    TriggerParams& triggerActions(const std::vector<TriggerAction>& val)
     {
         triggerActionsProperty = val;
         return *this;
     }
 
-    const std::vector<std::string>& triggerActions() const
+    const std::vector<TriggerAction>& triggerActions() const
     {
         return triggerActionsProperty;
     }
@@ -68,8 +68,8 @@
   private:
     std::string idProperty = "Trigger1";
     std::string nameProperty = "My Numeric Trigger";
-    std::vector<std::string> triggerActionsProperty = {"UpdateReport"};
-
+    std::vector<TriggerAction> triggerActionsProperty = {
+        TriggerAction::UpdateReport};
     std::vector<LabeledSensorInfo> labeledSensorsProperty = {
         {"service1", "/xyz/openbmc_project/sensors/temperature/BMC_Temp",
          "metadata1"}};
diff --git a/tests/src/test_discrete_threshold.cpp b/tests/src/test_discrete_threshold.cpp
index 3dd2baa..ebd50cc 100644
--- a/tests/src/test_discrete_threshold.cpp
+++ b/tests/src/test_discrete_threshold.cpp
@@ -23,8 +23,9 @@
     TriggerActionMock& actionMock = *actionMockPtr;
     std::shared_ptr<DiscreteThreshold> sut;
 
-    std::shared_ptr<DiscreteThreshold> makeThreshold(Milliseconds dwellTime,
-                                                     double thresholdValue)
+    std::shared_ptr<DiscreteThreshold>
+        makeThreshold(Milliseconds dwellTime, double thresholdValue,
+                      discrete::Severity severity = discrete::Severity::ok)
     {
         std::vector<std::unique_ptr<interfaces::TriggerAction>> actions;
         actions.push_back(std::move(actionMockPtr));
@@ -33,13 +34,19 @@
             DbusEnvironment::getIoc(),
             utils::convContainer<std::shared_ptr<interfaces::Sensor>>(
                 sensorMocks),
-            sensorNames, std::move(actions), dwellTime, thresholdValue,
-            "treshold_name");
+            std::move(actions), dwellTime, thresholdValue, "treshold name",
+            severity);
     }
 
     void SetUp() override
     {
-        sut = makeThreshold(0ms, 90.0);
+        for (size_t idx = 0; idx < sensorMocks.size(); idx++)
+        {
+            ON_CALL(*sensorMocks.at(idx), getName())
+                .WillByDefault(Return(sensorNames[idx]));
+        }
+
+        sut = makeThreshold(0ms, 90.0, discrete::Severity::critical);
     }
 };
 
@@ -61,6 +68,13 @@
     EXPECT_CALL(actionMock, commit(_, _, _)).Times(0);
 }
 
+TEST_F(TestDiscreteThreshold, getLabeledParamsReturnsCorrectly)
+{
+    LabeledThresholdParam expected = discrete::LabeledThresholdParam(
+        "treshold name", discrete::Severity::critical, 0, std::to_string(90.0));
+    EXPECT_EQ(sut->getThresholdParam(), expected);
+}
+
 struct DiscreteParams
 {
     struct UpdateParams
@@ -200,6 +214,13 @@
   public:
     void SetUp() override
     {
+
+        for (size_t idx = 0; idx < sensorMocks.size(); idx++)
+        {
+            ON_CALL(*sensorMocks.at(idx), getName())
+                .WillByDefault(Return(sensorNames[idx]));
+        }
+
         sut = makeThreshold(0ms, GetParam().thresholdValue);
     }
 };
@@ -235,6 +256,12 @@
   public:
     void SetUp() override
     {
+        for (size_t idx = 0; idx < sensorMocks.size(); idx++)
+        {
+            ON_CALL(*sensorMocks.at(idx), getName())
+                .WillByDefault(Return(sensorNames[idx]));
+        }
+
         sut = makeThreshold(GetParam().dwellTime, GetParam().thresholdValue);
     }
 };
diff --git a/tests/src/test_metric.cpp b/tests/src/test_metric.cpp
index bd1d8c4..fcb2ded 100644
--- a/tests/src/test_metric.cpp
+++ b/tests/src/test_metric.cpp
@@ -145,7 +145,7 @@
     expected.at_label<ts::CollectionTimeScope>() = params.collectionTimeScope();
     expected.at_label<ts::CollectionDuration>() = params.collectionDuration();
     expected.at_label<ts::SensorPath>() = {
-        LabeledSensorParameters("service1", "path1", "metadata1")};
+        LabeledSensorInfo("service1", "path1", "metadata1")};
 
     EXPECT_THAT(conf, Eq(expected));
 }
diff --git a/tests/src/test_numeric_threshold.cpp b/tests/src/test_numeric_threshold.cpp
index 851d4a9..65c976c 100644
--- a/tests/src/test_numeric_threshold.cpp
+++ b/tests/src/test_numeric_threshold.cpp
@@ -23,7 +23,8 @@
     std::shared_ptr<NumericThreshold> sut;
 
     void makeThreshold(Milliseconds dwellTime, numeric::Direction direction,
-                       double thresholdValue)
+                       double thresholdValue,
+                       numeric::Type type = numeric::Type::lowerWarning)
     {
         std::vector<std::unique_ptr<interfaces::TriggerAction>> actions;
         actions.push_back(std::move(actionMockPtr));
@@ -32,13 +33,19 @@
             DbusEnvironment::getIoc(),
             utils::convContainer<std::shared_ptr<interfaces::Sensor>>(
                 sensorMocks),
-            sensorNames, std::move(actions), dwellTime, direction,
-            thresholdValue);
+            std::move(actions), dwellTime, direction, thresholdValue, type);
     }
 
     void SetUp() override
     {
-        makeThreshold(0ms, numeric::Direction::increasing, 90.0);
+        for (size_t idx = 0; idx < sensorMocks.size(); idx++)
+        {
+            ON_CALL(*sensorMocks.at(idx), getName())
+                .WillByDefault(Return(sensorNames[idx]));
+        }
+
+        makeThreshold(0ms, numeric::Direction::increasing, 90.0,
+                      numeric::Type::upperCritical);
     }
 };
 
@@ -60,6 +67,13 @@
     EXPECT_CALL(actionMock, commit(_, _, _)).Times(0);
 }
 
+TEST_F(TestNumericThreshold, getLabeledParamsReturnsCorrectly)
+{
+    LabeledThresholdParam expected = numeric::LabeledThresholdParam(
+        numeric::Type::upperCritical, 0, numeric::Direction::increasing, 90.0);
+    EXPECT_EQ(sut->getThresholdParam(), expected);
+}
+
 struct NumericParams
 {
     NumericParams& Direction(numeric::Direction val)
@@ -114,6 +128,12 @@
   public:
     void SetUp() override
     {
+        for (size_t idx = 0; idx < sensorMocks.size(); idx++)
+        {
+            ON_CALL(*sensorMocks.at(idx), getName())
+                .WillByDefault(Return(sensorNames[idx]));
+        }
+
         makeThreshold(0ms, GetParam().direction, 90.0);
     }
 };
@@ -205,6 +225,12 @@
   public:
     void SetUp() override
     {
+        for (size_t idx = 0; idx < sensorMocks.size(); idx++)
+        {
+            ON_CALL(*sensorMocks.at(idx), getName())
+                .WillByDefault(Return(sensorNames[idx]));
+        }
+
         makeThreshold(2ms, GetParam().direction, 90.0);
     }
 
@@ -303,6 +329,12 @@
   public:
     void SetUp() override
     {
+        for (size_t idx = 0; idx < sensorMocks.size(); idx++)
+        {
+            ON_CALL(*sensorMocks.at(idx), getName())
+                .WillByDefault(Return(sensorNames[idx]));
+        }
+
         makeThreshold(2ms, GetParam().direction, 90.0);
     }
 
diff --git a/tests/src/test_on_change_threshold.cpp b/tests/src/test_on_change_threshold.cpp
index 75a63c5..0c3b301 100644
--- a/tests/src/test_on_change_threshold.cpp
+++ b/tests/src/test_on_change_threshold.cpp
@@ -27,10 +27,16 @@
         std::vector<std::unique_ptr<interfaces::TriggerAction>> actions;
         actions.push_back(std::move(actionMockPtr));
 
+        for (size_t idx = 0; idx < sensorMocks.size(); idx++)
+        {
+            ON_CALL(*sensorMocks.at(idx), getName())
+                .WillByDefault(Return(sensorNames[idx]));
+        }
+
         sut = std::make_shared<OnChangeThreshold>(
             utils::convContainer<std::shared_ptr<interfaces::Sensor>>(
                 sensorMocks),
-            sensorNames, std::move(actions));
+            std::move(actions));
     }
 };
 
@@ -52,6 +58,12 @@
     EXPECT_CALL(actionMock, commit(_, _, _)).Times(0);
 }
 
+TEST_F(TestOnChangeThreshold, getLabeledParamsReturnsCorrectly)
+{
+    LabeledThresholdParam expected = std::monostate();
+    EXPECT_EQ(sut->getThresholdParam(), expected);
+}
+
 struct OnChangeParams
 {
     using UpdateParams = std::tuple<size_t, Milliseconds, double>;
diff --git a/tests/src/test_report_manager.cpp b/tests/src/test_report_manager.cpp
index a18579c..10b4de9 100644
--- a/tests/src/test_report_manager.cpp
+++ b/tests/src/test_report_manager.cpp
@@ -215,9 +215,9 @@
 
     reportParams.metricParameters(
         std::vector<LabeledMetricParameters>{{LabeledMetricParameters{
-            {LabeledSensorParameters{"Service",
-                                     "/xyz/openbmc_project/sensors/power/p1",
-                                     "Metadata1"}},
+            {LabeledSensorInfo{"Service",
+                               "/xyz/openbmc_project/sensors/power/p1",
+                               "Metadata1"}},
             OperationType::single,
             "MetricId1",
             CollectionTimeScope::point,
@@ -229,7 +229,7 @@
 
     for (size_t i = 0; i < ReportManager::maxNumberMetrics; i++)
     {
-        metricParamsVec.emplace_back(LabeledSensorParameters{
+        metricParamsVec.emplace_back(LabeledSensorInfo{
             "Service", "/xyz/openbmc_project/sensors/power/p1", "Metadata1"});
     }
 
@@ -396,9 +396,9 @@
 {
     reportParams.metricParameters(
         std::vector<LabeledMetricParameters>{{LabeledMetricParameters{
-            {LabeledSensorParameters{"Service",
-                                     "/xyz/openbmc_project/sensors/power/p1",
-                                     "Metadata1"}},
+            {LabeledSensorInfo{"Service",
+                               "/xyz/openbmc_project/sensors/power/p1",
+                               "Metadata1"}},
             operationType,
             "MetricId1",
             CollectionTimeScope::point,
diff --git a/tests/src/test_sensor.cpp b/tests/src/test_sensor.cpp
index c0a9dc3..c073ee7 100644
--- a/tests/src/test_sensor.cpp
+++ b/tests/src/test_sensor.cpp
@@ -97,6 +97,31 @@
     ASSERT_TRUE(DbusEnvironment::waitForFuture("async_read2"));
 }
 
+TEST_F(TestSensor, getLabeledInfoReturnsCorrectly)
+{
+    auto expected = LabeledSensorInfo(DbusEnvironment::serviceName(),
+                                      sensorObject->path(), "metadata");
+    EXPECT_EQ(sut->getLabeledSensorInfo(), expected);
+}
+
+TEST_F(TestSensor, getNameReturnsPathWhenMetadataIsNotSet)
+{
+    static const char* path = "/telemetry/ut/DbusSensorObject2";
+    sut = sensorCache.makeSensor<Sensor>(DbusEnvironment::serviceName(), path,
+                                         "", DbusEnvironment::getIoc(),
+                                         DbusEnvironment::getBus());
+    EXPECT_EQ(sut->getName(), path);
+}
+
+TEST_F(TestSensor, getNameReturnsMetadataWhenMetadataIsSet)
+{
+    static const char* path = "/telemetry/ut/DbusSensorObject2";
+    sut = sensorCache.makeSensor<Sensor>(DbusEnvironment::serviceName(), path,
+                                         "metadata2", DbusEnvironment::getIoc(),
+                                         DbusEnvironment::getBus());
+    EXPECT_EQ(sut->getName(), "metadata2");
+}
+
 class TestSensorNotification : public TestSensor
 {
   public:
diff --git a/tests/src/test_trigger.cpp b/tests/src/test_trigger.cpp
index 66e9bf0..a2286ee 100644
--- a/tests/src/test_trigger.cpp
+++ b/tests/src/test_trigger.cpp
@@ -1,6 +1,9 @@
 #include "dbus_environment.hpp"
 #include "helpers.hpp"
 #include "mocks/json_storage_mock.hpp"
+#include "mocks/sensor_mock.hpp"
+#include "mocks/threshold_mock.hpp"
+#include "mocks/trigger_factory_mock.hpp"
 #include "mocks/trigger_manager_mock.hpp"
 #include "params/trigger_params.hpp"
 #include "trigger.hpp"
@@ -14,7 +17,7 @@
 using namespace testing;
 using namespace std::literals::string_literals;
 
-static constexpr size_t expectedTriggerVersion = 0;
+static constexpr size_t expectedTriggerVersion = 1;
 
 class TestTrigger : public Test
 {
@@ -35,7 +38,10 @@
 
     std::unique_ptr<TriggerManagerMock> triggerManagerMockPtr =
         std::make_unique<NiceMock<TriggerManagerMock>>();
+    std::unique_ptr<TriggerFactoryMock> triggerFactoryMockPtr =
+        std::make_unique<NiceMock<TriggerFactoryMock>>();
     testing::NiceMock<StorageMock> storageMock;
+    std::vector<std::shared_ptr<interfaces::Threshold>> thresholdMocks;
     std::unique_ptr<Trigger> sut;
 
     void SetUp() override
@@ -54,12 +60,17 @@
 
     std::unique_ptr<Trigger> makeTrigger(const TriggerParams& params)
     {
+        thresholdMocks =
+            ThresholdMock::makeThresholds(params.thresholdParams());
+
         return std::make_unique<Trigger>(
             DbusEnvironment::getIoc(), DbusEnvironment::getObjServer(),
             params.id(), params.name(), params.triggerActions(),
-            params.reportIds(), params.sensors(), params.thresholdParams(),
-            std::vector<std::shared_ptr<interfaces::Threshold>>{},
-            *triggerManagerMockPtr, storageMock);
+            std::make_shared<std::vector<std::string>>(
+                params.reportIds().begin(), params.reportIds().end()),
+            std::vector<std::shared_ptr<interfaces::Threshold>>(thresholdMocks),
+            *triggerManagerMockPtr, storageMock, *triggerFactoryMockPtr,
+            SensorMock::makeSensorMocks(params.sensors()));
     }
 
     static interfaces::JsonStorage::FilePath to_file_path(std::string name)
@@ -104,13 +115,18 @@
     EXPECT_THAT(getProperty<bool>(sut->getPath(), "Persistent"), Eq(true));
     EXPECT_THAT(
         getProperty<std::vector<std::string>>(sut->getPath(), "TriggerActions"),
-        Eq(triggerParams.triggerActions()));
+        Eq(utils::transform(
+            triggerParams.triggerActions(),
+            [](const auto& action) { return actionToString(action); })));
     EXPECT_THAT((getProperty<SensorsInfo>(sut->getPath(), "Sensors")),
                 Eq(utils::fromLabeledSensorsInfo(triggerParams.sensors())));
     EXPECT_THAT(
         getProperty<std::vector<std::string>>(sut->getPath(), "ReportNames"),
         Eq(triggerParams.reportIds()));
     EXPECT_THAT(
+        getProperty<bool>(sut->getPath(), "Discrete"),
+        Eq(isTriggerThresholdDiscrete(triggerParams.thresholdParams())));
+    EXPECT_THAT(
         getProperty<TriggerThresholdParams>(sut->getPath(), "Thresholds"),
         Eq(std::visit(utils::FromLabeledThresholdParamConversion(),
                       triggerParams.thresholdParams())));
@@ -124,6 +140,41 @@
     EXPECT_THAT(getProperty<std::string>(sut->getPath(), "Name"), Eq(name));
 }
 
+TEST_F(TestTrigger, setPropertyReportNames)
+{
+    std::vector<std::string> newNames = {"abc", "one", "two"};
+    EXPECT_THAT(setProperty(sut->getPath(), "ReportNames", newNames),
+                Eq(boost::system::errc::success));
+    EXPECT_THAT(
+        getProperty<std::vector<std::string>>(sut->getPath(), "ReportNames"),
+        Eq(newNames));
+}
+
+TEST_F(TestTrigger, setPropertySensors)
+{
+    EXPECT_CALL(*triggerFactoryMockPtr, updateSensors(_, _));
+    for (const auto& threshold : thresholdMocks)
+    {
+        auto thresholdMockPtr =
+            std::dynamic_pointer_cast<NiceMock<ThresholdMock>>(threshold);
+        EXPECT_CALL(*thresholdMockPtr, updateSensors(_));
+    }
+    SensorsInfo newSensors({std::make_pair(
+        sdbusplus::message::object_path("/abc/def"), "metadata")});
+    EXPECT_THAT(setProperty(sut->getPath(), "Sensors", newSensors),
+                Eq(boost::system::errc::success));
+}
+
+TEST_F(TestTrigger, setPropertyThresholds)
+{
+    EXPECT_CALL(*triggerFactoryMockPtr, updateThresholds(_, _, _, _, _));
+    TriggerThresholdParams newThresholds =
+        std::vector<discrete::ThresholdParam>(
+            {std::make_tuple("discrete threshold", "OK", 10, "12.3")});
+    EXPECT_THAT(setProperty(sut->getPath(), "Thresholds", newThresholds),
+                Eq(boost::system::errc::success));
+}
+
 TEST_F(TestTrigger, checkIfNumericCoversionsAreGood)
 {
     const auto& labeledParamsBase =
@@ -265,7 +316,10 @@
 TEST_F(TestTriggerStore, settingPersistencyToTrueStoresTriggerTriggerActions)
 {
     ASSERT_THAT(storedConfiguration.at("TriggerActions"),
-                Eq(triggerParams.triggerActions()));
+                Eq(utils::transform(triggerParams.triggerActions(),
+                                    [](const auto& action) {
+                                        return actionToString(action);
+                                    })));
 }
 
 TEST_F(TestTriggerStore, settingPersistencyToTrueStoresTriggerReportIds)
@@ -278,8 +332,7 @@
 {
     nlohmann::json expectedItem;
     expectedItem["service"] = "service1";
-    expectedItem["sensorPath"] =
-        "/xyz/openbmc_project/sensors/temperature/BMC_Temp";
+    expectedItem["path"] = "/xyz/openbmc_project/sensors/temperature/BMC_Temp";
     expectedItem["metadata"] = "metadata1";
 
     ASSERT_THAT(storedConfiguration.at("Sensors"), ElementsAre(expectedItem));
diff --git a/tests/src/test_trigger_actions.cpp b/tests/src/test_trigger_actions.cpp
index 1c36326..b902e5a 100644
--- a/tests/src/test_trigger_actions.cpp
+++ b/tests/src/test_trigger_actions.cpp
@@ -220,7 +220,9 @@
   public:
     void make(std::vector<std::string> names)
     {
-        sut = std::make_unique<UpdateReport>(reportManager, std::move(names));
+        sut = std::make_unique<UpdateReport>(
+            reportManager,
+            std::make_shared<std::vector<std::string>>(std::move(names)));
     }
 
     NiceMock<ReportManagerMock> reportManager;
diff --git a/tests/src/test_trigger_manager.cpp b/tests/src/test_trigger_manager.cpp
index 182c58b..ea4f0b9 100644
--- a/tests/src/test_trigger_manager.cpp
+++ b/tests/src/test_trigger_manager.cpp
@@ -29,8 +29,11 @@
             },
             DbusEnvironment::serviceName(), TriggerManager::triggerManagerPath,
             TriggerManager::triggerManagerIfaceName, "AddTrigger", params.id(),
-            params.name(), params.triggerActions(), sensorInfos,
-            params.reportIds(),
+            params.name(),
+            utils::transform(
+                params.triggerActions(),
+                [](const auto& action) { return actionToString(action); }),
+            sensorInfos, params.reportIds(),
             std::visit(utils::FromLabeledThresholdParamConversion(),
                        params.thresholdParams()));
         return DbusEnvironment::waitForFuture(addTriggerPromise.get_future());
@@ -291,7 +294,10 @@
         {"Name", TriggerParams().name()},
         {"ThresholdParamsDiscriminator",
          TriggerParams().thresholdParams().index()},
-        {"TriggerActions", TriggerParams().triggerActions()},
+        {"TriggerActions", utils::transform(TriggerParams().triggerActions(),
+                                            [](const auto& action) {
+                                                return actionToString(action);
+                                            })},
         {"ThresholdParams", utils::labeledThresholdParamsToJson(
                                 TriggerParams().thresholdParams())},
         {"ReportIds", TriggerParams().reportIds()},