From 9ceffdf114fa1c6d13711c61ea7013f0195a7c1b Mon Sep 17 00:00:00 2001 From: swethasukumarr Date: Fri, 12 Jun 2026 14:03:05 -0400 Subject: [PATCH 1/4] RDKEMW-17483: Change Discovery.watched method return type void to bool --- docs/openrpc/openrpc/discovery.json | 13 +++++++------ docs/openrpc/the-spec/firebolt-open-rpc.json | 13 +++++++------ include/firebolt/discovery.h | 4 ++-- src/discovery_impl.cpp | 9 +++++++-- src/discovery_impl.h | 2 +- test/api_test_app/apis/discoveryDemo.cpp | 2 +- test/component/discoveryTest.cpp | 3 +++ test/unit/discoveryTest.cpp | 11 ++++++++--- 8 files changed, 36 insertions(+), 21 deletions(-) diff --git a/docs/openrpc/openrpc/discovery.json b/docs/openrpc/openrpc/discovery.json index 6f80f61..1cb0ce3 100644 --- a/docs/openrpc/openrpc/discovery.json +++ b/docs/openrpc/openrpc/discovery.json @@ -61,9 +61,10 @@ } ], "result": { - "name": "result", + "name": "success", + "summary": "whether the call was successful or not", "schema": { - "type": "null" + "type": "boolean" } }, "examples": [ @@ -88,8 +89,8 @@ } ], "result": { - "name": "result", - "value": null + "name": "success", + "value": true } }, { @@ -117,8 +118,8 @@ } ], "result": { - "name": "result", - "value": null + "name": "success", + "value": true } } ] diff --git a/docs/openrpc/the-spec/firebolt-open-rpc.json b/docs/openrpc/the-spec/firebolt-open-rpc.json index 1315678..becbcf0 100644 --- a/docs/openrpc/the-spec/firebolt-open-rpc.json +++ b/docs/openrpc/the-spec/firebolt-open-rpc.json @@ -582,9 +582,10 @@ } ], "result": { - "name": "result", + "name": "success", + "summary": "whether the call was successful or not", "schema": { - "type": "null" + "type": "boolean" } }, "examples": [ @@ -609,8 +610,8 @@ } ], "result": { - "name": "result", - "value": null + "name": "success", + "value": true } }, { @@ -638,8 +639,8 @@ } ], "result": { - "name": "result", - "value": null + "name": "success", + "value": true } } ] diff --git a/include/firebolt/discovery.h b/include/firebolt/discovery.h index 894a768..55b3913 100644 --- a/include/firebolt/discovery.h +++ b/include/firebolt/discovery.h @@ -39,9 +39,9 @@ class IDiscovery * @param[in] agePolicy : The age policy associated with the watch event. The age policy describes the age groups * to which content may be directed * - * @retval An ok Result on success, or an error; no value is returned + * @retval The status. */ - virtual Result watched(const std::string& entityId, std::optional progress, + virtual Result watched(const std::string& entityId, std::optional progress, std::optional completed, std::optional watchedOn, std::optional agePolicy) const = 0; diff --git a/src/discovery_impl.cpp b/src/discovery_impl.cpp index 3504399..3d3a8db 100644 --- a/src/discovery_impl.cpp +++ b/src/discovery_impl.cpp @@ -27,7 +27,7 @@ DiscoveryImpl::DiscoveryImpl(Firebolt::Helpers::IHelper& helper) { } -Result DiscoveryImpl::watched(const std::string& entityId, std::optional progress, +Result DiscoveryImpl::watched(const std::string& entityId, std::optional progress, std::optional completed, std::optional watchedOn, std::optional agePolicy) const { @@ -50,7 +50,12 @@ Result DiscoveryImpl::watched(const std::string& entityId, std::optional result = helper_.get("Discovery.watched", parameters); + if (!result) + { + return Result{result.error()}; + } + return Result{result.value()}; } Result DiscoveryImpl::watchedV2(const std::string& entityId, std::optional progress, diff --git a/src/discovery_impl.h b/src/discovery_impl.h index 96b2d70..7710e40 100644 --- a/src/discovery_impl.h +++ b/src/discovery_impl.h @@ -33,7 +33,7 @@ class DiscoveryImpl : public IDiscovery ~DiscoveryImpl() override = default; - Result watched(const std::string& entityId, std::optional progress, std::optional completed, + Result watched(const std::string& entityId, std::optional progress, std::optional completed, std::optional watchedOn, std::optional agePolicy) const override; diff --git a/test/api_test_app/apis/discoveryDemo.cpp b/test/api_test_app/apis/discoveryDemo.cpp index 98b199a..932785c 100644 --- a/test/api_test_app/apis/discoveryDemo.cpp +++ b/test/api_test_app/apis/discoveryDemo.cpp @@ -62,7 +62,7 @@ void DiscoveryDemo::runOption(const std::string& method) watchedOn, agePolicyOpt); if (succeed(r)) { - std::cout << "Discovery.watched: Success" << std::endl; + std::cout << "Discovery.watched result: " << std::boolalpha << *r << std::endl; } } else if (method == "Discovery.watchedV2") diff --git a/test/component/discoveryTest.cpp b/test/component/discoveryTest.cpp index e0ae6f5..bdab3a5 100644 --- a/test/component/discoveryTest.cpp +++ b/test/component/discoveryTest.cpp @@ -29,10 +29,13 @@ class DiscoveryCTest : public ::testing::Test TEST_F(DiscoveryCTest, Watched) { + auto expectedValue = jsonEngine.get_value("Discovery.watched"); auto result = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().watched("entity123", 0.75f, true, "2024-10-01T12:00:00Z", Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "Failed to call watched"; + + EXPECT_EQ(*result, expectedValue.get()); } TEST_F(DiscoveryCTest, WatchedV2) diff --git a/test/unit/discoveryTest.cpp b/test/unit/discoveryTest.cpp index 46fb672..f5fd5e1 100644 --- a/test/unit/discoveryTest.cpp +++ b/test/unit/discoveryTest.cpp @@ -36,7 +36,7 @@ TEST_F(DiscoveryUTest, checkEnums) TEST_F(DiscoveryUTest, watched) { - mockInvoke("Discovery.watched"); + mock("Discovery.watched"); std::string entityId = "content123"; std::optional progress = 0.75f; std::optional completed = true; @@ -44,6 +44,9 @@ TEST_F(DiscoveryUTest, watched) std::optional agePolicy = Firebolt::AgePolicy::ADULT; auto result = discoveryImpl_.watched(entityId, progress, completed, watchedOn, agePolicy); ASSERT_TRUE(result) << "Error on watched"; + Firebolt::JSON::Boolean boolJson; + boolJson.fromJson(jsonEngine.get_value("Discovery.watched")); + EXPECT_EQ(boolJson.value(), *result); } TEST_F(DiscoveryUTest, watched_payload) @@ -54,13 +57,14 @@ TEST_F(DiscoveryUTest, watched_payload) expected["completed"] = true; expected["watchedOn"] = "2024-06-01T12:00:00Z"; expected["agePolicy"] = "app:adult"; - EXPECT_CALL(mockHelper, invoke("Discovery.watched", _)) + EXPECT_CALL(mockHelper, getJson("Discovery.watched", _)) .WillOnce(Invoke( [&](const std::string& /* methodName */, const nlohmann::json& parameters) { + bool res = parameters == expected; EXPECT_EQ(parameters, expected) << "Parameters do not match expected payload: " << expected.dump() << " but got: " << parameters.dump(); - return Firebolt::Result{Firebolt::Error::None}; + return Firebolt::Result{res}; })); std::string entityId = "content123"; std::optional progress = 0.75f; @@ -69,6 +73,7 @@ TEST_F(DiscoveryUTest, watched_payload) std::optional agePolicy = Firebolt::AgePolicy::ADULT; auto result = discoveryImpl_.watched(entityId, progress, completed, watchedOn, agePolicy); ASSERT_TRUE(result) << "Error on watched"; + EXPECT_EQ(true, *result); } TEST_F(DiscoveryUTest, watchedV2) From d42ad905ae158ea8b3306401b71ebbf71aaa9f7d Mon Sep 17 00:00:00 2001 From: swethasukumarr Date: Fri, 12 Jun 2026 14:13:49 -0400 Subject: [PATCH 2/4] RDKEMW-17483: Fix copilot comments --- include/firebolt/discovery.h | 2 +- src/discovery_impl.cpp | 7 +------ test/unit/discoveryTest.cpp | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/include/firebolt/discovery.h b/include/firebolt/discovery.h index 55b3913..a3e9982 100644 --- a/include/firebolt/discovery.h +++ b/include/firebolt/discovery.h @@ -39,7 +39,7 @@ class IDiscovery * @param[in] agePolicy : The age policy associated with the watch event. The age policy describes the age groups * to which content may be directed * - * @retval The status. + * @retval Whether the platform successfully recorded the watched notification, or an error */ virtual Result watched(const std::string& entityId, std::optional progress, std::optional completed, std::optional watchedOn, diff --git a/src/discovery_impl.cpp b/src/discovery_impl.cpp index 3d3a8db..67b0f5b 100644 --- a/src/discovery_impl.cpp +++ b/src/discovery_impl.cpp @@ -50,12 +50,7 @@ Result DiscoveryImpl::watched(const std::string& entityId, std::optional result = helper_.get("Discovery.watched", parameters); - if (!result) - { - return Result{result.error()}; - } - return Result{result.value()}; + return helper_.get("Discovery.watched", parameters); } Result DiscoveryImpl::watchedV2(const std::string& entityId, std::optional progress, diff --git a/test/unit/discoveryTest.cpp b/test/unit/discoveryTest.cpp index f5fd5e1..edba6d9 100644 --- a/test/unit/discoveryTest.cpp +++ b/test/unit/discoveryTest.cpp @@ -64,7 +64,7 @@ TEST_F(DiscoveryUTest, watched_payload) bool res = parameters == expected; EXPECT_EQ(parameters, expected) << "Parameters do not match expected payload: " << expected.dump() << " but got: " << parameters.dump(); - return Firebolt::Result{res}; + return Firebolt::Result{nlohmann::json(res)}; })); std::string entityId = "content123"; std::optional progress = 0.75f; From 1002f9a4cb10ee86729d136f24da33fb1600331a Mon Sep 17 00:00:00 2001 From: swethasukumarr Date: Fri, 12 Jun 2026 14:21:43 -0400 Subject: [PATCH 3/4] fix: update changelog --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 767263f..0c78da0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [0.6.2](https://github.com/rdkcentral/firebolt-cpp-client/compare/v0.6.1...v0.6.2) + +### Fixed +- `Discovery.watched` now returns `Result` again (reverts the `Result` change introduced in v0.6.0); + ## [0.6.1](https://github.com/rdkcentral/firebolt-cpp-client/compare/v0.6.0...v0.6.1) ### Added @@ -10,7 +15,7 @@ - `Actions.intent` (no parameters, returns string) - `Actions.onIntent` event -### Changed +### Changed`` - **Breaking**: `Discovery.watched` and all `Metrics.*` methods now return `Result` (previously `Result`) ## [0.5.5](https://github.com/rdkcentral/firebolt-cpp-client/compare/v0.5.4...v0.5.5) From 5b3008e8553c1b7b006d5a98ce81d9197ca5d44f Mon Sep 17 00:00:00 2001 From: swethasukumarr Date: Fri, 12 Jun 2026 14:28:24 -0400 Subject: [PATCH 4/4] fix: Address review comments --- CHANGELOG.md | 4 ++-- docs/openrpc/openrpc/discovery.json | 2 +- docs/openrpc/the-spec/firebolt-open-rpc.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c78da0..6cc774a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ## [0.6.2](https://github.com/rdkcentral/firebolt-cpp-client/compare/v0.6.1...v0.6.2) ### Fixed -- `Discovery.watched` now returns `Result` again (reverts the `Result` change introduced in v0.6.0); +- `Discovery.watched` now returns `Result` again (reverts the `Result` change introduced in v0.6.0). ## [0.6.1](https://github.com/rdkcentral/firebolt-cpp-client/compare/v0.6.0...v0.6.1) @@ -15,7 +15,7 @@ - `Actions.intent` (no parameters, returns string) - `Actions.onIntent` event -### Changed`` +### Changed - **Breaking**: `Discovery.watched` and all `Metrics.*` methods now return `Result` (previously `Result`) ## [0.5.5](https://github.com/rdkcentral/firebolt-cpp-client/compare/v0.5.4...v0.5.5) diff --git a/docs/openrpc/openrpc/discovery.json b/docs/openrpc/openrpc/discovery.json index 1cb0ce3..ac06280 100644 --- a/docs/openrpc/openrpc/discovery.json +++ b/docs/openrpc/openrpc/discovery.json @@ -62,7 +62,7 @@ ], "result": { "name": "success", - "summary": "whether the call was successful or not", + "summary": "Whether the call was successful or not", "schema": { "type": "boolean" } diff --git a/docs/openrpc/the-spec/firebolt-open-rpc.json b/docs/openrpc/the-spec/firebolt-open-rpc.json index becbcf0..698d4f1 100644 --- a/docs/openrpc/the-spec/firebolt-open-rpc.json +++ b/docs/openrpc/the-spec/firebolt-open-rpc.json @@ -583,7 +583,7 @@ ], "result": { "name": "success", - "summary": "whether the call was successful or not", + "summary": "Whether the call was successful or not", "schema": { "type": "boolean" }