Skip to content

Commit

Permalink
test(core): Update parameters.initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ksentak committed Oct 3, 2024
1 parent 29f49c6 commit 5081566
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions src/sdks/core/src/cpp/sdk/cpptest/unit/parametersTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,23 @@ class ParametersTest : public ::testing::Test

TEST_F(ParametersTest, Initialization)
{
nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Parameters.initialization"));

Firebolt::Parameters::AppInitialization appInitialization = Firebolt::IFireboltAccessor::Instance().ParametersInterface().initialization(&error);

EXPECT_EQ(error, Firebolt::Error::None) << "Failed to retrieve appInitialization from Parameters.initialization() method";
EXPECT_EQ(appInitialization.us_privacy, expectedValues["us_privacy"]);
EXPECT_EQ(appInitialization.lmt, expectedValues["lmt"]);

nlohmann::json_abi_v3_11_3::json navigateTo = nlohmann::json::parse(appInitialization.discovery.value().navigateTo.value());

EXPECT_EQ(navigateTo["action"],
expectedValues["discovery"]["navigateTo"]["action"]);
EXPECT_EQ(navigateTo["context"]["source"],
expectedValues["discovery"]["navigateTo"]["context"]["source"]);
EXPECT_EQ(navigateTo["data"]["entityId"],
expectedValues["discovery"]["navigateTo"]["data"]["entityId"]);
EXPECT_EQ(navigateTo["data"]["entityType"],
expectedValues["discovery"]["navigateTo"]["data"]["entityType"]);
EXPECT_EQ(navigateTo["data"]["programType"],
expectedValues["discovery"]["navigateTo"]["data"]["programType"]);
}
nlohmann::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Parameters.initialization"));

Firebolt::Parameters::AppInitialization appInitialization = Firebolt::IFireboltAccessor::Instance().ParametersInterface().initialization(&error);

EXPECT_EQ(error, Firebolt::Error::None) << "Failed to retrieve appInitialization from Parameters.initialization() method";
EXPECT_EQ(appInitialization.us_privacy, expectedValues["us_privacy"]);
EXPECT_EQ(appInitialization.lmt, expectedValues["lmt"]);

ASSERT_TRUE(appInitialization.discovery.has_value());
ASSERT_TRUE(appInitialization.discovery.value().navigateTo.has_value());

// Deserialize the actual navigateTo value (double-deserialization to handle extra escaping)
std::string actualNavigateToStr = appInitialization.discovery.value().navigateTo.value();
nlohmann::json actualNavigateToJson = nlohmann::json::parse(nlohmann::json::parse(actualNavigateToStr).get<std::string>());

// Convert expectedValues["discovery"]["navigateTo"] to a serialized JSON string
nlohmann::json expectedNavigateTo = expectedValues["discovery"]["navigateTo"];

EXPECT_EQ(actualNavigateToJson, expectedNavigateTo);
}

0 comments on commit 5081566

Please sign in to comment.