diff --git a/docs/openrpc/openrpc/discovery.json b/docs/openrpc/openrpc/discovery.json index b6f22c0..8862606 100644 --- a/docs/openrpc/openrpc/discovery.json +++ b/docs/openrpc/openrpc/discovery.json @@ -61,10 +61,9 @@ } ], "result": { - "name": "success", - "summary": "whether the call was successful or not", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -89,8 +88,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } }, { @@ -118,8 +117,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] diff --git a/docs/openrpc/openrpc/metrics.json b/docs/openrpc/openrpc/metrics.json index fe89723..b1d705b 100644 --- a/docs/openrpc/openrpc/metrics.json +++ b/docs/openrpc/openrpc/metrics.json @@ -19,9 +19,9 @@ "summary": "Inform the platform that your app is minimally usable. This method is called automatically by `Lifecycle.ready()`", "params": [], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -29,8 +29,8 @@ "name": "Send ready metric", "params": [], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -51,9 +51,9 @@ "summary": "Log a sign in event, called by Discovery.signIn().", "params": [], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -61,8 +61,8 @@ "name": "Send signIn metric", "params": [], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -83,9 +83,9 @@ "summary": "Log a sign out event, called by Discovery.signOut().", "params": [], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -93,8 +93,8 @@ "name": "Send signOut metric", "params": [], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -128,9 +128,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -138,8 +138,8 @@ "name": "Send startContent metric", "params": [], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } }, { @@ -151,8 +151,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } }, { @@ -168,8 +168,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -203,9 +203,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -213,8 +213,8 @@ "name": "Send stopContent metric", "params": [], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } }, { @@ -226,8 +226,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -261,9 +261,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -276,8 +276,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } }, { @@ -289,8 +289,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -356,9 +356,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -383,8 +383,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -418,9 +418,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -433,8 +433,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -468,9 +468,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -483,8 +483,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -518,9 +518,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -533,8 +533,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -568,9 +568,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -583,8 +583,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -618,9 +618,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -633,8 +633,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -676,9 +676,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -691,12 +691,12 @@ }, { "name": "target", - "value": 0.50 + "value": 0.5 } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -738,9 +738,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -757,8 +757,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -800,9 +800,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -819,8 +819,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -886,9 +886,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -917,8 +917,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -952,9 +952,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -967,8 +967,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -1013,7 +1013,7 @@ "result": { "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -1031,7 +1031,7 @@ ], "result": { "name": "result", - "value": true + "value": null } } ] @@ -1135,4 +1135,4 @@ } } } -} \ No newline at end of file +} diff --git a/docs/openrpc/the-spec/firebolt-open-rpc.json b/docs/openrpc/the-spec/firebolt-open-rpc.json index 05a1fc6..82b8600 100644 --- a/docs/openrpc/the-spec/firebolt-open-rpc.json +++ b/docs/openrpc/the-spec/firebolt-open-rpc.json @@ -502,10 +502,9 @@ } ], "result": { - "name": "success", - "summary": "whether the call was successful or not", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -530,8 +529,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } }, { @@ -559,8 +558,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -902,9 +901,9 @@ "summary": "Inform the platform that your app is minimally usable. This method is called automatically by `Lifecycle.ready()`", "params": [], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -912,8 +911,8 @@ "name": "Send ready metric", "params": [], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -934,9 +933,9 @@ "summary": "Log a sign in event, called by Discovery.signIn().", "params": [], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -944,8 +943,8 @@ "name": "Send signIn metric", "params": [], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -966,9 +965,9 @@ "summary": "Log a sign out event, called by Discovery.signOut().", "params": [], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -976,8 +975,8 @@ "name": "Send signOut metric", "params": [], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -1011,9 +1010,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -1021,8 +1020,8 @@ "name": "Send startContent metric", "params": [], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } }, { @@ -1034,8 +1033,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } }, { @@ -1051,8 +1050,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -1086,9 +1085,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -1096,8 +1095,8 @@ "name": "Send stopContent metric", "params": [], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } }, { @@ -1109,8 +1108,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -1144,9 +1143,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -1159,8 +1158,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } }, { @@ -1172,8 +1171,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -1239,9 +1238,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -1266,8 +1265,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -1301,9 +1300,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -1316,8 +1315,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -1351,9 +1350,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -1366,8 +1365,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -1401,9 +1400,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -1416,8 +1415,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -1451,9 +1450,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -1466,8 +1465,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -1501,9 +1500,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -1516,8 +1515,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -1559,9 +1558,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -1578,8 +1577,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -1621,9 +1620,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -1640,8 +1639,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -1683,9 +1682,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -1702,8 +1701,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -1769,9 +1768,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -1800,8 +1799,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -1835,9 +1834,9 @@ } ], "result": { - "name": "success", + "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -1850,8 +1849,8 @@ } ], "result": { - "name": "success", - "value": true + "name": "result", + "value": null } } ] @@ -1896,7 +1895,7 @@ "result": { "name": "result", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -1914,7 +1913,7 @@ ], "result": { "name": "result", - "value": true + "value": null } } ] diff --git a/include/firebolt/discovery.h b/include/firebolt/discovery.h index 50cecb9..885380e 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 The status. + * @retval An ok Result on success, or an error; no value is returned */ - 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/include/firebolt/metrics.h b/include/firebolt/metrics.h index d14c5bf..6927674 100644 --- a/include/firebolt/metrics.h +++ b/include/firebolt/metrics.h @@ -43,23 +43,23 @@ class IMetrics /** * @brief Informs the platform that the app is minimally usable * - * @retval The success state or error + * @retval An ok Result on success, or an error; no value is returned */ - virtual Result ready() const = 0; + virtual Result ready() const = 0; /** * @brief Logs a sign in event * - * @retval The success state or error + * @retval An ok Result on success, or an error; no value is returned */ - virtual Result signIn() const = 0; + virtual Result signIn() const = 0; /** * @brief Logs a sign out event * - * @retval The success state or error + * @retval An ok Result on success, or an error; no value is returned */ - virtual Result signOut() const = 0; + virtual Result signOut() const = 0; /** * @brief Informs the platform that your user has started content @@ -68,9 +68,9 @@ class IMetrics * @param[in] agePolicy : The age policy to associate with the metrics event, the age policy describes the age group * to which content is directed * - * @retval The success state or error + * @retval An ok Result on success, or an error; no value is returned */ - virtual Result startContent(const std::optional& entityId, + virtual Result startContent(const std::optional& entityId, const std::optional agePolicy) const = 0; /** @@ -80,9 +80,9 @@ class IMetrics * @param[in] agePolicy : The age policy to associate with the metrics event, the age policy describes the age group * to which content is directed * - * @retval The success state or error + * @retval An ok Result on success, or an error; no value is returned */ - virtual Result stopContent(const std::optional& entityId, + virtual Result stopContent(const std::optional& entityId, const std::optional agePolicy) const = 0; /** @@ -92,9 +92,9 @@ class IMetrics * @param[in] agePolicy : The age policy to associate with the metrics event, the age policy describes the age group * to which content is directed * - * @retval The success state or error + * @retval An ok Result on success, or an error; no value is returned */ - virtual Result page(const std::string& pageId, const std::optional& agePolicy) const = 0; + virtual Result page(const std::string& pageId, const std::optional& agePolicy) const = 0; /** * @brief Informs the platform of an error that has occurred in your app @@ -107,9 +107,9 @@ class IMetrics * @param[in] agePolicy : The age policy to associate with the metrics event, the age policy describes the age * group to which content is directed * - * @retval The success state or error + * @retval An ok Result on success, or an error; no value is returned */ - virtual Result error(const ErrorType type, const std::string& code, const std::string& description, + virtual Result error(const ErrorType type, const std::string& code, const std::string& description, const bool visible, const std::optional>& parameters, const std::optional& agePolicy) const = 0; @@ -120,9 +120,9 @@ class IMetrics * @param[in] agePolicy : The age policy to associate with the metrics event, the age policy describes the age group * to which content is directed * - * @retval The success state or error + * @retval An ok Result on success, or an error; no value is returned */ - virtual Result mediaLoadStart(const std::string& entityId, + virtual Result mediaLoadStart(const std::string& entityId, const std::optional& agePolicy) const = 0; /** @@ -133,9 +133,9 @@ class IMetrics * @param[in] agePolicy : The age policy to associate with the metrics event, the age policy describes the age group * to which content is directed * - * @retval The success state or error + * @retval An ok Result on success, or an error; no value is returned */ - virtual Result mediaPlaying(const std::string& entityId, + virtual Result mediaPlaying(const std::string& entityId, const std::optional& agePolicy) const = 0; /** @@ -145,9 +145,9 @@ class IMetrics * @param[in] agePolicy : The age policy to associate with the metrics event, the age policy describes the age group * to which content is directed * - * @retval The success state or error + * @retval An ok Result on success, or an error; no value is returned */ - virtual Result mediaPlay(const std::string& entityId, + virtual Result mediaPlay(const std::string& entityId, const std::optional& agePolicy) const = 0; /** @@ -157,9 +157,9 @@ class IMetrics * @param[in] agePolicy : The age policy to associate with the metrics event, the age policy describes the age group * to which content is directed * - * @retval The success state or error + * @retval An ok Result on success, or an error; no value is returned */ - virtual Result mediaPause(const std::string& entityId, + virtual Result mediaPause(const std::string& entityId, const std::optional& agePolicy) const = 0; /** @@ -169,9 +169,9 @@ class IMetrics * @param[in] agePolicy : The age policy to associate with the metrics event, the age policy describes the age group * to which content is directed * - * @retval The success state or error + * @retval An ok Result on success, or an error; no value is returned */ - virtual Result mediaWaiting(const std::string& entityId, + virtual Result mediaWaiting(const std::string& entityId, const std::optional& agePolicy) const = 0; /** @@ -183,9 +183,9 @@ class IMetrics * @param[in] agePolicy : The age policy to associate with the metrics event, the age policy describes the age group * to which content is directed * - * @retval The success state or error + * @retval An ok Result on success, or an error; no value is returned */ - virtual Result mediaSeeking(const std::string& entityId, const double target, + virtual Result mediaSeeking(const std::string& entityId, const double target, const std::optional& agePolicy) const = 0; /** @@ -198,9 +198,9 @@ class IMetrics * @param[in] agePolicy : The age policy to associate with the metrics event, the age policy describes the age group * to which content is directed * - * @retval The success state or error + * @retval An ok Result on success, or an error; no value is returned */ - virtual Result mediaSeeked(const std::string& entityId, const double position, + virtual Result mediaSeeked(const std::string& entityId, const double position, const std::optional& agePolicy) const = 0; /** @@ -211,9 +211,9 @@ class IMetrics * @param[in] agePolicy : The age policy to associate with the metrics event, the age policy describes the age group * to which content is directed * - * @retval The success state or error + * @retval An ok Result on success, or an error; no value is returned */ - virtual Result mediaRateChanged(const std::string& entityId, const double rate, + virtual Result mediaRateChanged(const std::string& entityId, const double rate, const std::optional& agePolicy) const = 0; /** @@ -227,9 +227,9 @@ class IMetrics * @param[in] agePolicy : The age policy to associate with the metrics event, the age policy describes the age group * to which content is directed * - * @retval The success state or error + * @retval An ok Result on success, or an error; no value is returned */ - virtual Result mediaRenditionChanged(const std::string& entityId, const unsigned bitrate, const unsigned width, + virtual Result mediaRenditionChanged(const std::string& entityId, const unsigned bitrate, const unsigned width, const unsigned height, const std::optional& profile, const std::optional& agePolicy) const = 0; @@ -240,9 +240,9 @@ class IMetrics * @param[in] agePolicy : The age policy to associate with the metrics event, the age policy describes the age group * to which content is directed * - * @retval The success state or error + * @retval An ok Result on success, or an error; no value is returned */ - virtual Result mediaEnded(const std::string& entityId, + virtual Result mediaEnded(const std::string& entityId, const std::optional& agePolicy) const = 0; /** @@ -253,9 +253,9 @@ class IMetrics * @param[in] agePolicy : The age policy to associate with the metrics event, the age policy describes the age group * to which content is directed * - * @retval The success state or error + * @retval An ok Result on success, or an error; no value is returned */ - virtual Result event(const std::string& schema, const std::string& data, + virtual Result event(const std::string& schema, const std::string& data, const std::optional& agePolicy) const = 0; /** @@ -263,7 +263,7 @@ class IMetrics * * @param[in] build : The build / version of this app * - * @retval The status + * @retval An ok Result on success, or an error; no value is returned */ virtual Result appInfo(const std::string& build) const = 0; }; diff --git a/src/discovery_impl.cpp b/src/discovery_impl.cpp index cc209c0..e653777 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,11 +50,6 @@ 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_.invoke("Discovery.watched", parameters); } } // namespace Firebolt::Discovery diff --git a/src/discovery_impl.h b/src/discovery_impl.h index 30a78f8..34e12f1 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/src/metrics_impl.cpp b/src/metrics_impl.cpp index 892be95..9f29027 100644 --- a/src/metrics_impl.cpp +++ b/src/metrics_impl.cpp @@ -28,22 +28,22 @@ MetricsImpl::MetricsImpl(Firebolt::Helpers::IHelper& helper) { } -Result MetricsImpl::ready() const +Result MetricsImpl::ready() const { - return helper_.get("Metrics.ready"); + return helper_.invoke("Metrics.ready", nlohmann::json({})); } -Result MetricsImpl::signIn() const +Result MetricsImpl::signIn() const { - return helper_.get("Metrics.signIn"); + return helper_.invoke("Metrics.signIn", nlohmann::json({})); } -Result MetricsImpl::signOut() const +Result MetricsImpl::signOut() const { - return helper_.get("Metrics.signOut"); + return helper_.invoke("Metrics.signOut", nlohmann::json({})); } -Result MetricsImpl::startContent(const std::optional& entityId, +Result MetricsImpl::startContent(const std::optional& entityId, const std::optional agePolicy) const { nlohmann::json parameters; @@ -55,10 +55,10 @@ Result MetricsImpl::startContent(const std::optional& entityI { parameters["agePolicy"] = Firebolt::JSON::toString(Firebolt::JsonData::AgePolicyEnum, *agePolicy); } - return helper_.get("Metrics.startContent", parameters); + return helper_.invoke("Metrics.startContent", parameters); } -Result MetricsImpl::stopContent(const std::optional& entityId, +Result MetricsImpl::stopContent(const std::optional& entityId, const std::optional agePolicy) const { nlohmann::json parameters; @@ -70,10 +70,10 @@ Result MetricsImpl::stopContent(const std::optional& entityId { parameters["agePolicy"] = Firebolt::JSON::toString(Firebolt::JsonData::AgePolicyEnum, *agePolicy); } - return helper_.get("Metrics.stopContent", parameters); + return helper_.invoke("Metrics.stopContent", parameters); } -Result MetricsImpl::page(const std::string& pageId, const std::optional& agePolicy) const +Result MetricsImpl::page(const std::string& pageId, const std::optional& agePolicy) const { nlohmann::json parameters; parameters["pageId"] = pageId; @@ -81,10 +81,10 @@ Result MetricsImpl::page(const std::string& pageId, const std::optional("Metrics.page", parameters); + return helper_.invoke("Metrics.page", parameters); } -Result MetricsImpl::error(const ErrorType type, const std::string& code, const std::string& description, +Result MetricsImpl::error(const ErrorType type, const std::string& code, const std::string& description, const bool visible, const std::optional>& parameters, const std::optional& agePolicy) const { @@ -106,10 +106,10 @@ Result MetricsImpl::error(const ErrorType type, const std::string& code, c { jsonParameters["agePolicy"] = Firebolt::JSON::toString(Firebolt::JsonData::AgePolicyEnum, *agePolicy); } - return helper_.get("Metrics.error", jsonParameters); + return helper_.invoke("Metrics.error", jsonParameters); } -Result MetricsImpl::mediaLoadStart(const std::string& entityId, +Result MetricsImpl::mediaLoadStart(const std::string& entityId, const std::optional& agePolicy) const { nlohmann::json parameters; @@ -118,10 +118,10 @@ Result MetricsImpl::mediaLoadStart(const std::string& entityId, { parameters["agePolicy"] = Firebolt::JSON::toString(Firebolt::JsonData::AgePolicyEnum, *agePolicy); } - return helper_.get("Metrics.mediaLoadStart", parameters); + return helper_.invoke("Metrics.mediaLoadStart", parameters); } -Result MetricsImpl::mediaPlay(const std::string& entityId, const std::optional& agePolicy) const +Result MetricsImpl::mediaPlay(const std::string& entityId, const std::optional& agePolicy) const { nlohmann::json parameters; parameters["entityId"] = entityId; @@ -129,10 +129,10 @@ Result MetricsImpl::mediaPlay(const std::string& entityId, const std::opti { parameters["agePolicy"] = Firebolt::JSON::toString(Firebolt::JsonData::AgePolicyEnum, *agePolicy); } - return helper_.get("Metrics.mediaPlay", parameters); + return helper_.invoke("Metrics.mediaPlay", parameters); } -Result MetricsImpl::mediaPlaying(const std::string& entityId, +Result MetricsImpl::mediaPlaying(const std::string& entityId, const std::optional& agePolicy) const { nlohmann::json parameters; @@ -141,10 +141,10 @@ Result MetricsImpl::mediaPlaying(const std::string& entityId, { parameters["agePolicy"] = Firebolt::JSON::toString(Firebolt::JsonData::AgePolicyEnum, *agePolicy); } - return helper_.get("Metrics.mediaPlaying", parameters); + return helper_.invoke("Metrics.mediaPlaying", parameters); } -Result MetricsImpl::mediaPause(const std::string& entityId, const std::optional& agePolicy) const +Result MetricsImpl::mediaPause(const std::string& entityId, const std::optional& agePolicy) const { nlohmann::json parameters; parameters["entityId"] = entityId; @@ -152,10 +152,10 @@ Result MetricsImpl::mediaPause(const std::string& entityId, const std::opt { parameters["agePolicy"] = Firebolt::JSON::toString(Firebolt::JsonData::AgePolicyEnum, *agePolicy); } - return helper_.get("Metrics.mediaPause", parameters); + return helper_.invoke("Metrics.mediaPause", parameters); } -Result MetricsImpl::mediaWaiting(const std::string& entityId, +Result MetricsImpl::mediaWaiting(const std::string& entityId, const std::optional& agePolicy) const { nlohmann::json parameters; @@ -164,10 +164,10 @@ Result MetricsImpl::mediaWaiting(const std::string& entityId, { parameters["agePolicy"] = Firebolt::JSON::toString(Firebolt::JsonData::AgePolicyEnum, *agePolicy); } - return helper_.get("Metrics.mediaWaiting", parameters); + return helper_.invoke("Metrics.mediaWaiting", parameters); } -Result MetricsImpl::mediaSeeking(const std::string& entityId, const double target, +Result MetricsImpl::mediaSeeking(const std::string& entityId, const double target, const std::optional& agePolicy) const { nlohmann::json parameters; @@ -177,10 +177,10 @@ Result MetricsImpl::mediaSeeking(const std::string& entityId, const double { parameters["agePolicy"] = Firebolt::JSON::toString(Firebolt::JsonData::AgePolicyEnum, *agePolicy); } - return helper_.get("Metrics.mediaSeeking", parameters); + return helper_.invoke("Metrics.mediaSeeking", parameters); } -Result MetricsImpl::mediaSeeked(const std::string& entityId, const double position, +Result MetricsImpl::mediaSeeked(const std::string& entityId, const double position, const std::optional& agePolicy) const { nlohmann::json parameters; @@ -190,10 +190,10 @@ Result MetricsImpl::mediaSeeked(const std::string& entityId, const double { parameters["agePolicy"] = Firebolt::JSON::toString(Firebolt::JsonData::AgePolicyEnum, *agePolicy); } - return helper_.get("Metrics.mediaSeeked", parameters); + return helper_.invoke("Metrics.mediaSeeked", parameters); } -Result MetricsImpl::mediaRateChanged(const std::string& entityId, const double rate, +Result MetricsImpl::mediaRateChanged(const std::string& entityId, const double rate, const std::optional& agePolicy) const { nlohmann::json parameters; @@ -203,10 +203,10 @@ Result MetricsImpl::mediaRateChanged(const std::string& entityId, const do { parameters["agePolicy"] = Firebolt::JSON::toString(Firebolt::JsonData::AgePolicyEnum, *agePolicy); } - return helper_.get("Metrics.mediaRateChanged", parameters); + return helper_.invoke("Metrics.mediaRateChanged", parameters); } -Result MetricsImpl::mediaRenditionChanged(const std::string& entityId, const unsigned bitrate, const unsigned width, +Result MetricsImpl::mediaRenditionChanged(const std::string& entityId, const unsigned bitrate, const unsigned width, const unsigned height, const std::optional& profile, const std::optional& agePolicy) const { @@ -223,10 +223,10 @@ Result MetricsImpl::mediaRenditionChanged(const std::string& entityId, con { parameters["agePolicy"] = Firebolt::JSON::toString(Firebolt::JsonData::AgePolicyEnum, *agePolicy); } - return helper_.get("Metrics.mediaRenditionChanged", parameters); + return helper_.invoke("Metrics.mediaRenditionChanged", parameters); } -Result MetricsImpl::mediaEnded(const std::string& entityId, const std::optional& agePolicy) const +Result MetricsImpl::mediaEnded(const std::string& entityId, const std::optional& agePolicy) const { nlohmann::json parameters; parameters["entityId"] = entityId; @@ -234,10 +234,10 @@ Result MetricsImpl::mediaEnded(const std::string& entityId, const std::opt { parameters["agePolicy"] = Firebolt::JSON::toString(Firebolt::JsonData::AgePolicyEnum, *agePolicy); } - return helper_.get("Metrics.mediaEnded", parameters); + return helper_.invoke("Metrics.mediaEnded", parameters); } -Result MetricsImpl::event(const std::string& schema, const std::string& data, +Result MetricsImpl::event(const std::string& schema, const std::string& data, const std::optional& agePolicy) const { nlohmann::json parameters; @@ -247,7 +247,7 @@ Result MetricsImpl::event(const std::string& schema, const std::string& da { parameters["agePolicy"] = Firebolt::JSON::toString(Firebolt::JsonData::AgePolicyEnum, *agePolicy); } - return helper_.get("Metrics.event", parameters); + return helper_.invoke("Metrics.event", parameters); } Result MetricsImpl::appInfo(const std::string& build) const diff --git a/src/metrics_impl.h b/src/metrics_impl.h index 4eb0da6..ace303b 100644 --- a/src/metrics_impl.h +++ b/src/metrics_impl.h @@ -32,39 +32,39 @@ class MetricsImpl : public IMetrics ~MetricsImpl() override = default; - Result ready() const override; - Result signIn() const override; - Result signOut() const override; - Result startContent(const std::optional& entityId, + Result ready() const override; + Result signIn() const override; + Result signOut() const override; + Result startContent(const std::optional& entityId, const std::optional agePolicy) const override; - Result stopContent(const std::optional& entityId, + Result stopContent(const std::optional& entityId, const std::optional agePolicy) const override; - Result page(const std::string& pageId, const std::optional& agePolicy) const override; - Result error(const ErrorType type, const std::string& code, const std::string& description, + Result page(const std::string& pageId, const std::optional& agePolicy) const override; + Result error(const ErrorType type, const std::string& code, const std::string& description, const bool visible, const std::optional>& parameters, const std::optional& agePolicy) const override; - Result mediaLoadStart(const std::string& entityId, + Result mediaLoadStart(const std::string& entityId, const std::optional& agePolicy) const override; - Result mediaPlay(const std::string& entityId, + Result mediaPlay(const std::string& entityId, const std::optional& agePolicy) const override; - Result mediaPlaying(const std::string& entityId, + Result mediaPlaying(const std::string& entityId, const std::optional& agePolicy) const override; - Result mediaPause(const std::string& entityId, + Result mediaPause(const std::string& entityId, const std::optional& agePolicy) const override; - Result mediaWaiting(const std::string& entityId, + Result mediaWaiting(const std::string& entityId, const std::optional& agePolicy) const override; - Result mediaSeeking(const std::string& entityId, const double target, + Result mediaSeeking(const std::string& entityId, const double target, const std::optional& agePolicy) const override; - Result mediaSeeked(const std::string& entityId, const double position, + Result mediaSeeked(const std::string& entityId, const double position, const std::optional& agePolicy) const override; - Result mediaRateChanged(const std::string& entityId, const double rate, + Result mediaRateChanged(const std::string& entityId, const double rate, const std::optional& agePolicy) const override; - Result mediaRenditionChanged(const std::string& entityId, const unsigned bitrate, const unsigned width, + Result mediaRenditionChanged(const std::string& entityId, const unsigned bitrate, const unsigned width, const unsigned height, const std::optional& profile, const std::optional& agePolicy) const override; - Result mediaEnded(const std::string& entityId, + Result mediaEnded(const std::string& entityId, const std::optional& agePolicy) const override; - Result event(const std::string& schema, const std::string& data, + Result event(const std::string& schema, const std::string& data, const std::optional& agePolicy) const override; Result appInfo(const std::string& build) const override; diff --git a/test/api_test_app/apis/discoveryDemo.cpp b/test/api_test_app/apis/discoveryDemo.cpp index 0e3afba..5e0b9d6 100644 --- a/test/api_test_app/apis/discoveryDemo.cpp +++ b/test/api_test_app/apis/discoveryDemo.cpp @@ -61,7 +61,7 @@ void DiscoveryDemo::runOption(const std::string& method) watchedOn, agePolicyOpt); if (succeed(r)) { - std::cout << "Discovery.watched result: " << std::boolalpha << *r << std::endl; + std::cout << "Discovery.watched: Success" << std::endl; } } } diff --git a/test/api_test_app/apis/metricsDemo.cpp b/test/api_test_app/apis/metricsDemo.cpp index e494cd0..9ac520d 100644 --- a/test/api_test_app/apis/metricsDemo.cpp +++ b/test/api_test_app/apis/metricsDemo.cpp @@ -56,7 +56,7 @@ void MetricsDemo::runOption(const std::string& method) auto r = Firebolt::IFireboltAccessor::Instance().MetricsInterface().ready(); if (succeed(r)) { - std::cout << "Metrics Ready: " << std::boolalpha << *r << std::endl; + std::cout << "Metrics Ready: Success" << std::endl; } } else if (method == "Metrics.signIn") @@ -64,7 +64,7 @@ void MetricsDemo::runOption(const std::string& method) auto r = Firebolt::IFireboltAccessor::Instance().MetricsInterface().signIn(); if (succeed(r)) { - std::cout << "Metrics Sign In: " << std::boolalpha << *r << std::endl; + std::cout << "Metrics Sign In: Success" << std::endl; } } else if (method == "Metrics.signOut") @@ -72,7 +72,7 @@ void MetricsDemo::runOption(const std::string& method) auto r = Firebolt::IFireboltAccessor::Instance().MetricsInterface().signOut(); if (succeed(r)) { - std::cout << "Metrics Sign Out: " << std::boolalpha << *r << std::endl; + std::cout << "Metrics Sign Out: Success" << std::endl; } } else if (method == "Metrics.startContent") @@ -80,7 +80,7 @@ void MetricsDemo::runOption(const std::string& method) auto r = Firebolt::IFireboltAccessor::Instance().MetricsInterface().startContent("entity123", std::nullopt); if (succeed(r)) { - std::cout << "Metrics Start Content: " << std::boolalpha << *r << std::endl; + std::cout << "Metrics Start Content: Success" << std::endl; } } else if (method == "Metrics.stopContent") @@ -88,7 +88,7 @@ void MetricsDemo::runOption(const std::string& method) auto r = Firebolt::IFireboltAccessor::Instance().MetricsInterface().stopContent("entity123", std::nullopt); if (succeed(r)) { - std::cout << "Metrics Stop Content: " << std::boolalpha << *r << std::endl; + std::cout << "Metrics Stop Content: Success" << std::endl; } } else if (method == "Metrics.page") @@ -96,7 +96,7 @@ void MetricsDemo::runOption(const std::string& method) auto r = Firebolt::IFireboltAccessor::Instance().MetricsInterface().page("page123", std::nullopt); if (succeed(r)) { - std::cout << "Metrics Page: " << std::boolalpha << *r << std::endl; + std::cout << "Metrics Page: Success" << std::endl; } } else if (method == "Metrics.error") @@ -106,7 +106,7 @@ void MetricsDemo::runOption(const std::string& method) std::nullopt, std::nullopt); if (succeed(r)) { - std::cout << "Metrics Error: " << std::boolalpha << *r << std::endl; + std::cout << "Metrics Error: Success" << std::endl; } } else if (method == "Metrics.mediaLoadStart") @@ -114,7 +114,7 @@ void MetricsDemo::runOption(const std::string& method) auto r = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaLoadStart("entity123", std::nullopt); if (succeed(r)) { - std::cout << "Metrics Media Load Start: " << std::boolalpha << *r << std::endl; + std::cout << "Metrics Media Load Start: Success" << std::endl; } } else if (method == "Metrics.mediaPlay") @@ -122,7 +122,7 @@ void MetricsDemo::runOption(const std::string& method) auto r = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaPlay("entity123", std::nullopt); if (succeed(r)) { - std::cout << "Metrics Media Play: " << std::boolalpha << *r << std::endl; + std::cout << "Metrics Media Play: Success" << std::endl; } } else if (method == "Metrics.mediaPlaying") @@ -130,7 +130,7 @@ void MetricsDemo::runOption(const std::string& method) auto r = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaPlaying("entity123", std::nullopt); if (succeed(r)) { - std::cout << "Metrics Media Playing: " << std::boolalpha << *r << std::endl; + std::cout << "Metrics Media Playing: Success" << std::endl; } } else if (method == "Metrics.mediaPause") @@ -138,7 +138,7 @@ void MetricsDemo::runOption(const std::string& method) auto r = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaPause("entity123", std::nullopt); if (succeed(r)) { - std::cout << "Metrics Media Pause: " << std::boolalpha << *r << std::endl; + std::cout << "Metrics Media Pause: Success" << std::endl; } } else if (method == "Metrics.mediaWaiting") @@ -146,7 +146,7 @@ void MetricsDemo::runOption(const std::string& method) auto r = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaWaiting("entity123", std::nullopt); if (succeed(r)) { - std::cout << "Metrics Media Waiting: " << std::boolalpha << *r << std::endl; + std::cout << "Metrics Media Waiting: Success" << std::endl; } } else if (method == "Metrics.mediaSeeking") @@ -154,7 +154,7 @@ void MetricsDemo::runOption(const std::string& method) auto r = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaSeeking("entity123", 0.5, std::nullopt); if (succeed(r)) { - std::cout << "Metrics Media Seeking: " << std::boolalpha << *r << std::endl; + std::cout << "Metrics Media Seeking: Success" << std::endl; } } else if (method == "Metrics.mediaSeeked") @@ -162,7 +162,7 @@ void MetricsDemo::runOption(const std::string& method) auto r = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaSeeked("entity123", 0.5, std::nullopt); if (succeed(r)) { - std::cout << "Metrics Media Seeked: " << std::boolalpha << *r << std::endl; + std::cout << "Metrics Media Seeked: Success" << std::endl; } } else if (method == "Metrics.mediaRateChanged") @@ -171,7 +171,7 @@ void MetricsDemo::runOption(const std::string& method) Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaRateChanged("entity123", 1.5, std::nullopt); if (succeed(r)) { - std::cout << "Metrics Media Rate Changed: " << std::boolalpha << *r << std::endl; + std::cout << "Metrics Media Rate Changed: Success" << std::endl; } } else if (method == "Metrics.mediaRenditionChanged") @@ -181,7 +181,7 @@ void MetricsDemo::runOption(const std::string& method) std::nullopt); if (succeed(r)) { - std::cout << "Metrics Media Rendition Changed: " << std::boolalpha << *r << std::endl; + std::cout << "Metrics Media Rendition Changed: Success" << std::endl; } } else if (method == "Metrics.mediaEnded") @@ -189,7 +189,7 @@ void MetricsDemo::runOption(const std::string& method) auto r = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaEnded("entity123", std::nullopt); if (succeed(r)) { - std::cout << "Metrics Media Ended: " << std::boolalpha << *r << std::endl; + std::cout << "Metrics Media Ended: Success" << std::endl; } } else if (method == "Metrics.event") @@ -198,7 +198,7 @@ void MetricsDemo::runOption(const std::string& method) "{\"key\":\"value\"}", std::nullopt); if (succeed(r)) { - std::cout << "Metrics Event: " << std::boolalpha << *r << std::endl; + std::cout << "Metrics Event: Success" << std::endl; } } else if (method == "Metrics.appInfo") diff --git a/test/component/discoveryTest.cpp b/test/component/discoveryTest.cpp index bc118b6..c1cfcf1 100644 --- a/test/component/discoveryTest.cpp +++ b/test/component/discoveryTest.cpp @@ -18,12 +18,10 @@ #include "firebolt/discovery.h" #include "firebolt/firebolt.h" -#include "json_engine.h" +#include class DiscoveryCTest : public ::testing::Test { -protected: - JsonEngine jsonEngine; }; TEST_F(DiscoveryCTest, Watched) @@ -32,7 +30,4 @@ TEST_F(DiscoveryCTest, Watched) "2024-10-01T12:00:00Z", Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "Failed to call watched"; - - auto expectedValue = jsonEngine.get_value("Discovery.watched"); - EXPECT_EQ(*result, expectedValue.get()); } diff --git a/test/component/metricsTest.cpp b/test/component/metricsTest.cpp index e626a6d..9e1d6fc 100644 --- a/test/component/metricsTest.cpp +++ b/test/component/metricsTest.cpp @@ -17,7 +17,6 @@ */ #include "firebolt/firebolt.h" -#include "json_engine.h" #include "utils.h" #include @@ -25,235 +24,185 @@ class MetricsCTest : public ::testing::Test { protected: void SetUp() override {} - - JsonEngine jsonEngine; }; TEST_F(MetricsCTest, Ready) { - auto expectedValue = jsonEngine.get_value("Metrics.ready"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().ready(); ASSERT_TRUE(result) << "MetricsImpl::ready() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, SignIn) { - auto expectedValue = jsonEngine.get_value("Metrics.signIn"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().signIn(); ASSERT_TRUE(result) << "MetricsImpl::signIn() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, SignOut) { - auto expectedValue = jsonEngine.get_value("Metrics.signOut"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().signOut(); ASSERT_TRUE(result) << "MetricsImpl::signOut() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, StartContent) { - auto expectedValue = jsonEngine.get_value("Metrics.startContent"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().startContent("entity123", Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "MetricsImpl::startContent() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, StopContent) { - auto expectedValue = jsonEngine.get_value("Metrics.stopContent"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().stopContent("entity123", Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "MetricsImpl::stopContent() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, Page) { - auto expectedValue = jsonEngine.get_value("Metrics.page"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().page("homePage", Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "MetricsImpl::page() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, Error) { - auto expectedValue = jsonEngine.get_value("Metrics.error"); auto result = Firebolt::IFireboltAccessor::Instance() .MetricsInterface() .error(Firebolt::Metrics::ErrorType::Network, "ERR001", "Network error occurred", true, std::map{{"param1", "value1"}, {"param2", "value2"}}, Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "MetricsImpl::error() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, ErrorNoParameters) { - auto expectedValue = jsonEngine.get_value("Metrics.error"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().error(Firebolt::Metrics::ErrorType::Network, "ERR001", "Network error occurred", true, std::nullopt, Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "MetricsImpl::error() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, ErrorNoAgePolicy) { - auto expectedValue = jsonEngine.get_value("Metrics.error"); auto result = Firebolt::IFireboltAccessor::Instance() .MetricsInterface() .error(Firebolt::Metrics::ErrorType::Network, "ERR001", "Network error occurred", true, std::map{{"param1", "value1"}, {"param2", "value2"}}, std::nullopt); ASSERT_TRUE(result) << "MetricsImpl::error() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, MediaLoadStart) { - auto expectedValue = jsonEngine.get_value("Metrics.mediaLoadStart"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaLoadStart("mediaEntity123", Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "MetricsImpl::mediaLoadStart() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, MediaPlay) { - auto expectedValue = jsonEngine.get_value("Metrics.mediaPlay"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaPlay("mediaEntity123", Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "MetricsImpl::mediaPlay() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, MediaPlaying) { - auto expectedValue = jsonEngine.get_value("Metrics.mediaPlaying"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaPlaying("mediaEntity123", Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "MetricsImpl::mediaPlaying() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, MediaPause) { - auto expectedValue = jsonEngine.get_value("Metrics.mediaPause"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaPause("mediaEntity123", Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "MetricsImpl::mediaPause() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, MediaWaiting) { - auto expectedValue = jsonEngine.get_value("Metrics.mediaWaiting"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaWaiting("mediaEntity123", Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "MetricsImpl::mediaWaiting() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, MediaSeeking) { - auto expectedValue = jsonEngine.get_value("Metrics.mediaSeeking"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaSeeking("mediaEntity123", 0.5, Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "MetricsImpl::mediaSeeking() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, MediaSeekingInt) { - auto expectedValue = jsonEngine.get_value("Metrics.mediaSeeking"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaSeeking("mediaEntity123", 500, Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "MetricsImpl::mediaSeeking() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, MediaSeeked) { - auto expectedValue = jsonEngine.get_value("Metrics.mediaSeeked"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaSeeked("mediaEntity123", 0.5, Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "MetricsImpl::mediaSeeked() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, MediaSeekedInt) { - auto expectedValue = jsonEngine.get_value("Metrics.mediaSeeked"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaSeeked("mediaEntity123", 500, Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "MetricsImpl::mediaSeeked() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, MediaRateChanged) { - auto expectedValue = jsonEngine.get_value("Metrics.mediaRateChanged"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaRateChanged("mediaEntity123", 1.5, Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "MetricsImpl::mediaRateChanged() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, MediaRenditionChanged) { - auto expectedValue = jsonEngine.get_value("Metrics.mediaRenditionChanged"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaRenditionChanged("mediaEntity123", 3000, 1920, 1080, "HDR", Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "MetricsImpl::mediaRenditionChanged() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, MediaRenditionChangedNoProfile) { - auto expectedValue = jsonEngine.get_value("Metrics.mediaRenditionChanged"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaRenditionChanged("mediaEntity123", 3000, 1920, 1080, std::nullopt, Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "MetricsImpl::mediaRenditionChanged() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, MediaRenditionChangedNoAgePolicy) { - auto expectedValue = jsonEngine.get_value("Metrics.mediaRenditionChanged"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaRenditionChanged("mediaEntity123", 3000, 1920, 1080, std::nullopt, std::nullopt); ASSERT_TRUE(result) << "MetricsImpl::mediaRenditionChanged() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, MediaEnded) { - auto expectedValue = jsonEngine.get_value("Metrics.mediaEnded"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().mediaEnded("mediaEntity123", Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "MetricsImpl::mediaEnded() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, Event) { - auto expectedValue = jsonEngine.get_value("Metrics.event"); auto result = Firebolt::IFireboltAccessor::Instance().MetricsInterface().event("https://com.example.event", "{\"key\":\"value\"}", Firebolt::AgePolicy::ADULT); ASSERT_TRUE(result) << "MetricsImpl::event() returned an error"; - EXPECT_EQ(*result, expectedValue); } TEST_F(MetricsCTest, AppInfo) diff --git a/test/unit/discoveryTest.cpp b/test/unit/discoveryTest.cpp index 4e1c3ce..9b7b1b1 100644 --- a/test/unit/discoveryTest.cpp +++ b/test/unit/discoveryTest.cpp @@ -36,7 +36,7 @@ TEST_F(DiscoveryUTest, checkEnums) TEST_F(DiscoveryUTest, watched) { - mock("Discovery.watched"); + mockInvoke("Discovery.watched"); std::string entityId = "content123"; std::optional progress = 0.75f; std::optional completed = true; @@ -44,9 +44,6 @@ 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) @@ -57,14 +54,13 @@ TEST_F(DiscoveryUTest, watched_payload) expected["completed"] = true; expected["watchedOn"] = "2024-06-01T12:00:00Z"; expected["agePolicy"] = "app:adult"; - EXPECT_CALL(mockHelper, getJson("Discovery.watched", _)) + EXPECT_CALL(mockHelper, invoke("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{res}; + return Firebolt::Result{Firebolt::Error::None}; })); std::string entityId = "content123"; std::optional progress = 0.75f; @@ -73,5 +69,4 @@ 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); } diff --git a/test/unit/metricsTest.cpp b/test/unit/metricsTest.cpp index 321c6d1..a7dbcab 100644 --- a/test/unit/metricsTest.cpp +++ b/test/unit/metricsTest.cpp @@ -33,49 +33,49 @@ TEST_F(MetricsUTest, checkEnums) TEST_F(MetricsUTest, Ready) { - mock("Metrics.ready"); + mockInvoke("Metrics.ready"); auto result = metricsImpl_.ready(); EXPECT_TRUE(result); } TEST_F(MetricsUTest, SignIn) { - mock("Metrics.signIn"); + mockInvoke("Metrics.signIn"); auto result = metricsImpl_.signIn(); EXPECT_TRUE(result); } TEST_F(MetricsUTest, SignOut) { - mock("Metrics.signOut"); + mockInvoke("Metrics.signOut"); auto result = metricsImpl_.signOut(); EXPECT_TRUE(result); } TEST_F(MetricsUTest, StartContent) { - mock("Metrics.startContent"); + mockInvoke("Metrics.startContent"); auto result = metricsImpl_.startContent("entity123", Firebolt::AgePolicy::ADULT); EXPECT_TRUE(result); } TEST_F(MetricsUTest, StopContent) { - mock("Metrics.stopContent"); + mockInvoke("Metrics.stopContent"); auto result = metricsImpl_.stopContent("entity123", Firebolt::AgePolicy::ADULT); EXPECT_TRUE(result); } TEST_F(MetricsUTest, Page) { - mock("Metrics.page"); + mockInvoke("Metrics.page"); auto result = metricsImpl_.page("homePage", Firebolt::AgePolicy::ADULT); EXPECT_TRUE(result); } TEST_F(MetricsUTest, Error) { - mock("Metrics.error"); + mockInvoke("Metrics.error"); auto result = metricsImpl_.error(Firebolt::Metrics::ErrorType::Network, "ERR001", "Network error occurred", true, std::map{{"param1", "value1"}, {"param2", "value2"}}, Firebolt::AgePolicy::ADULT); @@ -84,7 +84,7 @@ TEST_F(MetricsUTest, Error) TEST_F(MetricsUTest, ErrorNoParameters) { - mock("Metrics.error"); + mockInvoke("Metrics.error"); auto result = metricsImpl_.error(Firebolt::Metrics::ErrorType::Network, "ERR001", "Network error occurred", true, std::nullopt, Firebolt::AgePolicy::ADULT); EXPECT_TRUE(result); @@ -92,7 +92,7 @@ TEST_F(MetricsUTest, ErrorNoParameters) TEST_F(MetricsUTest, ErrorNoAgePolicy) { - mock("Metrics.error"); + mockInvoke("Metrics.error"); auto result = metricsImpl_.error(Firebolt::Metrics::ErrorType::Network, "ERR001", "Network error occurred", true, std::map{{"param1", "value1"}, {"param2", "value2"}}, std::nullopt); @@ -101,63 +101,63 @@ TEST_F(MetricsUTest, ErrorNoAgePolicy) TEST_F(MetricsUTest, MediaLoadStart) { - mock("Metrics.mediaLoadStart"); + mockInvoke("Metrics.mediaLoadStart"); auto result = metricsImpl_.mediaLoadStart("mediaEntity123", Firebolt::AgePolicy::ADULT); EXPECT_TRUE(result); } TEST_F(MetricsUTest, MediaPlay) { - mock("Metrics.mediaPlay"); + mockInvoke("Metrics.mediaPlay"); auto result = metricsImpl_.mediaPlay("mediaEntity123", Firebolt::AgePolicy::ADULT); EXPECT_TRUE(result); } TEST_F(MetricsUTest, MediaPlaying) { - mock("Metrics.mediaPlaying"); + mockInvoke("Metrics.mediaPlaying"); auto result = metricsImpl_.mediaPlaying("mediaEntity123", Firebolt::AgePolicy::ADULT); EXPECT_TRUE(result); } TEST_F(MetricsUTest, MediaPause) { - mock("Metrics.mediaPause"); + mockInvoke("Metrics.mediaPause"); auto result = metricsImpl_.mediaPause("mediaEntity123", Firebolt::AgePolicy::ADULT); EXPECT_TRUE(result); } TEST_F(MetricsUTest, MediaWaiting) { - mock("Metrics.mediaWaiting"); + mockInvoke("Metrics.mediaWaiting"); auto result = metricsImpl_.mediaWaiting("mediaEntity123", Firebolt::AgePolicy::ADULT); EXPECT_TRUE(result); } TEST_F(MetricsUTest, MediaSeeking) { - mock("Metrics.mediaSeeking"); + mockInvoke("Metrics.mediaSeeking"); auto result = metricsImpl_.mediaSeeking("mediaEntity123", 0.5, Firebolt::AgePolicy::ADULT); EXPECT_TRUE(result); } TEST_F(MetricsUTest, MediaSeeked) { - mock("Metrics.mediaSeeked"); + mockInvoke("Metrics.mediaSeeked"); auto result = metricsImpl_.mediaSeeked("mediaEntity123", 0.5, Firebolt::AgePolicy::ADULT); EXPECT_TRUE(result); } TEST_F(MetricsUTest, MediaRateChanged) { - mock("Metrics.mediaRateChanged"); + mockInvoke("Metrics.mediaRateChanged"); auto result = metricsImpl_.mediaRateChanged("mediaEntity123", 1.5, Firebolt::AgePolicy::ADULT); EXPECT_TRUE(result); } TEST_F(MetricsUTest, MediaRenditionChanged) { - mock("Metrics.mediaRenditionChanged"); + mockInvoke("Metrics.mediaRenditionChanged"); auto result = metricsImpl_.mediaRenditionChanged("mediaEntity123", 3000, 1920, 1080, "HDR", Firebolt::AgePolicy::ADULT); EXPECT_TRUE(result); @@ -165,14 +165,14 @@ TEST_F(MetricsUTest, MediaRenditionChanged) TEST_F(MetricsUTest, MediaEnded) { - mock("Metrics.mediaEnded"); + mockInvoke("Metrics.mediaEnded"); auto result = metricsImpl_.mediaEnded("mediaEntity123", Firebolt::AgePolicy::ADULT); EXPECT_TRUE(result); } TEST_F(MetricsUTest, Event) { - mock("Metrics.event"); + mockInvoke("Metrics.event"); auto result = metricsImpl_.event("https://com.example.schema", "{\"key\":\"value\"}", Firebolt::AgePolicy::ADULT); EXPECT_TRUE(result); } diff --git a/test/unit/mock_helper.h b/test/unit/mock_helper.h index 9f9183e..f2a9ffb 100644 --- a/test/unit/mock_helper.h +++ b/test/unit/mock_helper.h @@ -104,6 +104,13 @@ class MockBase { return Firebolt::Result{response}; })); } + void mockInvoke(const std::string& methodName) + { + EXPECT_CALL(mockHelper, invoke(methodName, _)) + .WillOnce(Invoke([](const std::string& /*methodName*/, const nlohmann::json& /*parameters*/) + { return Firebolt::Result{Firebolt::Error::None}; })); + } + void mockSubscribe(const std::string& eventName) { EXPECT_CALL(mockHelper, subscribe(_, eventName, _, _))