Remove deprecated "Thresholds" property and fix UTs
Thresholds have been split into "DiscreteThresholds" and
"NumericThresholds", remove deprecated property, update UTs
Tested:
UTs passed
Change-Id: I1959be879e9016b84fff7f7ae6cfad1f5d00e5aa
Signed-off-by: Boleslaw Ogonczyk Makowski <boleslawx.ogonczyk-makowski@intel.com>
diff --git a/src/trigger.cpp b/src/trigger.cpp
index f71e515..f619f51 100644
--- a/src/trigger.cpp
+++ b/src/trigger.cpp
@@ -70,23 +70,6 @@
[this](const auto&) { return persistent; });
dbusIface.register_property_rw(
- "Thresholds", TriggerThresholdParams{},
- sdbusplus::vtable::property_::emits_change,
- [this, &triggerFactory](auto newVal, auto& oldVal) {
- auto newThresholdParams = std::visit(
- utils::ToLabeledThresholdParamConversion(), newVal);
- TriggerManager::verifyThresholdParams(newThresholdParams);
- triggerFactory.updateThresholds(
- thresholds, *id, triggerActions, reportIds, sensors,
- newThresholdParams);
- oldVal = std::move(newVal);
- return 1;
- },
- [this](const auto&) {
- return fromLabeledThresholdParam(getLabeledThresholds());
- });
-
- dbusIface.register_property_rw(
"DiscreteThresholds", std::vector<discrete::ThresholdParam>{},
sdbusplus::vtable::property_::emits_change,
[this, &triggerFactory](
diff --git a/tests/src/test_trigger.cpp b/tests/src/test_trigger.cpp
index 7764c8d..5b15c49 100644
--- a/tests/src/test_trigger.cpp
+++ b/tests/src/test_trigger.cpp
@@ -312,30 +312,39 @@
Eq(boost::system::errc::success));
}
-TEST_F(TestTrigger, setPropertyThresholds)
+TEST_F(TestTrigger, setPropertyNumericThresholds)
{
EXPECT_CALL(*triggerFactoryMockPtr, updateThresholds(_, _, _, _, _, _));
- TriggerThresholdParams newThresholds =
- std::vector<discrete::ThresholdParam>({std::make_tuple(
- "discrete threshold", utils::enumToString(discrete::Severity::ok),
- 10, "12.3")});
- EXPECT_THAT(setProperty(sut->getPath(), "Thresholds", newThresholds),
+ auto newThresholds = std::vector<numeric::ThresholdParam>({std::make_tuple(
+ numeric::typeToString(numeric::Type::upperWarning), 10,
+ numeric::directionToString(numeric::Direction::increasing), 12.3)});
+ EXPECT_THAT(setProperty(sut->getPath(), "NumericThresholds", newThresholds),
+ Eq(boost::system::errc::success));
+}
+
+TEST_F(TestTrigger, setPropertyDiscreteThresholds)
+{
+ EXPECT_CALL(*triggerFactoryMockPtr, updateThresholds(_, _, _, _, _, _));
+ auto newThresholds = std::vector<discrete::ThresholdParam>({std::make_tuple(
+ "discrete threshold", utils::enumToString(discrete::Severity::ok), 10,
+ "12.3")});
+ EXPECT_THAT(setProperty(sut->getPath(), "DiscreteThresholds",
+ newThresholds),
Eq(boost::system::errc::success));
}
TEST_F(TestTrigger, setThresholdParamsWithTooLongDiscreteName)
{
- const TriggerThresholdParams currentValue =
- std::visit(utils::FromLabeledThresholdParamConversion(),
- triggerParams.thresholdParams());
+ const std::vector<discrete::ThresholdParam> currentValue =
+ std::get<1>(utils::FromLabeledThresholdParamConversion()(
+ triggerParams.discreteThresholdParams()));
- TriggerThresholdParams newThresholds =
- std::vector<discrete::ThresholdParam>({std::make_tuple(
- utils::string_utils::getTooLongName(),
- utils::enumToString(discrete::Severity::ok), 10, "12.3")});
+ auto newThresholds = std::vector<discrete::ThresholdParam>({std::make_tuple(
+ utils::string_utils::getTooLongName(),
+ utils::enumToString(discrete::Severity::ok), 10, "12.3")});
- changeProperty<TriggerThresholdParams>(
- sut->getPath(), "Thresholds",
+ changeProperty<std::vector<discrete::ThresholdParam>>(
+ sut->getPath(), "DiscreteThresholds",
{.valueBefore = Eq(currentValue),
.newValue = newThresholds,
.ec = Eq(boost::system::errc::invalid_argument),