diff options
author | agaliuzov <agaliuzov@luxoft.com> | 2016-05-15 05:43:18 -0700 |
---|---|---|
committer | agaliuzov <agaliuzov@luxoft.com> | 2016-05-15 07:32:01 -0700 |
commit | d2aa2f5ba839ab016708d298292428063d6fd5ea (patch) | |
tree | 9679e68946690e289eb25a7b58e76c40077d610d /src/components/formatters | |
parent | 8b853ebe626d5500b8e832f5f48cf26f0919de88 (diff) | |
parent | be8feae0e11c59e20f8c9b08c32f7f64937e0ee4 (diff) | |
download | sdl_core-d2aa2f5ba839ab016708d298292428063d6fd5ea.tar.gz |
Merge branch 'master' into develop
Diffstat (limited to 'src/components/formatters')
3 files changed, 19 insertions, 13 deletions
diff --git a/src/components/formatters/include/formatters/CSmartFactory.h b/src/components/formatters/include/formatters/CSmartFactory.h index 7cefabaa74..55f9a30385 100644 --- a/src/components/formatters/include/formatters/CSmartFactory.h +++ b/src/components/formatters/include/formatters/CSmartFactory.h @@ -149,9 +149,13 @@ namespace NsSmartDeviceLink * * @param object SmartObject to attach schema for. * + * @param RemoveFakeParameters contains true if need + * to remove fake parameters from smart object otherwise contains false. + * * @return True if operation was successful or false otherwise. */ - bool attachSchema(NsSmartDeviceLink::NsSmartObjects::SmartObject& object); + bool attachSchema(NsSmartDeviceLink::NsSmartObjects::SmartObject& object, + const bool RemoveFakeParameters); /** * @brief Attach schema to the struct SmartObject. @@ -275,7 +279,9 @@ namespace NsSmartDeviceLink } template <class FunctionIdEnum, class MessageTypeEnum, class StructIdEnum> - bool CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::attachSchema(NsSmartDeviceLink::NsSmartObjects::SmartObject &object) + bool CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>:: + attachSchema(NsSmartDeviceLink::NsSmartObjects::SmartObject &object, + const bool RemoveFakeParameters) { if(false == object.keyExists(strings::S_PARAMS)) return false; if(false == object[strings::S_PARAMS].keyExists(strings::S_MESSAGE_TYPE)) return false; @@ -295,7 +301,7 @@ namespace NsSmartDeviceLink } object.setSchema(schemaIterator->second); - schemaIterator->second.applySchema(object); + schemaIterator->second.applySchema(object, RemoveFakeParameters); return true; } @@ -315,7 +321,7 @@ namespace NsSmartDeviceLink } object.setSchema(structs_iterator->second); - structs_iterator->second.applySchema(object); + structs_iterator->second.applySchema(object, false); return true; } @@ -338,7 +344,7 @@ namespace NsSmartDeviceLink NsSmartDeviceLink::NsSmartObjects::SmartObject function_object( NsSmartDeviceLink::NsSmartObjects::SmartType_Map); function_object.setSchema(schema_iterator->second); - schema_iterator->second.applySchema(function_object); + schema_iterator->second.applySchema(function_object, false); return function_object; } diff --git a/src/components/formatters/test/CSmartFactory_test.cc b/src/components/formatters/test/CSmartFactory_test.cc index 635d52414a..745b960533 100644 --- a/src/components/formatters/test/CSmartFactory_test.cc +++ b/src/components/formatters/test/CSmartFactory_test.cc @@ -145,7 +145,7 @@ TEST(CSmartFactoryTest, CreateSmartObj_AttachSchema1_ExpectCreatedObjectCorrespo obj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::Function1; obj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; // Attach schema to object - EXPECT_TRUE(test_factory.attachSchema(obj)); + EXPECT_TRUE(test_factory.attachSchema(obj, false)); EXPECT_TRUE(SmartType::SmartType_Map == obj.getType()); // Adding necessary fileds to correspond schema obj[S_PARAMS][S_CORRELATION_ID] = 444; @@ -166,7 +166,7 @@ TEST(CSmartFactoryTest, CreateSmartObj_AttachSchema1_MissOneField_ExpectCreatedO obj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::Function1; obj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; // Attach schema to object - EXPECT_TRUE(test_factory.attachSchema(obj)); + EXPECT_TRUE(test_factory.attachSchema(obj, false)); EXPECT_TRUE(SmartType::SmartType_Map == obj.getType()); // Adding necessary fileds to correspond schema but 1 field is missing obj[S_PARAMS][S_PROTOCOL_VERSION] = 1; @@ -186,7 +186,7 @@ TEST(CSmartFactoryTest, CreateSmartObj_AttachNotExistedSchema_ExpectSmSchemaNotA obj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::Function1; obj[S_PARAMS][S_MESSAGE_TYPE] = 10; // Attach schema to object - EXPECT_FALSE(test_factory.attachSchema(obj)); + EXPECT_FALSE(test_factory.attachSchema(obj, false)); EXPECT_TRUE(SmartType::SmartType_Map == obj.getType()); } @@ -198,7 +198,7 @@ TEST(CSmartFactoryTest, CreateSmartObj_AttachSchema1_AddInvalidValue_ExpectCreat obj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::Function1; obj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; // Attach schema to object - EXPECT_TRUE(test_factory.attachSchema(obj)); + EXPECT_TRUE(test_factory.attachSchema(obj, false)); EXPECT_TRUE(SmartType::SmartType_Map == obj.getType()); // Adding necessary fileds to correspond schema but 1 field is missing obj[S_PARAMS][S_PROTOCOL_VERSION] = "string"; diff --git a/src/components/formatters/test/formatter_json_rpc_test.cc b/src/components/formatters/test/formatter_json_rpc_test.cc index 9159b4be05..5592676ff1 100644 --- a/src/components/formatters/test/formatter_json_rpc_test.cc +++ b/src/components/formatters/test/formatter_json_rpc_test.cc @@ -97,7 +97,7 @@ TEST(FormatterJsonRPCTest, CorrectRPCv1Request_ToString_Success) { obj[S_MSG_PARAMS] = SmartObject(SmartType::SmartType_Map); // Attach Schema hmi_apis::HMI_API factory; - EXPECT_TRUE(factory.attachSchema(obj)); + EXPECT_TRUE(factory.attachSchema(obj, false)); std::string result; // Convert SmartObject to Json string @@ -117,7 +117,7 @@ TEST(FormatterJsonRPCTest, CorrectRPCv2Request_ToString_Success) { obj[S_MSG_PARAMS] = SmartObject(SmartType::SmartType_Map); // Attach Schema mobile_apis::MOBILE_API factory; - EXPECT_TRUE(factory.attachSchema(obj)); + EXPECT_TRUE(factory.attachSchema(obj, false)); std::string result; // Convert SmartObject to Json string @@ -310,8 +310,8 @@ TEST(FormatterJsonRPCTest, InvalidRPC_ToString_False) { obj[S_MSG_PARAMS] = SmartObject(SmartType::SmartType_Map); // Attach Schema hmi_apis::HMI_API factory; - EXPECT_FALSE(factory.attachSchema(obj)); - // Convert SmartObject to Json string + EXPECT_FALSE(factory.attachSchema(obj, false)); + // Convert SmrtObject to Json string EXPECT_FALSE(FormatterJsonRpc::ToString(obj, result)); // Expect result with default value. No correct conversion was done EXPECT_EQ(std::string("{\n \"jsonrpc\" : \"2.0\"\n}\n"), result); |