From 85983229db8d915cc9241b329c0d9f27ec0f531a Mon Sep 17 00:00:00 2001 From: swethasukumarr Date: Wed, 15 Jul 2026 12:03:04 -0400 Subject: [PATCH] RDKEMW-20911 : Fix intent type as object and not string --- docs/openrpc/the-spec/firebolt-open-rpc.json | 12 ++++++------ src/json_types/actions.h | 5 +++-- test/component/actionsGeneratedTest.cpp | 14 +++++++++----- test/unit/actionsTest.cpp | 8 +++++--- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/docs/openrpc/the-spec/firebolt-open-rpc.json b/docs/openrpc/the-spec/firebolt-open-rpc.json index 2292d55..2d07437 100644 --- a/docs/openrpc/the-spec/firebolt-open-rpc.json +++ b/docs/openrpc/the-spec/firebolt-open-rpc.json @@ -71,8 +71,8 @@ "type": "object", "required": ["intent", "intentId"], "properties": { - "intent": { "type": "string" }, - "intentId": { "type": "integer" } + "intent": { "type": "object" }, + "intentId": { "type": "integer", "minimum": 0 } } } }, @@ -81,7 +81,7 @@ "name": "Get the current intent", "result": { "name": "Default Result", - "value": { "intent": "launch", "intentId": 1 } + "value": { "intent": {"action": "pre-load", "context": {"source": "system"}}, "intentId": 0 } } } ] @@ -117,8 +117,8 @@ "type": "object", "required": ["intent", "intentId"], "properties": { - "intent": { "type": "string" }, - "intentId": { "type": "integer" } + "intent": { "type": "object" }, + "intentId": { "type": "integer", "minimum": 0 } } } }, @@ -133,7 +133,7 @@ ], "result": { "name": "Default Result", - "value": { "intent": "launch", "intentId": 1 } + "value": { "intent": {"action": "pre-load", "context": {"source": "system"}}, "intentId": 0 } } } ] diff --git a/src/json_types/actions.h b/src/json_types/actions.h index 732775c..a27e961 100644 --- a/src/json_types/actions.h +++ b/src/json_types/actions.h @@ -36,8 +36,9 @@ namespace JsonData // Serialises any JSON value (object, string, …) to its compact JSON text // representation. Used for Actions.intent / Actions.onIntent whose wire format -// is the object {"intent":"...","intentId":N} but whose public C++ API surface -// exposes the whole document as a std::string, per the Firebolt 9 spec. +// is the object {"intent":{"action":"...","context":{...}},"intentId":N} but whose +// public C++ API surface exposes the whole document as a std::string, per the +// Firebolt 9 spec. class JsonString : public Firebolt::JSON::NL_Json_Basic { public: diff --git a/test/component/actionsGeneratedTest.cpp b/test/component/actionsGeneratedTest.cpp index a8105c0..c5e38c9 100644 --- a/test/component/actionsGeneratedTest.cpp +++ b/test/component/actionsGeneratedTest.cpp @@ -37,8 +37,10 @@ TEST_F(ActionsGeneratedCTest, Intent) auto result = Firebolt::IFireboltAccessor::Instance().ActionsInterface().intent(); ASSERT_TRUE(result) << toError(result); auto parsed = nlohmann::json::parse(*result); - EXPECT_EQ(parsed.at("intent").get(), "launch"); - EXPECT_EQ(parsed.at("intentId").get(), 1); + EXPECT_TRUE(parsed.at("intent").is_object()); + EXPECT_EQ(parsed.at("intent").at("action").get(), "pre-load"); + EXPECT_EQ(parsed.at("intent").at("context").at("source").get(), "system"); + EXPECT_EQ(parsed.at("intentId").get(), 0u); } TEST_F(ActionsGeneratedCTest, SubscribeOnIntent) @@ -47,8 +49,10 @@ TEST_F(ActionsGeneratedCTest, SubscribeOnIntent) [&](const std::string& intent) { auto parsed = nlohmann::json::parse(intent); - EXPECT_EQ(parsed.at("intent").get(), "launch"); - EXPECT_EQ(parsed.at("intentId").get(), 1); + EXPECT_TRUE(parsed.at("intent").is_object()); + EXPECT_EQ(parsed.at("intent").at("action").get(), "pre-load"); + EXPECT_EQ(parsed.at("intent").at("context").at("source").get(), "system"); + EXPECT_EQ(parsed.at("intentId").get(), 0u); { std::lock_guard lock(mtx); eventReceived = true; @@ -59,7 +63,7 @@ TEST_F(ActionsGeneratedCTest, SubscribeOnIntent) ASSERT_TRUE(id) << toError(id); verifyEventSubscription(id); - triggerEvent("Actions.onIntent", R"({"intent":"launch","intentId":1})"); + triggerEvent("Actions.onIntent", R"({"intent":{"action":"pre-load","context":{"source":"system"}},"intentId":0})"); verifyEventReceived(mtx, cv, eventReceived); auto result = Firebolt::IFireboltAccessor::Instance().ActionsInterface().unsubscribe(id.value()); diff --git a/test/unit/actionsTest.cpp b/test/unit/actionsTest.cpp index feec5ed..773cc69 100644 --- a/test/unit/actionsTest.cpp +++ b/test/unit/actionsTest.cpp @@ -28,13 +28,15 @@ class ActionsUTest : public ::testing::Test, protected MockBase TEST_F(ActionsUTest, Start) { - mock_with_response("Actions.intent", nlohmann::json({{"intent", "launch"}, {"intentId", 1}})); + mock_with_response("Actions.intent", nlohmann::json({{"intent", {{"action", "pre-load"}, {"context", {{"source", "system"}}}}}, {"intentId", 0u}})); auto result = actionsImpl_.intent(); ASSERT_TRUE(result) << "ActionsImpl::intent() returned an error"; auto parsed = nlohmann::json::parse(*result); - EXPECT_EQ(parsed.at("intent").get(), "launch"); - EXPECT_EQ(parsed.at("intentId").get(), 1); + EXPECT_TRUE(parsed.at("intent").is_object()); + EXPECT_EQ(parsed.at("intent").at("action").get(), "pre-load"); + EXPECT_EQ(parsed.at("intent").at("context").at("source").get(), "system"); + EXPECT_EQ(parsed.at("intentId").get(), 0u); } TEST_F(ActionsUTest, SubscribeOnIntent)