diff --git a/CHANGELOG.md b/CHANGELOG.md index 767263f..6cc774a 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 diff --git a/docs/openrpc/openrpc/discovery.json b/docs/openrpc/openrpc/discovery.json index 6f80f61..ac06280 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..698d4f1 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..a3e9982 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 Whether the platform successfully recorded the watched notification, or an error */ - 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..67b0f5b 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,7 @@ Result DiscoveryImpl::watched(const std::string& entityId, std::optional("Discovery.watched", parameters); } 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..edba6d9 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{nlohmann::json(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)