Api changes in AddReportFuture version
Added support for CollectionFunction, CollectionDuration,
CollectionTimeScope, ReportUpdates, AppendLimit.
New API separates Id and Name, user can decide to pass only Name
to auto generate Id or pass Id which needs to be unique.
Tested:
- No functional changes to old API, everything works as before
- All use cases can be replaced with new API to achieve same results
- New features which require new API work as expected
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
Change-Id: I647efab36d90a548754f89968223e162a087481e
diff --git a/tests/src/mocks/report_factory_mock.hpp b/tests/src/mocks/report_factory_mock.hpp
index cc0bc8e..58c71d6 100644
--- a/tests/src/mocks/report_factory_mock.hpp
+++ b/tests/src/mocks/report_factory_mock.hpp
@@ -15,14 +15,15 @@
return utils::transform(readingParams, [](const auto& params) {
return LabeledMetricParameters(
utils::transform(std::get<0>(params),
- [](const auto& sensorPath) {
- return LabeledSensorParameters("Service",
- sensorPath);
+ [](const auto& sensorData) {
+ return LabeledSensorParameters(
+ "Service", std::get<0>(sensorData),
+ std::get<1>(sensorData));
}),
utils::toOperationType(std::get<1>(params)),
- std::get<2>(params), std::get<3>(params),
- utils::toCollectionTimeScope(std::get<4>(params)),
- CollectionDuration(Milliseconds(std::get<5>(params))));
+ std::get<2>(params),
+ utils::toCollectionTimeScope(std::get<3>(params)),
+ CollectionDuration(Milliseconds(std::get<4>(params))));
});
}
@@ -35,9 +36,10 @@
.WillByDefault(
WithArgs<1>(Invoke(&ReportFactoryMock::convertToLabeled)));
- ON_CALL(*this, make(A<const std::string&>(), _, _, _, _, _, _, _, _, _))
- .WillByDefault(WithArgs<0>(Invoke([](const std::string& name) {
- return std::make_unique<NiceMock<ReportMock>>(name);
+ ON_CALL(*this,
+ make(A<const std::string&>(), _, _, _, _, _, _, _, _, _, _))
+ .WillByDefault(WithArgs<0>(Invoke([](const std::string& id) {
+ return std::make_unique<NiceMock<ReportMock>>(id);
})));
}
@@ -46,7 +48,7 @@
(const, override));
MOCK_METHOD(std::unique_ptr<interfaces::Report>, make,
- (const std::string&, const ReportingType,
+ (const std::string&, const std::string&, const ReportingType,
const std::vector<ReportAction>&, Milliseconds, uint64_t,
const ReportUpdates, interfaces::ReportManager&,
interfaces::JsonStorage&, std::vector<LabeledMetricParameters>,
@@ -62,15 +64,16 @@
{
const ReportParams& params = *paramsRef;
return EXPECT_CALL(
- *this, make(params.reportName(), params.reportingType(),
- params.reportActions(), params.interval(),
- params.appendLimit(), params.reportUpdates(), rm,
- js, params.metricParameters(), params.enabled()));
+ *this, make(params.reportId(), params.reportName(),
+ params.reportingType(), params.reportActions(),
+ params.interval(), params.appendLimit(),
+ params.reportUpdates(), rm, js,
+ params.metricParameters(), params.enabled()));
}
else
{
using testing::_;
- return EXPECT_CALL(*this, make(_, _, _, _, _, _, rm, js, _, _));
+ return EXPECT_CALL(*this, make(_, _, _, _, _, _, _, rm, js, _, _));
}
}
};
diff --git a/tests/src/mocks/report_mock.hpp b/tests/src/mocks/report_mock.hpp
index 726d53c..6a6e259 100644
--- a/tests/src/mocks/report_mock.hpp
+++ b/tests/src/mocks/report_mock.hpp
@@ -7,12 +7,12 @@
class ReportMock : public interfaces::Report
{
public:
- ReportMock(std::string name)
+ ReportMock(const std::string& id)
{
using namespace testing;
- ON_CALL(*this, getName).WillByDefault([name] { return name; });
- ON_CALL(*this, getPath).WillByDefault([name] { return "/" + name; });
+ ON_CALL(*this, getId).WillByDefault([id] { return id; });
+ ON_CALL(*this, getPath).WillByDefault([id] { return "/" + id; });
EXPECT_CALL(*this, Die).Times(AnyNumber());
}
@@ -21,7 +21,7 @@
Die();
}
- MOCK_METHOD(std::string, getName, (), (override, const));
+ MOCK_METHOD(std::string, getId, (), (override, const));
MOCK_METHOD(std::string, getPath, (), (override, const));
MOCK_METHOD(void, updateReadings, (), (override));
MOCK_METHOD(void, Die, ());
diff --git a/tests/src/mocks/sensor_mock.hpp b/tests/src/mocks/sensor_mock.hpp
index b86a26e..9ff72e2 100644
--- a/tests/src/mocks/sensor_mock.hpp
+++ b/tests/src/mocks/sensor_mock.hpp
@@ -24,6 +24,7 @@
}
MOCK_METHOD(Id, id, (), (const, override));
+ MOCK_METHOD(std::string, metadata, (), (const, override));
MOCK_METHOD(void, registerForUpdates,
(const std::weak_ptr<interfaces::SensorListener>&), (override));
MOCK_METHOD(void, unregisterFromUpdates,
diff --git a/tests/src/mocks/trigger_factory_mock.hpp b/tests/src/mocks/trigger_factory_mock.hpp
index ab7510d..9fa2f48 100644
--- a/tests/src/mocks/trigger_factory_mock.hpp
+++ b/tests/src/mocks/trigger_factory_mock.hpp
@@ -24,7 +24,7 @@
MOCK_METHOD(std::unique_ptr<interfaces::Trigger>, make,
(const std::string& id, const std::string& name,
const std::vector<std::string>& triggerActions,
- const std::vector<std::string>& reportNames,
+ const std::vector<std::string>& reportIds,
interfaces::TriggerManager& triggerManager,
interfaces::JsonStorage& triggerStorage,
const LabeledTriggerThresholdParams& labeledThresholdParams,
@@ -54,7 +54,7 @@
return EXPECT_CALL(
*this, make(params.id(), params.name(), params.triggerActions(),
- params.reportNames(), tm, triggerStorage,
+ params.reportIds(), tm, triggerStorage,
params.thresholdParams(), params.sensors()));
}
else