Removed FutureVersion from API

Instead of using FutureVersion API currently used version is updated.
This change needs to be bumped together with [1]. API that utilized map
of variants to be more flexible and backwards compatible was reverted.
It was decided that straight forward API that is commonly used should be
used instead.

Removed MetricId property from Metric. In telemetry it was implemented
as a name for Metric, but it was supposed to work as described in [2].
Currently MetricId is not supported by telemetry service and property
was removed.

Tested:
- After chaging bmcweb to use new API old and new features are working
  as expected

[1]: https://gerrit.openbmc.org/c/openbmc/bmcweb/+/44270
[2]: https://redfish.dmtf.org/schemas/v1/MetricReportDefinition.v1_4_2.json

Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
Change-Id: I5930a466a370f268d68f575a4a3db5ee9655e574
diff --git a/tests/src/test_report_manager.cpp b/tests/src/test_report_manager.cpp
index fc394ae..295d966 100644
--- a/tests/src/test_report_manager.cpp
+++ b/tests/src/test_report_manager.cpp
@@ -18,8 +18,7 @@
 using namespace std::string_literals;
 using namespace std::chrono_literals;
 
-using AddReportFutureVersionVariantForSet =
-    utils::WithoutMonostate<AddReportFutureVersionVariant>;
+using AddReportVariantForSet = utils::WithoutMonostate<AddReportVariant>;
 
 class TestReportManager : public Test
 {
@@ -57,10 +56,9 @@
         DbusEnvironment::synchronizeIoc();
     }
 
-    std::pair<boost::system::error_code, std::string>
-        addReport(const std::vector<
-                  std::pair<std::string, AddReportFutureVersionVariantForSet>>&
-                      properties)
+    template <class... Args>
+        requires(sizeof...(Args) > 1)
+    std::pair<boost::system::error_code, std::string> addReport(Args&&... args)
     {
         std::promise<std::pair<boost::system::error_code, std::string>>
             addReportPromise;
@@ -70,34 +68,22 @@
             addReportPromise.set_value({ec, path});
             },
             DbusEnvironment::serviceName(), ReportManager::reportManagerPath,
-            ReportManager::reportManagerIfaceName, "AddReportFutureVersion",
-            properties);
+            ReportManager::reportManagerIfaceName, "AddReport",
+            std::forward<Args>(args)...);
         return DbusEnvironment::waitForFuture(addReportPromise.get_future());
     }
 
     auto addReport(const ReportParams& params)
     {
-        std::vector<std::pair<std::string, AddReportFutureVersionVariantForSet>>
-            properties;
-
-        properties.emplace_back("Id", params.reportId());
-        properties.emplace_back("Name", params.reportName());
-        properties.emplace_back("ReportingType",
-                                utils::enumToString(params.reportingType()));
-        properties.emplace_back("ReportUpdates",
-                                utils::enumToString(params.reportUpdates()));
-        properties.emplace_back("AppendLimit", params.appendLimit());
-        properties.emplace_back("Enabled", params.enabled());
-        properties.emplace_back("ReportActions",
-                                utils::transform(params.reportActions(),
-                                                 [](const auto v) {
-            return utils::enumToString(v);
-                                }));
-        properties.emplace_back("Interval", params.interval().count());
-        properties.emplace_back("ReadingParameters",
-                                toReadingParameters(params.metricParameters()));
-
-        return addReport(properties);
+        return addReport(
+            params.reportId(), params.reportName(),
+            utils::enumToString(params.reportingType()),
+            utils::enumToString(params.reportUpdates()), params.appendLimit(),
+            utils::transform(
+                params.reportActions(),
+                [](const auto v) { return utils::enumToString(v); }),
+            params.interval().count(),
+            toReadingParameters(params.metricParameters()), params.enabled());
     }
 
     template <class T>
@@ -125,7 +111,10 @@
 {
     EXPECT_THAT(
         getProperty<std::vector<std::string>>("SupportedOperationTypes"),
-        UnorderedElementsAre("Maximum", "Minimum", "Average", "Summation"));
+        UnorderedElementsAre(utils::enumToString(OperationType::max),
+                             utils::enumToString(OperationType::min),
+                             utils::enumToString(OperationType::avg),
+                             utils::enumToString(OperationType::sum)));
 }
 
 TEST_F(TestReportManager, addReport)
@@ -163,8 +152,10 @@
         .WillOnce(Return(ByMove(std::move(reportMockPtr))));
 
     auto [ec, path] = addReport(
-        std::vector<
-            std::pair<std::string, AddReportFutureVersionVariantForSet>>{});
+        "", "", "", "", std::numeric_limits<uint64_t>::max(),
+        std::vector<std::string>(), std::numeric_limits<uint64_t>::max(),
+        ReadingParameters(), true);
+
     EXPECT_THAT(ec.value(), Eq(boost::system::errc::success));
     EXPECT_THAT(path, Eq(reportMock.getPath()));
 }
@@ -243,28 +234,6 @@
     EXPECT_THAT(path, Eq("/"s + reportParams.reportId()));
 }
 
-TEST_F(TestReportManager, addReportWithMaxLengthMetricId)
-{
-    namespace ts = utils::tstring;
-    std::vector<LabeledMetricParameters> newMetricParams{
-        {LabeledMetricParameters{
-            {LabeledSensorInfo{"Service",
-                               "/xyz/openbmc_project/sensors/power/p1",
-                               "metadata1"}},
-            OperationType::avg,
-            utils::string_utils::getMaxId(),
-            CollectionTimeScope::point,
-            CollectionDuration(Milliseconds(0u))}}};
-
-    reportParams.metricParameters(newMetricParams);
-    reportFactoryMock.expectMake(reportParams, Ref(*sut), Ref(storageMock));
-
-    auto [ec, path] = addReport(reportParams);
-
-    EXPECT_THAT(ec.value(), Eq(boost::system::errc::success));
-    EXPECT_THAT(path, Eq("/"s + reportParams.reportId()));
-}
-
 TEST_F(TestReportManager, DISABLED_failToAddReportWithTooLongFullId)
 {
     reportFactoryMock.expectMake(std::nullopt, Ref(*sut), Ref(storageMock))
@@ -338,31 +307,6 @@
     EXPECT_THAT(path, Eq(std::string()));
 }
 
-TEST_F(TestReportManager, DISABLED_failToAddReportWithTooLongMetricId)
-{
-    namespace ts = utils::tstring;
-
-    std::vector<LabeledMetricParameters> newMetricParams{
-        {LabeledMetricParameters{
-            {LabeledSensorInfo{"Service",
-                               "/xyz/openbmc_project/sensors/power/p1",
-                               "metadata1"}},
-            OperationType::avg,
-            utils::string_utils::getTooLongId(),
-            CollectionTimeScope::point,
-            CollectionDuration(Milliseconds(0u))}}};
-
-    reportFactoryMock.expectMake(std::nullopt, Ref(*sut), Ref(storageMock))
-        .Times(0);
-
-    reportParams.metricParameters(newMetricParams);
-
-    auto [ec, path] = addReport(reportParams);
-
-    EXPECT_THAT(ec.value(), Eq(boost::system::errc::invalid_argument));
-    EXPECT_THAT(path, Eq(std::string()));
-}
-
 TEST_F(TestReportManager, DISABLED_failToAddReportTwice)
 {
     reportFactoryMock.expectMake(reportParams, Ref(*sut), Ref(storageMock))
@@ -395,8 +339,10 @@
     reportFactoryMock.expectMake(std::nullopt, Ref(*sut), Ref(storageMock))
         .Times(0);
 
-    auto [ec, path] = addReport({{"Name", reportParams.reportName()},
-                                 {"ReportingType", "InvalidReportingType"}});
+    auto [ec, path] = addReport(
+        "", "", "InvalidReportingType", "",
+        std::numeric_limits<uint64_t>::max(), std::vector<std::string>(),
+        std::numeric_limits<uint64_t>::max(), ReadingParameters(), false);
 
     EXPECT_THAT(ec.value(), Eq(boost::system::errc::invalid_argument));
     EXPECT_THAT(path, Eq(std::string()));
@@ -414,7 +360,6 @@
                                "/xyz/openbmc_project/sensors/power/p1",
                                "Metadata1"}},
             OperationType::avg,
-            "MetricId1",
             CollectionTimeScope::point,
             CollectionDuration(Milliseconds(0u))}}});
 
@@ -448,7 +393,6 @@
         metricParams.emplace_back(
             LabeledMetricParameters{{},
                                     OperationType::avg,
-                                    "MetricId1",
                                     CollectionTimeScope::point,
                                     CollectionDuration(Milliseconds(0u))});
     }
@@ -476,13 +420,14 @@
 
 TEST_F(TestReportManager, addReportWithAppendLimitEqualToUint64MaxIsAllowed)
 {
-    reportParams.appendLimit(std::numeric_limits<uint64_t>::max());
-
     EXPECT_CALL(reportFactoryMock, convertMetricParams(_, _));
-    reportFactoryMock.expectMake(reportParams, Ref(*sut), Ref(storageMock))
+    reportFactoryMock
+        .expectMake(reportParams.appendLimit(ReportManager::maxAppendLimit),
+                    Ref(*sut), Ref(storageMock))
         .WillOnce(Return(ByMove(std::move(reportMockPtr))));
 
-    auto [ec, path] = addReport(reportParams);
+    auto [ec, path] = addReport(
+        reportParams.appendLimit(std::numeric_limits<uint64_t>::max()));
     EXPECT_THAT(ec.value(), Eq(boost::system::errc::success));
     EXPECT_THAT(path, Eq(reportMock.getPath()));
 }
@@ -574,7 +519,6 @@
                                "/xyz/openbmc_project/sensors/power/p1",
                                "Metadata1"}},
             operationType,
-            "MetricId1",
             CollectionTimeScope::point,
             CollectionDuration(Milliseconds(0u))}}});