Skip to content
Open
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
12 changes: 6 additions & 6 deletions docs/openrpc/the-spec/firebolt-open-rpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
"type": "object",
"required": ["intent", "intentId"],
"properties": {
"intent": { "type": "string" },
"intentId": { "type": "integer" }
"intent": { "type": "object" },
"intentId": { "type": "integer", "minimum": 0 }
}
Comment on lines 73 to 76
}
},
Expand All @@ -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 }
}
}
]
Expand Down Expand Up @@ -117,8 +117,8 @@
"type": "object",
"required": ["intent", "intentId"],
"properties": {
"intent": { "type": "string" },
"intentId": { "type": "integer" }
"intent": { "type": "object" },
"intentId": { "type": "integer", "minimum": 0 }
}
Comment on lines 119 to 122
}
},
Expand All @@ -133,7 +133,7 @@
],
"result": {
"name": "Default Result",
"value": { "intent": "launch", "intentId": 1 }
"value": { "intent": {"action": "pre-load", "context": {"source": "system"}}, "intentId": 0 }
}
}
]
Expand Down
5 changes: 3 additions & 2 deletions src/json_types/actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>
{
public:
Expand Down
14 changes: 9 additions & 5 deletions test/component/actionsGeneratedTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>(), "launch");
EXPECT_EQ(parsed.at("intentId").get<int>(), 1);
EXPECT_TRUE(parsed.at("intent").is_object());
EXPECT_EQ(parsed.at("intent").at("action").get<std::string>(), "pre-load");
EXPECT_EQ(parsed.at("intent").at("context").at("source").get<std::string>(), "system");
EXPECT_EQ(parsed.at("intentId").get<unsigned>(), 0u);
}

TEST_F(ActionsGeneratedCTest, SubscribeOnIntent)
Expand All @@ -47,8 +49,10 @@ TEST_F(ActionsGeneratedCTest, SubscribeOnIntent)
[&](const std::string& intent)
{
auto parsed = nlohmann::json::parse(intent);
EXPECT_EQ(parsed.at("intent").get<std::string>(), "launch");
EXPECT_EQ(parsed.at("intentId").get<int>(), 1);
EXPECT_TRUE(parsed.at("intent").is_object());
EXPECT_EQ(parsed.at("intent").at("action").get<std::string>(), "pre-load");
EXPECT_EQ(parsed.at("intent").at("context").at("source").get<std::string>(), "system");
EXPECT_EQ(parsed.at("intentId").get<unsigned>(), 0u);
{
std::lock_guard<std::mutex> lock(mtx);
eventReceived = true;
Expand All @@ -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());
Expand Down
8 changes: 5 additions & 3 deletions test/unit/actionsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>(), "launch");
EXPECT_EQ(parsed.at("intentId").get<int>(), 1);
EXPECT_TRUE(parsed.at("intent").is_object());
EXPECT_EQ(parsed.at("intent").at("action").get<std::string>(), "pre-load");
EXPECT_EQ(parsed.at("intent").at("context").at("source").get<std::string>(), "system");
EXPECT_EQ(parsed.at("intentId").get<unsigned>(), 0u);
}

TEST_F(ActionsUTest, SubscribeOnIntent)
Expand Down
Loading