Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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<bool>` again (reverts the `Result<void>` change introduced in v0.6.0).

## [0.6.1](https://github.com/rdkcentral/firebolt-cpp-client/compare/v0.6.0...v0.6.1)

### Added
Expand Down
13 changes: 7 additions & 6 deletions docs/openrpc/openrpc/discovery.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@
}
],
"result": {
"name": "result",
"name": "success",
"summary": "Whether the call was successful or not",
"schema": {
"type": "null"
"type": "boolean"
}
},
"examples": [
Expand All @@ -88,8 +89,8 @@
}
],
"result": {
"name": "result",
"value": null
"name": "success",
"value": true
}
},
{
Expand Down Expand Up @@ -117,8 +118,8 @@
}
],
"result": {
"name": "result",
"value": null
"name": "success",
"value": true
}
}
]
Expand Down
13 changes: 7 additions & 6 deletions docs/openrpc/the-spec/firebolt-open-rpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,10 @@
}
],
"result": {
"name": "result",
"name": "success",
"summary": "Whether the call was successful or not",
"schema": {
"type": "null"
"type": "boolean"
}
},
"examples": [
Expand All @@ -609,8 +610,8 @@
}
],
"result": {
"name": "result",
"value": null
"name": "success",
"value": true
}
},
{
Expand Down Expand Up @@ -638,8 +639,8 @@
}
],
"result": {
"name": "result",
"value": null
"name": "success",
"value": true
}
}
]
Expand Down
4 changes: 2 additions & 2 deletions include/firebolt/discovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> watched(const std::string& entityId, std::optional<double> progress,
virtual Result<bool> watched(const std::string& entityId, std::optional<double> progress,
std::optional<bool> completed, std::optional<std::string> watchedOn,
std::optional<Firebolt::AgePolicy> agePolicy) const = 0;

Expand Down
4 changes: 2 additions & 2 deletions src/discovery_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ DiscoveryImpl::DiscoveryImpl(Firebolt::Helpers::IHelper& helper)
{
}

Result<void> DiscoveryImpl::watched(const std::string& entityId, std::optional<double> progress,
Result<bool> DiscoveryImpl::watched(const std::string& entityId, std::optional<double> progress,
std::optional<bool> completed, std::optional<std::string> watchedOn,
std::optional<Firebolt::AgePolicy> agePolicy) const
{
Expand All @@ -50,7 +50,7 @@ Result<void> DiscoveryImpl::watched(const std::string& entityId, std::optional<d
parameters["agePolicy"] = Firebolt::JSON::toString(Firebolt::JsonData::AgePolicyEnum, *agePolicy);
}

return helper_.invoke("Discovery.watched", parameters);
return helper_.get<Firebolt::JSON::Boolean, bool>("Discovery.watched", parameters);
}

Result<bool> DiscoveryImpl::watchedV2(const std::string& entityId, std::optional<double> progress,
Expand Down
2 changes: 1 addition & 1 deletion src/discovery_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class DiscoveryImpl : public IDiscovery

~DiscoveryImpl() override = default;

Result<void> watched(const std::string& entityId, std::optional<double> progress, std::optional<bool> completed,
Result<bool> watched(const std::string& entityId, std::optional<double> progress, std::optional<bool> completed,
std::optional<std::string> watchedOn,
std::optional<Firebolt::AgePolicy> agePolicy) const override;

Expand Down
2 changes: 1 addition & 1 deletion test/api_test_app/apis/discoveryDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions test/component/discoveryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>());
}

TEST_F(DiscoveryCTest, WatchedV2)
Expand Down
11 changes: 8 additions & 3 deletions test/unit/discoveryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@ TEST_F(DiscoveryUTest, checkEnums)

TEST_F(DiscoveryUTest, watched)
{
mockInvoke("Discovery.watched");
mock("Discovery.watched");
std::string entityId = "content123";
std::optional<double> progress = 0.75f;
std::optional<bool> completed = true;
std::optional<std::string> watchedOn = "2024-06-01T12:00:00Z";
std::optional<Firebolt::AgePolicy> 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)
Expand All @@ -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<void>{Firebolt::Error::None};
return Firebolt::Result<nlohmann::json>{nlohmann::json(res)};
}));
std::string entityId = "content123";
std::optional<double> progress = 0.75f;
Expand All @@ -69,6 +73,7 @@ TEST_F(DiscoveryUTest, watched_payload)
std::optional<Firebolt::AgePolicy> 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)
Expand Down
Loading