From ca094001f3ba2274099bfcb2ef3acc7607210d59 Mon Sep 17 00:00:00 2001 From: parag-pv Date: Mon, 30 Sep 2024 11:03:34 -0400 Subject: [PATCH] Review fix: Removing log prints, adding comments --- languages/cpp/src/shared/include/json_engine.h | 10 +--------- languages/cpp/src/shared/src/Transport/Transport.h | 10 ++++++---- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/languages/cpp/src/shared/include/json_engine.h b/languages/cpp/src/shared/include/json_engine.h index 33433cc5..0bb98734 100644 --- a/languages/cpp/src/shared/include/json_engine.h +++ b/languages/cpp/src/shared/include/json_engine.h @@ -126,7 +126,6 @@ class JsonEngine // template void MockRequest(const WPEFramework::Core::JSONRPC::Message* message) { - std::cout << "Inside JSON engine MockRequest function" << std::endl; std::string methodName = capitalizeFirstChar(message->Designator.Value().c_str()); /* TODO: Add a flag here that will be set to true if the method name is found in the rpc block, u @@ -140,29 +139,23 @@ class JsonEngine // ID Validation // TODO: Check if id gets incremented by 1 for each request - std::cout << "MockRequest actual message.Id.Value(): " << message->Id.Value() << std::endl; EXPECT_THAT(message->Id, AllOf(Ge(1),Le(std::numeric_limits::max()))); // Schema validation const json requestParams = json::parse(message->Parameters.Value()); - std::cout << "Schema validator requestParams JSON: " << requestParams.dump() << std::endl; if(method["params"].empty()) { - std::cout << "Params is empty" << std::endl; + std::cout << "Schema validation for empty parameters" << std::endl; EXPECT_EQ(requestParams, "{}"_json); } else { - std::cout << "Params is NOT empty" << std::endl; json_validator validator; const json openRPCParams = method["params"]; for (auto& item : openRPCParams.items()) { std::string key = item.key(); json currentSchema = item.value(); std::string paramName = currentSchema["name"]; - std::cout << "paramName: " << paramName << std::endl; if (requestParams.contains(paramName)) { - std::cout << "RequestParams contain paramName in rpc" << std::endl; json dereferenced_schema = process_schema(currentSchema, _data); - std::cout << "schema JSON after $ref: " << dereferenced_schema.dump() << std::endl; try{ validator.set_root_schema(dereferenced_schema["schema"]); validator.validate(requestParams[paramName]); @@ -181,7 +174,6 @@ class JsonEngine template Firebolt::Error MockResponse(WPEFramework::Core::JSONRPC::Message &message, RESPONSE &response) { - std::cout << "Inside JSON engine MockResponse function" << std::endl; std::string methodName = capitalizeFirstChar(message.Designator.Value().c_str()); // Loop through the methods to find the one with the given name diff --git a/languages/cpp/src/shared/src/Transport/Transport.h b/languages/cpp/src/shared/src/Transport/Transport.h index d7fcfe37..3fe0cbc9 100644 --- a/languages/cpp/src/shared/src/Transport/Transport.h +++ b/languages/cpp/src/shared/src/Transport/Transport.h @@ -390,6 +390,7 @@ namespace FireboltSDK _adminLock.Unlock(); } +// Send requests to JSON engine's mockRequest method for unit testing instead of channel's submit method #ifdef UNIT_TEST void Submit(const WPEFramework::Core::ProxyType &message) { @@ -417,6 +418,7 @@ namespace FireboltSDK Close(); } +// Always return true for unit testing #ifdef UNIT_TEST bool IsOpen() { @@ -449,7 +451,8 @@ namespace FireboltSDK } _adminLock.Unlock(); } - + +// Always return true for unit testing #ifdef UNIT_TEST bool Open(const uint32_t waitTime) { @@ -609,6 +612,7 @@ namespace FireboltSDK public: +// Always return true for unit testing #ifdef UNIT_TEST inline bool IsOpen() { @@ -637,11 +641,11 @@ namespace FireboltSDK _eventHandler = eventHandler; } +// Invoke method is overriden for unit testing to call MockResponse method from JSON engine #ifdef UNIT_TEST template Firebolt::Error Invoke(const string &method, const PARAMETERS ¶meters, RESPONSE &response) { - std::cout << "Inside Mock Transport Invoke function" << std::endl; Entry slot; uint32_t id = _channel->Sequence(); Firebolt::Error result = Send(method, parameters, id); @@ -657,7 +661,6 @@ namespace FireboltSDK template Firebolt::Error Invoke(const string& method, const PARAMETERS& parameters, RESPONSE& response) { - std::cout << "Inside Transport Invoke function" << std::endl; Entry slot; uint32_t id = _channel->Sequence(); Firebolt::Error result = Send(method, parameters, id); @@ -871,7 +874,6 @@ namespace FireboltSDK int32_t Submit(const WPEFramework::Core::ProxyType &inbound) { - std::cout << "Inside Transport Submit function 2" << std::endl; int32_t result = WPEFramework::Core::ERROR_UNAVAILABLE; WPEFramework::Core::ProxyType job = WPEFramework::Core::ProxyType(WPEFramework::Core::ProxyType::Create(inbound, this)); WPEFramework::Core::IWorkerPool::Instance().Submit(job);