summaryrefslogtreecommitdiff
path: root/src/components/formatters
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/formatters')
-rw-r--r--src/components/formatters/CMakeLists.txt9
-rw-r--r--src/components/formatters/include/formatters/CFormatterJsonBase.h119
-rw-r--r--src/components/formatters/include/formatters/CFormatterJsonBase.hpp122
-rw-r--r--src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h (renamed from src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.hpp)56
-rw-r--r--src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h (renamed from src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.hpp)69
-rw-r--r--src/components/formatters/include/formatters/CSmartFactory.h410
-rw-r--r--src/components/formatters/include/formatters/CSmartFactory.hpp428
-rw-r--r--src/components/formatters/include/formatters/formatter_json_rpc.h736
-rw-r--r--src/components/formatters/include/formatters/generic_json_formatter.h14
-rw-r--r--src/components/formatters/include/formatters/meta_formatter.h18
-rw-r--r--src/components/formatters/src/CFormatterJsonBase.cc (renamed from src/components/formatters/src/CFormatterJsonBase.cpp)51
-rw-r--r--src/components/formatters/src/CFormatterJsonSDLRPCv1.cc (renamed from src/components/formatters/src/CFormatterJsonSDLRPCv1.cpp)104
-rw-r--r--src/components/formatters/src/CFormatterJsonSDLRPCv2.cc (renamed from src/components/formatters/src/CFormatterJsonSDLRPCv2.cpp)32
-rw-r--r--src/components/formatters/src/CSmartFactory.cc (renamed from src/components/formatters/src/CSmartFactory.cpp)20
-rw-r--r--src/components/formatters/src/formatter_json_rpc.cc87
-rw-r--r--src/components/formatters/src/generic_json_formatter.cc6
-rw-r--r--src/components/formatters/src/meta_formatter.cc5
-rw-r--r--src/components/formatters/test/CFormatterJsonBase_test.cc62
-rw-r--r--src/components/formatters/test/CMakeLists.txt2
-rw-r--r--src/components/formatters/test/CSmartFactory_test.cc112
-rw-r--r--src/components/formatters/test/cFormatterJsonSDLRPCv1_test.cc34
-rw-r--r--src/components/formatters/test/cFormatterJsonSDLRPCv2_test.cc48
-rw-r--r--src/components/formatters/test/formatter_json_rpc_test.cc333
-rw-r--r--src/components/formatters/test/generic_json_formatter_test.cc74
-rw-r--r--src/components/formatters/test/include/formatters/SmartFactoryTestHelper.h (renamed from src/components/formatters/test/include/SmartFactoryTestHelper.h)67
-rw-r--r--src/components/formatters/test/include/formatters/create_smartSchema.h (renamed from src/components/formatters/test/include/create_smartSchema.h)20
-rw-r--r--src/components/formatters/test/include/formatters/meta_formatter_test_helper.h (renamed from src/components/formatters/test/include/meta_formatter_test_helper.h)7
-rw-r--r--src/components/formatters/test/meta_formatter_test.cc207
-rw-r--r--src/components/formatters/test/src/SmartFactoryTestHelper.cc455
-rw-r--r--src/components/formatters/test/src/create_smartSchema.cc359
-rw-r--r--src/components/formatters/test/src/meta_formatter_test_helper.cc57
31 files changed, 2243 insertions, 1880 deletions
diff --git a/src/components/formatters/CMakeLists.txt b/src/components/formatters/CMakeLists.txt
index 3dd7dc9366..1858342ff3 100644
--- a/src/components/formatters/CMakeLists.txt
+++ b/src/components/formatters/CMakeLists.txt
@@ -38,16 +38,17 @@ include_directories (
${JSONCPP_INCLUDE_DIRECTORY}
${MESSAGE_BROKER_INCLUDE_DIRECTORY}
${COMPONENTS_DIR}/smart_objects/include
+ ${COMPONENTS_DIR}/utils/include
)
set (SOURCES
- ${FORMATTERS_SRC_DIR}/CSmartFactory.cpp
+ ${FORMATTERS_SRC_DIR}/CSmartFactory.cc
)
set (FORMATTER_SOURCES
- ${FORMATTERS_SRC_DIR}/CFormatterJsonBase.cpp
- ${FORMATTERS_SRC_DIR}/CFormatterJsonSDLRPCv1.cpp
- ${FORMATTERS_SRC_DIR}/CFormatterJsonSDLRPCv2.cpp
+ ${FORMATTERS_SRC_DIR}/CFormatterJsonBase.cc
+ ${FORMATTERS_SRC_DIR}/CFormatterJsonSDLRPCv1.cc
+ ${FORMATTERS_SRC_DIR}/CFormatterJsonSDLRPCv2.cc
${FORMATTERS_SRC_DIR}/formatter_json_rpc.cc
${FORMATTERS_SRC_DIR}/meta_formatter.cc
${FORMATTERS_SRC_DIR}/generic_json_formatter.cc
diff --git a/src/components/formatters/include/formatters/CFormatterJsonBase.h b/src/components/formatters/include/formatters/CFormatterJsonBase.h
new file mode 100644
index 0000000000..be4ee3e2cc
--- /dev/null
+++ b/src/components/formatters/include/formatters/CFormatterJsonBase.h
@@ -0,0 +1,119 @@
+/**
+ * @file CFormatterJsonBase.hpp
+ * @brief CFormatterJsonBase header file.
+ */
+// Copyright (c) 2013, Ford Motor Company
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided with the
+// distribution.
+//
+// Neither the name of the Ford Motor Company nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef __CFORMATTERJSONBASE_HPP__
+#define __CFORMATTERJSONBASE_HPP__
+
+#include "smart_objects/smart_object.h"
+#include "json/json.h"
+
+namespace NsSmartDeviceLink {
+namespace NsJSONHandler {
+namespace Formatters {
+
+namespace meta_formatter_error_code {
+/**
+ * @brief Error codes of MetaFormatter represented as bitmask
+ **/
+typedef long tMetaFormatterErrorCode;
+
+/**
+ * @brief OK, no error
+ */
+static const tMetaFormatterErrorCode kErrorOk = 0x0;
+
+/**
+ * @brief origin smart object is not function
+ */
+static const tMetaFormatterErrorCode kErrorObjectIsNotFunction = 0x01;
+
+/**
+ * @brief smart shema describes object which is not function
+ */
+static const tMetaFormatterErrorCode kErrorSchemaIsNotFunction = 0x02;
+
+/**
+ * @brief result smart object has invalid type (SmartType_Invalid)
+ * before passing to MetaFormatter, i.e. result object can not
+ * be changed, i.e. result object can not be built
+ *
+ */
+static const tMetaFormatterErrorCode kErrorFailedCreateObjectBySchema = 0x04;
+}
+
+/**
+ * @brief The base class for all JSON based formatters.
+ */
+class CFormatterJsonBase {
+ private:
+ /**
+ * @brief Constructor.
+ */
+ CFormatterJsonBase();
+
+ /**
+ * @brief Copy constructor.
+ *
+ * @param obj Object to copy.
+ */
+ CFormatterJsonBase(const CFormatterJsonBase& obj);
+
+ protected:
+ public:
+ /**
+ * @brief The method constructs a SmartObject from the input JSON object
+ *
+ * @param value Input JSON object.
+ * @param obj The resulting SmartObject.
+ */
+ static void jsonValueToObj(
+ const Json::Value& value,
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& obj);
+
+ /**
+ * @brief The method constructs a JSON object from the input SmartObject
+ *
+ * @param obj Input SmartObject. Can contain a complex structure of objects.
+ * @param value The resulting JSON object. It has the same structure as the
+ *input SmartObject.
+ */
+ static void objToJsonValue(
+ const NsSmartDeviceLink::NsSmartObjects::SmartObject& obj,
+ Json::Value& value);
+};
+}
+}
+} // namespace NsSmartDeviceLink::NsJSONHandler::Formatters
+
+#endif // __CFORMATTERJSONBASE_HPP__
diff --git a/src/components/formatters/include/formatters/CFormatterJsonBase.hpp b/src/components/formatters/include/formatters/CFormatterJsonBase.hpp
deleted file mode 100644
index ef57d9b1b9..0000000000
--- a/src/components/formatters/include/formatters/CFormatterJsonBase.hpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * @file CFormatterJsonBase.hpp
- * @brief CFormatterJsonBase header file.
- */
-// Copyright (c) 2013, Ford Motor Company
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// Redistributions of source code must retain the above copyright notice, this
-// list of conditions and the following disclaimer.
-//
-// Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided with the
-// distribution.
-//
-// Neither the name of the Ford Motor Company nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef __CFORMATTERJSONBASE_HPP__
-#define __CFORMATTERJSONBASE_HPP__
-
-#include "smart_objects/smart_object.h"
-#include "json/json.h"
-
-namespace NsSmartDeviceLink {
-namespace NsJSONHandler {
-namespace Formatters {
-
-namespace meta_formatter_error_code {
- /**
- * @brief Error codes of MetaFormatter represented as bitmask
- **/
- typedef long tMetaFormatterErrorCode ;
-
- /**
- * @brief OK, no error
- */
- static const tMetaFormatterErrorCode kErrorOk = 0x0;
-
- /**
- * @brief origin smart object is not function
- */
- static const tMetaFormatterErrorCode kErrorObjectIsNotFunction = 0x01;
-
- /**
- * @brief smart shema describes object which is not function
- */
- static const tMetaFormatterErrorCode kErrorSchemaIsNotFunction = 0x02;
-
- /**
- * @brief result smart object has invalid type (SmartType_Invalid)
- * before passing to MetaFormatter, i.e. result object can not
- * be changed, i.e. result object can not be built
- *
- */
- static const tMetaFormatterErrorCode kErrorFailedCreateObjectBySchema = 0x04;
-}
-
- /**
- * @brief The base class for all JSON based formatters.
- */
- class CFormatterJsonBase
- {
- private:
-
- /**
- * @brief Constructor.
- */
- CFormatterJsonBase();
-
- /**
- * @brief Copy constructor.
- *
- * @param obj Object to copy.
- */
- CFormatterJsonBase(const CFormatterJsonBase &obj);
-
- protected:
-
-
- public:
-
- /**
- * @brief The method constructs a SmartObject from the input JSON object
- *
- * @param value Input JSON object.
- * @param obj The resulting SmartObject.
- */
- static void jsonValueToObj(const Json::Value &value,
- NsSmartDeviceLink::NsSmartObjects::SmartObject &obj);
-
- /**
- * @brief The method constructs a JSON object from the input SmartObject
- *
- * @param obj Input SmartObject. Can contain a complex structure of objects.
- * @param value The resulting JSON object. It has the same structure as the input SmartObject.
- */
- static void objToJsonValue(const NsSmartDeviceLink::NsSmartObjects::SmartObject &obj,
- Json::Value &value);
- };
-
-}
-}
-} // namespace NsSmartDeviceLink::NsJSONHandler::Formatters
-
-#endif // __CFORMATTERJSONBASE_HPP__
diff --git a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.hpp b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h
index 03454395b0..e78a115f6c 100644
--- a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.hpp
+++ b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h
@@ -35,9 +35,9 @@
#include "smart_objects/smart_object.h"
#include "smart_objects/enum_schema_item.h"
-#include "CFormatterJsonBase.hpp"
+#include "CFormatterJsonBase.h"
-#include "formatters/CSmartFactory.hpp"
+#include "formatters/CSmartFactory.h"
#include "formatters/meta_formatter.h"
namespace NsSmartDeviceLink {
@@ -111,14 +111,15 @@ class CFormatterJsonSDLRPCv1 : public CFormatterJsonBase {
static const std::string S_CORRELATION_ID;
public:
-
static const int32_t kSuccess;
static const int32_t kParsingError;
static const int32_t kFunctionIdNotFound;
static const int32_t kMessageTypeNotFound;
static const int32_t kCorrelationIdNotFound;
- typedef NsSmartDeviceLink::NsJSONHandler::Formatters::meta_formatter_error_code::tMetaFormatterErrorCode tMetaFormatterErrorCode;
+ typedef NsSmartDeviceLink::NsJSONHandler::Formatters::
+ meta_formatter_error_code::tMetaFormatterErrorCode
+ tMetaFormatterErrorCode;
/**
* @brief Creates a JSON string from a SmartObject.
@@ -128,7 +129,7 @@ class CFormatterJsonSDLRPCv1 : public CFormatterJsonBase {
* @return true if success, false otherwise
*/
static bool toString(
- const NsSmartDeviceLink::NsSmartObjects::SmartObject &obj,
+ const NsSmartDeviceLink::NsSmartObjects::SmartObject& obj,
std::string& outStr);
/**
@@ -138,15 +139,17 @@ class CFormatterJsonSDLRPCv1 : public CFormatterJsonBase {
* @param out The resulting SmartObject
* @return true if success, otherwise - false
*/
- template<typename FunctionId, typename MessageType>
- static int32_t fromString(const std::string &str,
- NsSmartDeviceLink::NsSmartObjects::SmartObject &out);
+ template <typename FunctionId, typename MessageType>
+ static int32_t fromString(
+ const std::string& str,
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& out);
/**
* @brief Converts to string the smart object against the given schema
*
* @param object Original smart object
- * @param schema Smart schema which describes 'fake' smart object to be formatted
+ * @param schema Smart schema which describes 'fake' smart object to be
+ *formatted
* @param outStr Resulting JSON string
* @return formatting error code
*/
@@ -154,12 +157,11 @@ class CFormatterJsonSDLRPCv1 : public CFormatterJsonBase {
const NsSmartDeviceLink::NsSmartObjects::SmartObject& object,
const NsSmartDeviceLink::NsSmartObjects::CSmartSchema& schema,
std::string& outStr);
-
};
// ----------------------------------------------------------------------------
-template<typename FunctionId, typename MessageType>
+template <typename FunctionId, typename MessageType>
int32_t Formatters::CFormatterJsonSDLRPCv1::fromString(
const std::string& str,
NsSmartDeviceLink::NsSmartObjects::SmartObject& out) {
@@ -171,15 +173,15 @@ int32_t Formatters::CFormatterJsonSDLRPCv1::fromString(
std::string type;
if (false == reader.parse(str, root)) {
- result = kParsingError | kMessageTypeNotFound | kFunctionIdNotFound
- | kCorrelationIdNotFound;
+ result = kParsingError | kMessageTypeNotFound | kFunctionIdNotFound |
+ kCorrelationIdNotFound;
}
if (kSuccess == result) {
type = getMessageType(root);
if (true == type.empty()) {
- result = kMessageTypeNotFound | kFunctionIdNotFound
- | kCorrelationIdNotFound;
+ result =
+ kMessageTypeNotFound | kFunctionIdNotFound | kCorrelationIdNotFound;
}
}
@@ -187,16 +189,18 @@ int32_t Formatters::CFormatterJsonSDLRPCv1::fromString(
MessageType messageType = MessageType::INVALID_ENUM;
if (kSuccess == result) {
- if (!NsSmartObjects::EnumConversionHelper<MessageType>::StringToEnum(type, &messageType)) {
- // If MessageType is not found than FunctionId and CorrelationId can not be found either
- result = kMessageTypeNotFound | kFunctionIdNotFound
- | kCorrelationIdNotFound;
+ if (!NsSmartObjects::EnumConversionHelper<MessageType>::StringToEnum(
+ type, &messageType)) {
+ // If MessageType is not found than FunctionId and CorrelationId can not
+ // be found either
+ result =
+ kMessageTypeNotFound | kFunctionIdNotFound | kCorrelationIdNotFound;
}
}
if (kSuccess == result) {
- if (!NsSmartObjects::EnumConversionHelper<FunctionId>::StringToEnum(root[type][S_NAME].asString(),
- &functionId)) {
+ if (!NsSmartObjects::EnumConversionHelper<FunctionId>::StringToEnum(
+ root[type][S_NAME].asString(), &functionId)) {
result = kFunctionIdNotFound;
functionId = FunctionId::INVALID_ENUM;
}
@@ -210,13 +214,14 @@ int32_t Formatters::CFormatterJsonSDLRPCv1::fromString(
out[S::S_PARAMS][S::S_MESSAGE_TYPE] = messageType;
out[S::S_PARAMS][S::S_FUNCTION_ID] = functionId;
if (true == root[type][S_CORRELATION_ID].empty()) {
- if (type != S_NOTIFICATION) { // Notification may not have CorrelationId
+ if (type !=
+ S_NOTIFICATION) { // Notification may not have CorrelationId
result |= kCorrelationIdNotFound;
out[S::S_PARAMS][S::S_CORRELATION_ID] = -1;
}
} else {
- out[S::S_PARAMS][S::S_CORRELATION_ID] = root[type][S_CORRELATION_ID]
- .asInt();
+ out[S::S_PARAMS][S::S_CORRELATION_ID] =
+ root[type][S_CORRELATION_ID].asInt();
}
out[S::S_PARAMS][S::S_PROTOCOL_TYPE] = 0;
out[S::S_PARAMS][S::S_PROTOCOL_VERSION] = 1;
@@ -227,9 +232,8 @@ int32_t Formatters::CFormatterJsonSDLRPCv1::fromString(
return result;
}
-
}
}
} // namespace NsSmartDeviceLink::NsJSONHandler::Formatters
-#endif // __SMARTDEVICELINKCORE_JSONHANDLER_FORMATTERS__CFORMATTERJSONSDLRPCV1_HPP__
+#endif // __SMARTDEVICELINKCORE_JSONHANDLER_FORMATTERS__CFORMATTERJSONSDLRPCV1_HPP__
diff --git a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.hpp b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h
index 3b4e206515..a260ecd080 100644
--- a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.hpp
+++ b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h
@@ -35,8 +35,8 @@
#include "smart_objects/smart_object.h"
-#include "CFormatterJsonBase.hpp"
-#include "formatters/CSmartFactory.hpp"
+#include "CFormatterJsonBase.h"
+#include "formatters/CSmartFactory.h"
namespace NsSmartDeviceLink {
namespace NsJSONHandler {
@@ -49,7 +49,6 @@ namespace Formatters {
*/
class CFormatterJsonSDLRPCv2 : public CFormatterJsonBase {
private:
-
/**
* @brief Hidden constructor.
*
@@ -65,8 +64,9 @@ class CFormatterJsonSDLRPCv2 : public CFormatterJsonBase {
CFormatterJsonSDLRPCv2(const CFormatterJsonSDLRPCv2&);
public:
-
- typedef NsSmartDeviceLink::NsJSONHandler::Formatters::meta_formatter_error_code::tMetaFormatterErrorCode tMetaFormatterErrorCode;
+ typedef NsSmartDeviceLink::NsJSONHandler::Formatters::
+ meta_formatter_error_code::tMetaFormatterErrorCode
+ tMetaFormatterErrorCode;
/**
* @brief Creates a JSON string from a SmartObject.
@@ -76,7 +76,7 @@ class CFormatterJsonSDLRPCv2 : public CFormatterJsonBase {
* @return true if success, false otherwise
*/
static bool toString(
- const NsSmartDeviceLink::NsSmartObjects::SmartObject &obj,
+ const NsSmartDeviceLink::NsSmartObjects::SmartObject& obj,
std::string& outStr);
/**
@@ -84,14 +84,17 @@ class CFormatterJsonSDLRPCv2 : public CFormatterJsonBase {
*
* @param str Input JSON string in SDLRPCv2 format
* @param out Output SmartObject
- * @param functionId The corresponding field in SmartObject is filled with this param.
- * @param messageType The corresponding field in SmartObject is filled with this param.
+ * @param functionId The corresponding field in SmartObject is filled with
+ *this param.
+ * @param messageType The corresponding field in SmartObject is filled with
+ *this param.
* @return true if success, otherwise - false
*/
- template<typename FunctionId, typename MessageType>
- static bool fromString(const std::string &str,
- NsSmartDeviceLink::NsSmartObjects::SmartObject &out,
- FunctionId functionId, MessageType messageType);
+ template <typename FunctionId, typename MessageType>
+ static bool fromString(const std::string& str,
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& out,
+ FunctionId functionId,
+ MessageType messageType);
/**
* @brief Creates a SmartObject from a JSON string.
@@ -100,23 +103,28 @@ class CFormatterJsonSDLRPCv2 : public CFormatterJsonBase {
*
* @param str Input JSON string in SDLRPCv2 format
* @param out Output SmartObject
- * @param functionId The corresponding field in SmartObject is filled with this param.
- * @param messageType The corresponding field in SmartObject is filled with this param.
- * @param correlatioId It's like sequence number. The corresponding field in SmartObject
+ * @param functionId The corresponding field in SmartObject is filled with
+ *this param.
+ * @param messageType The corresponding field in SmartObject is filled with
+ *this param.
+ * @param correlatioId It's like sequence number. The corresponding field in
+ *SmartObject
* is filled with this param.
* @return true if success, otherwise - false
*/
- template<typename FunctionId, typename MessageType>
- static bool fromString(const std::string &str,
- NsSmartDeviceLink::NsSmartObjects::SmartObject &out,
- FunctionId functionId, MessageType messageType,
+ template <typename FunctionId, typename MessageType>
+ static bool fromString(const std::string& str,
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& out,
+ FunctionId functionId,
+ MessageType messageType,
int32_t correlationId);
/**
* @brief Converts to string the smart object against the given schema
*
* @param object Original smart object
- * @param schema Smart schema which describes 'fake' smart object to be formatted
+ * @param schema Smart schema which describes 'fake' smart object to be
+ *formatted
* @param outStr Resulting JSON string
* @return formatting error code
*/
@@ -126,10 +134,12 @@ class CFormatterJsonSDLRPCv2 : public CFormatterJsonBase {
std::string& outStr);
};
-template<typename FunctionId, typename MessageType>
+template <typename FunctionId, typename MessageType>
inline bool CFormatterJsonSDLRPCv2::fromString(
- const std::string& str, NsSmartDeviceLink::NsSmartObjects::SmartObject& out,
- FunctionId functionId, MessageType messageType) {
+ const std::string& str,
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& out,
+ FunctionId functionId,
+ MessageType messageType) {
bool result = true;
try {
@@ -154,11 +164,13 @@ inline bool CFormatterJsonSDLRPCv2::fromString(
return result;
}
-template<typename FunctionId, typename MessageType>
+template <typename FunctionId, typename MessageType>
inline bool CFormatterJsonSDLRPCv2::fromString(
- const std::string& str, NsSmartDeviceLink::NsSmartObjects::SmartObject& out,
- FunctionId functionId, MessageType messageType, int32_t correlationId) {
-
+ const std::string& str,
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& out,
+ FunctionId functionId,
+ MessageType messageType,
+ int32_t correlationId) {
bool result = fromString(str, out, functionId, messageType);
namespace strings = NsSmartDeviceLink::NsJSONHandler::strings;
@@ -168,9 +180,8 @@ inline bool CFormatterJsonSDLRPCv2::fromString(
return result;
}
-
}
}
} // namespace NsSmartDeviceLink::NsJSONHandler::Formatters
-#endif // __SMARTDEVICELINKCORE_JSONHANDLER_FORMATTERS__CFORMATTERJSONSDLRPCV2_HPP__
+#endif // __SMARTDEVICELINKCORE_JSONHANDLER_FORMATTERS__CFORMATTERJSONSDLRPCV2_HPP__
diff --git a/src/components/formatters/include/formatters/CSmartFactory.h b/src/components/formatters/include/formatters/CSmartFactory.h
new file mode 100644
index 0000000000..223d22fbbe
--- /dev/null
+++ b/src/components/formatters/include/formatters/CSmartFactory.h
@@ -0,0 +1,410 @@
+/**
+ * @file CSmartFactory.hpp
+ * @brief CSmartFactory header file.
+ */
+// Copyright (c) 2013, Ford Motor Company
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided with the
+// distribution.
+//
+// Neither the name of the Ford Motor Company nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef __CSMARTFACTORY_HPP__
+#define __CSMARTFACTORY_HPP__
+
+#include "smart_objects/smart_object.h"
+#include "smart_objects/smart_schema.h"
+#include <map>
+#include <string>
+
+namespace NsSmartDeviceLink {
+namespace NsJSONHandler {
+/**
+ * @brief String constants used by SmartFactory.
+ */
+namespace strings {
+/**
+ * @brief String constant for MSG_PARAMS.
+ */
+extern const std::string S_MSG_PARAMS;
+
+/**
+ * @brief String constant for PARAMS.
+ */
+extern const std::string S_PARAMS;
+
+/**
+ * @brief String constant for FUNCTION_ID.
+ */
+extern const std::string S_FUNCTION_ID;
+
+/**
+ * @brief String constant for MESSAGE_TYPE.
+ */
+extern const std::string S_MESSAGE_TYPE;
+
+/**
+ * @brief String constant for PROTOCOL_VERSION.
+ */
+extern const std::string S_PROTOCOL_VERSION;
+
+/**
+ * @brief String constant for PROTOCOL_TYPE.
+ */
+extern const std::string S_PROTOCOL_TYPE;
+
+/**
+ * @brief String constant for CORRELATION_ID.
+ */
+extern const std::string S_CORRELATION_ID;
+
+/**
+ * @brief String constant for "code" param name.
+ */
+extern const std::string kCode;
+
+/**
+ * @brief String constant for "message" param name.
+ */
+extern const std::string kMessage;
+}
+
+/**
+ * @brief Smart Schema key.
+ *
+ * @tparam FunctionIdEnum Type of function ID enum.
+ * @tparam MessageTypeEnum Type of messageType enum.
+ */
+template <class FunctionIdEnum, class MessageTypeEnum>
+struct SmartSchemaKey {
+ /**
+ * @brief Value of function ID for the key.
+ */
+ FunctionIdEnum functionId;
+
+ /**
+ * @brief Value of messageType for the key.
+ */
+ MessageTypeEnum messageType;
+
+ /**
+ * @brief Constructor.
+ *
+ * @param functionIdParam Value of function ID.
+ * @param messageTypeParam Value of message type.
+ */
+ SmartSchemaKey(FunctionIdEnum functionIdParam,
+ MessageTypeEnum messageTypeParam);
+};
+
+/**
+ * @brief Smart Factory.
+ *
+ * This class is used as base class for generated factories.
+ * Clients should use methods of this class to access all
+ * SmartSchema validation features.
+ *
+ * @tparam FunctionIdEnum Type of function ID enum.
+ * @tparam MessageTypeEnum Type of messageType enum.
+ * @tparam StructIdEnum Type of StructId enum.
+ */
+template <class FunctionIdEnum, class MessageTypeEnum, class StructIdEnum>
+class CSmartFactory {
+ public:
+ /**
+ * @brief Constructor.
+ */
+ CSmartFactory(void);
+
+ /**
+ * @brief Attach schema to the function SmartObject.
+ *
+ * @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,
+ const bool RemoveFakeParameters);
+
+ /**
+ * @brief Attach schema to the struct SmartObject.
+ *
+ * @param struct_id Identifier of the struct.
+ * @param object SmartObject to attach schema for.
+ *
+ * @return True if operation was successful of false otherwise.
+ */
+ bool AttachSchema(const StructIdEnum struct_id,
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& object);
+
+ /**
+ * @brief Create new SmartObject with attached function SmartSchema.
+ *
+ * @param function_id FunctionID of the function.
+ * @param message_type messageType of the function.
+ *
+ * @return If function succeeded it returns new SmartObject with
+ * map type and attached SmartSchema. Client can use such
+ * object to store specific function and perform validation.
+ * Otherwise (if SmartSchema was not attached to the
+ * SmartObject) function returns empty SmartObject with
+ * null type.
+ */
+ NsSmartDeviceLink::NsSmartObjects::SmartObject CreateSmartObject(
+ const FunctionIdEnum function_id, const MessageTypeEnum message_type);
+
+ /**
+ * @brief Create new SmartObject with attached struct SmartSchema.
+ *
+ * @param struct_id Identifier of the struct.
+ *
+ * @return If function succeeded it returns new SmartObject with
+ * map type and attached SmartSchema. Client can use such
+ * object to store specific struct and perform validation.
+ * Otherwise (if SmartSchema was not attached to the
+ * SmartObject) function returns empty SmartObject with
+ * null type.
+ */
+ NsSmartDeviceLink::NsSmartObjects::SmartObject CreateSmartObject(
+ const StructIdEnum struct_id);
+
+ /**
+ * @brief Get SmartSchema for specific function.
+ *
+ * @param function_id FunctionID of the function.
+ * @param message_type messageType of the function.
+ * @param[out] result This value will be copy of the desired
+ * function SmartSchema if it found (this
+ * function returns true) or unmodified if
+ * SmartSchema is not found (this function
+ * returns false).
+ *
+ * @return True if function schema for specified input parameters
+ * is found or false otherwise.
+ */
+ bool GetSchema(const FunctionIdEnum function_id,
+ const MessageTypeEnum message_type,
+ NsSmartDeviceLink::NsSmartObjects::CSmartSchema& result);
+
+ /**
+ * @brief Get SmartSchema for specific struct.
+ *
+ * @param struct_id Identifier of the struct.
+ *
+ * @param[out] result This value will be copy of the desired
+ * struct SmartSchema if it found (this
+ * function returns true) or unmodified if
+ * SmartSchema is not found (this function
+ * returns false).
+ *
+ * @return True if struct schema for specified input parameter is
+ * found or false otherwise.
+ */
+ bool GetSchema(const StructIdEnum struct_id,
+ NsSmartDeviceLink::NsSmartObjects::CSmartSchema& result);
+
+ protected:
+ /**
+ * @brief Defines map of SmartSchemaKeys to the SmartSchemes.
+ *
+ * This container type should be used to store SmartSchemes of
+ * functions.
+ */
+ typedef std::map<SmartSchemaKey<FunctionIdEnum, MessageTypeEnum>,
+ NsSmartDeviceLink::NsSmartObjects::CSmartSchema>
+ FuncionsSchemesMap;
+
+ /**
+ * @brief Defines map of StructIdEnum to the SmartSchemes.
+ *
+ * This container type should be used to store SmartSchemes of
+ * structs.
+ */
+ typedef std::map<StructIdEnum,
+ NsSmartDeviceLink::NsSmartObjects::CSmartSchema>
+ StructsSchemesMap;
+
+ /**
+ * @brief Map of all function schemes for this factory.
+ */
+ FuncionsSchemesMap functions_schemes_;
+
+ /**
+ * @brief Map of all struct shemes for this factory.
+ */
+ StructsSchemesMap structs_schemes_;
+};
+
+template <class FunctionIdEnum, class MessageTypeEnum, class StructIdEnum>
+CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::CSmartFactory(
+ void)
+ : functions_schemes_(), structs_schemes_() {}
+
+template <class FunctionIdEnum, class MessageTypeEnum, class StructIdEnum>
+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;
+ if (false == object[strings::S_PARAMS].keyExists(strings::S_FUNCTION_ID))
+ return false;
+
+ MessageTypeEnum msgtype(
+ (MessageTypeEnum)
+ object[strings::S_PARAMS][strings::S_MESSAGE_TYPE].asInt());
+ FunctionIdEnum fid(
+ (FunctionIdEnum)
+ object[strings::S_PARAMS][strings::S_FUNCTION_ID].asInt());
+
+ SmartSchemaKey<FunctionIdEnum, MessageTypeEnum> key(fid, msgtype);
+
+ typename FuncionsSchemesMap::iterator schemaIterator =
+ functions_schemes_.find(key);
+
+ if (schemaIterator == functions_schemes_.end()) {
+ // Schema was not found
+ return false;
+ }
+
+ object.setSchema(schemaIterator->second);
+ schemaIterator->second.applySchema(object, RemoveFakeParameters);
+
+ return true;
+}
+
+template <class FunctionIdEnum, class MessageTypeEnum, class StructIdEnum>
+bool CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::AttachSchema(
+ const StructIdEnum struct_id,
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& object) {
+ typename StructsSchemesMap::iterator structs_iterator =
+ structs_schemes_.find(struct_id);
+
+ if (structs_iterator == structs_schemes_.end()) {
+ return false;
+ }
+
+ object.setSchema(structs_iterator->second);
+ structs_iterator->second.applySchema(object, false);
+
+ return true;
+}
+
+template <class FunctionIdEnum, class MessageTypeEnum, class StructIdEnum>
+NsSmartDeviceLink::NsSmartObjects::SmartObject
+CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::CreateSmartObject(
+ const FunctionIdEnum function_id, const MessageTypeEnum message_type) {
+ SmartSchemaKey<FunctionIdEnum, MessageTypeEnum> key(function_id,
+ message_type);
+
+ typename FuncionsSchemesMap::iterator schema_iterator =
+ functions_schemes_.find(key);
+
+ if (schema_iterator != functions_schemes_.end()) {
+ NsSmartDeviceLink::NsSmartObjects::SmartObject function_object(
+ NsSmartDeviceLink::NsSmartObjects::SmartType_Map);
+ function_object.setSchema(schema_iterator->second);
+ schema_iterator->second.applySchema(function_object, false);
+ return function_object;
+ }
+
+ return NsSmartDeviceLink::NsSmartObjects::SmartObject();
+}
+
+template <class FunctionIdEnum, class MessageTypeEnum, class StructIdEnum>
+NsSmartDeviceLink::NsSmartObjects::SmartObject
+CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::CreateSmartObject(
+ const StructIdEnum struct_id) {
+ NsSmartDeviceLink::NsSmartObjects::SmartObject struct_object(
+ NsSmartDeviceLink::NsSmartObjects::SmartType_Map);
+ if (AttachSchema(struct_id, struct_object)) {
+ return struct_object;
+ }
+
+ return NsSmartDeviceLink::NsSmartObjects::SmartObject();
+}
+
+template <class FunctionIdEnum, class MessageTypeEnum, class StructIdEnum>
+bool CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::GetSchema(
+ const FunctionIdEnum function_id,
+ const MessageTypeEnum message_type,
+ NsSmartDeviceLink::NsSmartObjects::CSmartSchema& result) {
+ SmartSchemaKey<FunctionIdEnum, MessageTypeEnum> key(function_id,
+ message_type);
+
+ typename FuncionsSchemesMap::iterator schema_iterator =
+ functions_schemes_.find(key);
+
+ if (schema_iterator != functions_schemes_.end()) {
+ result = schema_iterator->second;
+ return true;
+ }
+
+ return false;
+}
+
+template <class FunctionIdEnum, class MessageTypeEnum, class StructIdEnum>
+bool CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::GetSchema(
+ const StructIdEnum struct_id,
+ NsSmartDeviceLink::NsSmartObjects::CSmartSchema& result) {
+ typename StructsSchemesMap::iterator structs_iterator =
+ structs_schemes_.find(struct_id);
+
+ if (structs_iterator != structs_schemes_.end()) {
+ result = structs_iterator->second;
+ return true;
+ }
+
+ return false;
+}
+
+template <class FunctionIdEnum, class MessageTypeEnum>
+SmartSchemaKey<FunctionIdEnum, MessageTypeEnum>::SmartSchemaKey(
+ FunctionIdEnum functionIdParam, MessageTypeEnum messageTypeParam)
+ : functionId(functionIdParam), messageType(messageTypeParam) {}
+
+template <class FunctionIdEnum, class MessageTypeEnum>
+bool operator<(const SmartSchemaKey<FunctionIdEnum, MessageTypeEnum>& l,
+ const SmartSchemaKey<FunctionIdEnum, MessageTypeEnum>& r) {
+ if (l.functionId < r.functionId)
+ return true;
+ if (l.functionId > r.functionId)
+ return false;
+
+ if (l.messageType < r.messageType)
+ return true;
+ if (l.messageType > r.messageType)
+ return false;
+
+ return false;
+}
+}
+}
+#endif //__CSMARTFACTORY_HPP__
diff --git a/src/components/formatters/include/formatters/CSmartFactory.hpp b/src/components/formatters/include/formatters/CSmartFactory.hpp
deleted file mode 100644
index 55f9a30385..0000000000
--- a/src/components/formatters/include/formatters/CSmartFactory.hpp
+++ /dev/null
@@ -1,428 +0,0 @@
-/**
- * @file CSmartFactory.hpp
- * @brief CSmartFactory header file.
- */
-// Copyright (c) 2013, Ford Motor Company
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// Redistributions of source code must retain the above copyright notice, this
-// list of conditions and the following disclaimer.
-//
-// Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided with the
-// distribution.
-//
-// Neither the name of the Ford Motor Company nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef __CSMARTFACTORY_HPP__
-#define __CSMARTFACTORY_HPP__
-
-#include "smart_objects/smart_object.h"
-#include "smart_objects/smart_schema.h"
-#include <map>
-#include <string>
-
-namespace NsSmartDeviceLink
-{
- namespace NsJSONHandler
- {
- /**
- * @brief String constants used by SmartFactory.
- */
- namespace strings
- {
- /**
- * @brief String constant for MSG_PARAMS.
- */
- extern const std::string S_MSG_PARAMS;
-
- /**
- * @brief String constant for PARAMS.
- */
- extern const std::string S_PARAMS;
-
- /**
- * @brief String constant for FUNCTION_ID.
- */
- extern const std::string S_FUNCTION_ID;
-
- /**
- * @brief String constant for MESSAGE_TYPE.
- */
- extern const std::string S_MESSAGE_TYPE;
-
- /**
- * @brief String constant for PROTOCOL_VERSION.
- */
- extern const std::string S_PROTOCOL_VERSION;
-
- /**
- * @brief String constant for PROTOCOL_TYPE.
- */
- extern const std::string S_PROTOCOL_TYPE;
-
- /**
- * @brief String constant for CORRELATION_ID.
- */
- extern const std::string S_CORRELATION_ID;
-
- /**
- * @brief String constant for "code" param name.
- */
- extern const std::string kCode;
-
- /**
- * @brief String constant for "message" param name.
- */
- extern const std::string kMessage;
- }
-
- /**
- * @brief Smart Schema key.
- *
- * @tparam FunctionIdEnum Type of function ID enum.
- * @tparam MessageTypeEnum Type of messageType enum.
- */
- template <class FunctionIdEnum, class MessageTypeEnum>
- struct SmartSchemaKey
- {
- /**
- * @brief Value of function ID for the key.
- */
- FunctionIdEnum functionId;
-
- /**
- * @brief Value of messageType for the key.
- */
- MessageTypeEnum messageType;
-
- /**
- * @brief Constructor.
- *
- * @param functionIdParam Value of function ID.
- * @param messageTypeParam Value of message type.
- */
- SmartSchemaKey(FunctionIdEnum functionIdParam, MessageTypeEnum messageTypeParam);
- };
-
- /**
- * @brief Smart Factory.
- *
- * This class is used as base class for generated factories.
- * Clients should use methods of this class to access all
- * SmartSchema validation features.
- *
- * @tparam FunctionIdEnum Type of function ID enum.
- * @tparam MessageTypeEnum Type of messageType enum.
- * @tparam StructIdEnum Type of StructId enum.
- */
- template <class FunctionIdEnum, class MessageTypeEnum, class StructIdEnum>
- class CSmartFactory
- {
- public:
-
- /**
- * @brief Constructor.
- */
- CSmartFactory(void);
-
- /**
- * @brief Attach schema to the function SmartObject.
- *
- * @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,
- const bool RemoveFakeParameters);
-
- /**
- * @brief Attach schema to the struct SmartObject.
- *
- * @param struct_id Identifier of the struct.
- * @param object SmartObject to attach schema for.
- *
- * @return True if operation was successful of false otherwise.
- */
- bool AttachSchema(const StructIdEnum struct_id,
- NsSmartDeviceLink::NsSmartObjects::SmartObject &object);
-
-
- /**
- * @brief Create new SmartObject with attached function SmartSchema.
- *
- * @param function_id FunctionID of the function.
- * @param message_type messageType of the function.
- *
- * @return If function succeeded it returns new SmartObject with
- * map type and attached SmartSchema. Client can use such
- * object to store specific function and perform validation.
- * Otherwise (if SmartSchema was not attached to the
- * SmartObject) function returns empty SmartObject with
- * null type.
- */
- NsSmartDeviceLink::NsSmartObjects::SmartObject CreateSmartObject(
- const FunctionIdEnum function_id,
- const MessageTypeEnum message_type);
-
- /**
- * @brief Create new SmartObject with attached struct SmartSchema.
- *
- * @param struct_id Identifier of the struct.
- *
- * @return If function succeeded it returns new SmartObject with
- * map type and attached SmartSchema. Client can use such
- * object to store specific struct and perform validation.
- * Otherwise (if SmartSchema was not attached to the
- * SmartObject) function returns empty SmartObject with
- * null type.
- */
- NsSmartDeviceLink::NsSmartObjects::SmartObject CreateSmartObject(
- const StructIdEnum struct_id);
-
- /**
- * @brief Get SmartSchema for specific function.
- *
- * @param function_id FunctionID of the function.
- * @param message_type messageType of the function.
- * @param[out] result This value will be copy of the desired
- * function SmartSchema if it found (this
- * function returns true) or unmodified if
- * SmartSchema is not found (this function
- * returns false).
- *
- * @return True if function schema for specified input parameters
- * is found or false otherwise.
- */
- bool GetSchema(
- const FunctionIdEnum function_id,
- const MessageTypeEnum message_type,
- NsSmartDeviceLink::NsSmartObjects::CSmartSchema &result);
-
- /**
- * @brief Get SmartSchema for specific struct.
- *
- * @param struct_id Identifier of the struct.
- *
- * @param[out] result This value will be copy of the desired
- * struct SmartSchema if it found (this
- * function returns true) or unmodified if
- * SmartSchema is not found (this function
- * returns false).
- *
- * @return True if struct schema for specified input parameter is
- * found or false otherwise.
- */
- bool GetSchema(
- const StructIdEnum struct_id,
- NsSmartDeviceLink::NsSmartObjects::CSmartSchema &result);
-
- protected:
-
- /**
- * @brief Defines map of SmartSchemaKeys to the SmartSchemes.
- *
- * This container type should be used to store SmartSchemes of
- * functions.
- */
- typedef std::map<SmartSchemaKey<FunctionIdEnum, MessageTypeEnum>,
- NsSmartDeviceLink::NsSmartObjects::CSmartSchema>
- FuncionsSchemesMap;
-
- /**
- * @brief Defines map of StructIdEnum to the SmartSchemes.
- *
- * This container type should be used to store SmartSchemes of
- * structs.
- */
- typedef std::map<StructIdEnum,
- NsSmartDeviceLink::NsSmartObjects::CSmartSchema>
- StructsSchemesMap;
-
- /**
- * @brief Map of all function schemes for this factory.
- */
- FuncionsSchemesMap functions_schemes_;
-
- /**
- * @brief Map of all struct shemes for this factory.
- */
- StructsSchemesMap structs_schemes_;
- };
-
- template <class FunctionIdEnum, class MessageTypeEnum, class StructIdEnum>
- CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::CSmartFactory(void)
- : functions_schemes_(),
- structs_schemes_()
- {
- }
-
- template <class FunctionIdEnum, class MessageTypeEnum, class StructIdEnum>
- 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;
- if(false == object[strings::S_PARAMS].keyExists(strings::S_FUNCTION_ID)) return false;
-
- MessageTypeEnum msgtype((MessageTypeEnum)object[strings::S_PARAMS][strings::S_MESSAGE_TYPE].asInt());
- FunctionIdEnum fid((FunctionIdEnum)object[strings::S_PARAMS][strings::S_FUNCTION_ID].asInt());
-
- SmartSchemaKey<FunctionIdEnum, MessageTypeEnum> key(fid, msgtype);
-
- typename FuncionsSchemesMap::iterator schemaIterator = functions_schemes_.find(key);
-
- if(schemaIterator == functions_schemes_.end())
- {
- // Schema was not found
- return false;
- }
-
- object.setSchema(schemaIterator->second);
- schemaIterator->second.applySchema(object, RemoveFakeParameters);
-
- return true;
- }
-
- template <class FunctionIdEnum,
- class MessageTypeEnum,
- class StructIdEnum>
- bool CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::
- AttachSchema(
- const StructIdEnum struct_id,
- NsSmartDeviceLink::NsSmartObjects::SmartObject &object) {
- typename StructsSchemesMap::iterator structs_iterator =
- structs_schemes_.find(struct_id);
-
- if (structs_iterator == structs_schemes_.end()) {
- return false;
- }
-
- object.setSchema(structs_iterator->second);
- structs_iterator->second.applySchema(object, false);
-
- return true;
- }
-
- template <class FunctionIdEnum,
- class MessageTypeEnum,
- class StructIdEnum>
- NsSmartDeviceLink::NsSmartObjects::SmartObject
- CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::
- CreateSmartObject(
- const FunctionIdEnum function_id,
- const MessageTypeEnum message_type) {
- SmartSchemaKey<FunctionIdEnum, MessageTypeEnum> key(
- function_id, message_type);
-
- typename FuncionsSchemesMap::iterator schema_iterator =
- functions_schemes_.find(key);
-
- if(schema_iterator != functions_schemes_.end()) {
- NsSmartDeviceLink::NsSmartObjects::SmartObject function_object(
- NsSmartDeviceLink::NsSmartObjects::SmartType_Map);
- function_object.setSchema(schema_iterator->second);
- schema_iterator->second.applySchema(function_object, false);
- return function_object;
- }
-
- return NsSmartDeviceLink::NsSmartObjects::SmartObject();
- }
-
- template <class FunctionIdEnum,
- class MessageTypeEnum,
- class StructIdEnum>
- NsSmartDeviceLink::NsSmartObjects::SmartObject
- CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::
- CreateSmartObject(const StructIdEnum struct_id) {
- NsSmartDeviceLink::NsSmartObjects::SmartObject struct_object(
- NsSmartDeviceLink::NsSmartObjects::SmartType_Map);
- if (AttachSchema(struct_id, struct_object)) {
- return struct_object;
- }
-
- return NsSmartDeviceLink::NsSmartObjects::SmartObject();
- }
-
- template <class FunctionIdEnum,
- class MessageTypeEnum,
- class StructIdEnum>
- bool CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::
- GetSchema(const FunctionIdEnum function_id,
- const MessageTypeEnum message_type,
- NsSmartDeviceLink::NsSmartObjects::CSmartSchema &result) {
- SmartSchemaKey<FunctionIdEnum, MessageTypeEnum> key(function_id,
- message_type);
-
- typename FuncionsSchemesMap::iterator schema_iterator =
- functions_schemes_.find(key);
-
- if(schema_iterator != functions_schemes_.end()) {
- result = schema_iterator->second;
- return true;
- }
-
- return false;
- }
-
- template <class FunctionIdEnum,
- class MessageTypeEnum,
- class StructIdEnum>
- bool CSmartFactory<FunctionIdEnum, MessageTypeEnum, StructIdEnum>::
- GetSchema(const StructIdEnum struct_id,
- NsSmartDeviceLink::NsSmartObjects::CSmartSchema &result) {
- typename StructsSchemesMap::iterator structs_iterator =
- structs_schemes_.find(struct_id);
-
- if(structs_iterator != structs_schemes_.end()) {
- result = structs_iterator->second;
- return true;
- }
-
- return false;
- }
-
- template <class FunctionIdEnum, class MessageTypeEnum>
- SmartSchemaKey<FunctionIdEnum, MessageTypeEnum>::SmartSchemaKey(FunctionIdEnum functionIdParam, MessageTypeEnum messageTypeParam)
- : functionId(functionIdParam)
- , messageType(messageTypeParam)
- {
-
- }
-
- template <class FunctionIdEnum, class MessageTypeEnum>
- bool operator<(const SmartSchemaKey< FunctionIdEnum, MessageTypeEnum >& l, const SmartSchemaKey< FunctionIdEnum, MessageTypeEnum >& r)
- {
- if (l.functionId < r.functionId) return true;
- if (l.functionId > r.functionId) return false;
-
- if (l.messageType < r.messageType) return true;
- if (l.messageType > r.messageType) return false;
-
- return false;
- }
- }
-}
-#endif //__CSMARTFACTORY_HPP__
diff --git a/src/components/formatters/include/formatters/formatter_json_rpc.h b/src/components/formatters/include/formatters/formatter_json_rpc.h
index d4653ef565..db122fa1a2 100644
--- a/src/components/formatters/include/formatters/formatter_json_rpc.h
+++ b/src/components/formatters/include/formatters/formatter_json_rpc.h
@@ -42,8 +42,8 @@
#include "smart_objects/enum_schema_item.h"
#include "json/json.h"
-#include "CFormatterJsonBase.hpp"
-#include "formatters/CSmartFactory.hpp"
+#include "CFormatterJsonBase.h"
+#include "formatters/CSmartFactory.h"
namespace NsSmartDeviceLink {
namespace NsJSONHandler {
@@ -52,415 +52,415 @@ namespace Formatters {
/**
* @brief Formatter for JSON RPC format.
*/
-class FormatterJsonRpc: public CFormatterJsonBase {
- public:
- /**
- * @brief No errors occurred during the parsing of the input JSON string.
- */
- static const int32_t kSuccess = 0;
-
- /**
- * @brief Input JSON string cannot be parsed.
- */
- static const int32_t kParsingError = 1;
-
- /**
- * @brief Input JSON string has invalid format.
- */
- static const int32_t kInvalidFormat = 2;
-
- /**
- * @brief Method in input JSON string is not
- * specified or specified incorrectly.
- */
- static const int32_t kMethodNotSpecified = 4;
-
- /**
- * @brief Method is unknown.
- */
- static const int32_t kUnknownMethod = 8;
-
- /**
- * @brief Message type is unknown.
- */
- static const int32_t kUnknownMessageType = 16;
-
- /**
- * @brief Id of request or response is invalid.
- */
- static const int32_t kInvalidId = 32;
-
- /**
- * @brief Response code is not available.
- */
- static const int32_t kResponseCodeNotAvailable = 64;
-
- /**
- * @brief Message for error response is not available.
- */
- static const int32_t kErrorResponseMessageNotAvailable = 128;
-
- /**
- * @brief Creates a JSON string from a SmartObject.
- *
- * @param obj Input SmartObject.
- * @param out_str Resulting JSON string.
- *
- * @return true if success, false otherwise.
- */
- static bool ToString(const NsSmartObjects::SmartObject& obj,
- std::string& out_str);
-
- /**
- * @brief Creates a SmartObject from a JSON string.
- *
- * @tparam FunctionId Type of function id enumeration.
- * @tparam MessageType Type of message type enumeration.
- *
- * @param str input JSON string.
- * @param out The resulting SmartObject.
- *
- * @return An integer that is a bitwise-or of all error codes occurred
- * during the parsing of the input string. 0 if no errors occurred.
- */
- template <typename FunctionId, typename MessageType>
- static int32_t FromString(const std::string& str,
- NsSmartObjects::SmartObject& out);
-
- private:
- /**
- * @brief Request.
- */
- static const char* kRequest;
-
- /**
- * @brief Response.
- */
- static const char* kResponse;
-
- /**
- * @brief Notification.
- */
- static const char* kNotification;
-
- /**
- * @brief Error reponse.
- */
- static const char* kErrorResponse;
-
- /**
- * @brief Name of "jsonrpc" message field.
- */
- static const char* kJsonRpc;
-
- /**
- * @brief Expected value of "jsonrpc" message field ("2.0").
- */
- static const char* kJsonRpcExpectedValue;
-
- /**
- * @brief Name of "id" message field.
- */
- static const char* kId;
-
- /**
- * @brief Name of "method" field.
- */
- static const char* kMethod;
-
- /**
- * @brief Name of "params" field.
- */
- static const char* kParams;
-
- /**
- * @brief Name of "result" field.
- */
- static const char* kResult;
-
- /**
- * @brief Name of "error" field.
- */
- static const char* kError;
-
- /**
- * @brief Name of "code" field.
- */
- static const char* kCode;
-
- /**
- * @brief Name of "data" field.
- */
- static const char* kData;
-
- /**
- * @brief Name of "message" field.
- */
- static const char* kMessage;
-
- /**
- * @brief Constructor.
- */
- FormatterJsonRpc();
-
- /**
- * @brief Copy constructor.
- *
- * @param unused Unused parameter.
- */
- FormatterJsonRpc(const FormatterJsonRpc& unused);
-
- /**
- * @brief Parse function id.
- *
- * @tparam FunctionId Type of function id enumeration.
- *
- * @param method_value JSON value with function id.
- * @param out The resulting SmartObject.
- *
- * @return An integer that is a bitwise-or of all error codes occurred
- * during the parsing of the function id. 0 if no errors occurred.
- */
- template <typename FunctionId>
- static int32_t ParseFunctionId(const Json::Value& method_value,
- NsSmartObjects::SmartObject& out);
-
- /**
- * @brief Set method.
- *
- * Try to extract function id from the message object and set the "method"
- * field of the container.
- *
- * @param params Message parameters object.
- * @param method_container Container for the "method" field.
- *
- * @return true if function id was extracted successfully and set as a
- * value of "method" field.
- */
- static bool SetMethod(const NsSmartObjects::SmartObject& params,
- Json::Value& method_container);
-
- /**
- * @brief Set id.
- *
- * Try to extract request/response id from the message object and set the
- * "id" field of the container.
- *
- * @param params Message parameters object.
- * @param id_container Container for the "id" field.
- *
- * @return true if request/response id was extracted successfully and set
- * as a value of "id" field.
- */
- static bool SetId(const NsSmartObjects::SmartObject& params,
- Json::Value& id_container);
-
- /**
- * @brief Set message
- *
- * Try to extract message from response error object and set "message" field for the container
- *
- * @param params Message parameters object.
- * @param id_container Container of the "message" field
- *
- * @return true if message string was extracted successfully and set
- * as a value of "message" field.
- */
- static bool SetMessage(const NsSmartObjects::SmartObject& params,
- Json::Value& id_container);
+class FormatterJsonRpc : public CFormatterJsonBase {
+ public:
+ /**
+ * @brief No errors occurred during the parsing of the input JSON string.
+ */
+ static const int32_t kSuccess = 0;
+
+ /**
+ * @brief Input JSON string cannot be parsed.
+ */
+ static const int32_t kParsingError = 1;
+
+ /**
+ * @brief Input JSON string has invalid format.
+ */
+ static const int32_t kInvalidFormat = 2;
+
+ /**
+ * @brief Method in input JSON string is not
+ * specified or specified incorrectly.
+ */
+ static const int32_t kMethodNotSpecified = 4;
+
+ /**
+ * @brief Method is unknown.
+ */
+ static const int32_t kUnknownMethod = 8;
+
+ /**
+ * @brief Message type is unknown.
+ */
+ static const int32_t kUnknownMessageType = 16;
+
+ /**
+ * @brief Id of request or response is invalid.
+ */
+ static const int32_t kInvalidId = 32;
+
+ /**
+ * @brief Response code is not available.
+ */
+ static const int32_t kResponseCodeNotAvailable = 64;
+
+ /**
+ * @brief Message for error response is not available.
+ */
+ static const int32_t kErrorResponseMessageNotAvailable = 128;
+
+ /**
+ * @brief Creates a JSON string from a SmartObject.
+ *
+ * @param obj Input SmartObject.
+ * @param out_str Resulting JSON string.
+ *
+ * @return true if success, false otherwise.
+ */
+ static bool ToString(const NsSmartObjects::SmartObject& obj,
+ std::string& out_str);
+
+ /**
+ * @brief Creates a SmartObject from a JSON string.
+ *
+ * @tparam FunctionId Type of function id enumeration.
+ * @tparam MessageType Type of message type enumeration.
+ *
+ * @param str input JSON string.
+ * @param out The resulting SmartObject.
+ *
+ * @return An integer that is a bitwise-or of all error codes occurred
+ * during the parsing of the input string. 0 if no errors occurred.
+ */
+ template <typename FunctionId, typename MessageType>
+ static int32_t FromString(const std::string& str,
+ NsSmartObjects::SmartObject& out);
+
+ private:
+ /**
+ * @brief Request.
+ */
+ static const char* kRequest;
+
+ /**
+ * @brief Response.
+ */
+ static const char* kResponse;
+
+ /**
+ * @brief Notification.
+ */
+ static const char* kNotification;
+
+ /**
+ * @brief Error reponse.
+ */
+ static const char* kErrorResponse;
+
+ /**
+ * @brief Name of "jsonrpc" message field.
+ */
+ static const char* kJsonRpc;
+
+ /**
+ * @brief Expected value of "jsonrpc" message field ("2.0").
+ */
+ static const char* kJsonRpcExpectedValue;
+
+ /**
+ * @brief Name of "id" message field.
+ */
+ static const char* kId;
+
+ /**
+ * @brief Name of "method" field.
+ */
+ static const char* kMethod;
+
+ /**
+ * @brief Name of "params" field.
+ */
+ static const char* kParams;
+
+ /**
+ * @brief Name of "result" field.
+ */
+ static const char* kResult;
+
+ /**
+ * @brief Name of "error" field.
+ */
+ static const char* kError;
+
+ /**
+ * @brief Name of "code" field.
+ */
+ static const char* kCode;
+
+ /**
+ * @brief Name of "data" field.
+ */
+ static const char* kData;
+
+ /**
+ * @brief Name of "message" field.
+ */
+ static const char* kMessage;
+
+ /**
+ * @brief Constructor.
+ */
+ FormatterJsonRpc();
+
+ /**
+ * @brief Copy constructor.
+ *
+ * @param unused Unused parameter.
+ */
+ FormatterJsonRpc(const FormatterJsonRpc& unused);
+
+ /**
+ * @brief Parse function id.
+ *
+ * @tparam FunctionId Type of function id enumeration.
+ *
+ * @param method_value JSON value with function id.
+ * @param out The resulting SmartObject.
+ *
+ * @return An integer that is a bitwise-or of all error codes occurred
+ * during the parsing of the function id. 0 if no errors occurred.
+ */
+ template <typename FunctionId>
+ static int32_t ParseFunctionId(const Json::Value& method_value,
+ NsSmartObjects::SmartObject& out);
+
+ /**
+ * @brief Set method.
+ *
+ * Try to extract function id from the message object and set the "method"
+ * field of the container.
+ *
+ * @param params Message parameters object.
+ * @param method_container Container for the "method" field.
+ *
+ * @return true if function id was extracted successfully and set as a
+ * value of "method" field.
+ */
+ static bool SetMethod(const NsSmartObjects::SmartObject& params,
+ Json::Value& method_container);
+
+ /**
+ * @brief Set id.
+ *
+ * Try to extract request/response id from the message object and set the
+ * "id" field of the container.
+ *
+ * @param params Message parameters object.
+ * @param id_container Container for the "id" field.
+ *
+ * @return true if request/response id was extracted successfully and set
+ * as a value of "id" field.
+ */
+ static bool SetId(const NsSmartObjects::SmartObject& params,
+ Json::Value& id_container);
+
+ /**
+ * @brief Set message
+ *
+ * Try to extract message from response error object and set "message" field
+ *for the container
+ *
+ * @param params Message parameters object.
+ * @param id_container Container of the "message" field
+ *
+ * @return true if message string was extracted successfully and set
+ * as a value of "message" field.
+ */
+ static bool SetMessage(const NsSmartObjects::SmartObject& params,
+ Json::Value& id_container);
};
template <typename FunctionId, typename MessageType>
int32_t FormatterJsonRpc::FromString(const std::string& str,
- NsSmartObjects::SmartObject& out) {
+ NsSmartObjects::SmartObject& out) {
int32_t result = kSuccess;
try {
- Json::Value root;
- Json::Reader reader;
- namespace strings = NsSmartDeviceLink::NsJSONHandler::strings;
+ Json::Value root;
+ Json::Reader reader;
+ namespace strings = NsSmartDeviceLink::NsJSONHandler::strings;
- if (false == reader.parse(str, root)) {
- result = kParsingError | kMethodNotSpecified | kUnknownMethod |
- kUnknownMessageType;
- } else {
- if (false == root.isMember(kJsonRpc)) {
- result |= kInvalidFormat;
+ if (false == reader.parse(str, root)) {
+ result = kParsingError | kMethodNotSpecified | kUnknownMethod |
+ kUnknownMessageType;
} else {
- const Json::Value& jsonRpcValue = root[kJsonRpc];
-
- if ((false == jsonRpcValue.isString()) ||
- (jsonRpcValue.asString() != kJsonRpcExpectedValue)) {
+ if (false == root.isMember(kJsonRpc)) {
result |= kInvalidFormat;
+ } else {
+ const Json::Value& jsonRpcValue = root[kJsonRpc];
+
+ if ((false == jsonRpcValue.isString()) ||
+ (jsonRpcValue.asString() != kJsonRpcExpectedValue)) {
+ result |= kInvalidFormat;
+ }
}
- }
- std::string message_type_string;
- Json::Value response_value;
- bool response_value_found = false;
- bool is_error_response = false;
+ std::string message_type_string;
+ Json::Value response_value;
+ bool response_value_found = false;
+ bool is_error_response = false;
- if (false == root.isMember(kId)) {
- message_type_string = kNotification;
+ if (false == root.isMember(kId)) {
+ message_type_string = kNotification;
- if (false == root.isMember(kMethod)) {
- result |= kMethodNotSpecified | kUnknownMethod;
- } else {
- result |= ParseFunctionId<FunctionId>(root[kMethod], out);
- }
- out[strings::S_MSG_PARAMS]
- = NsSmartObjects::SmartObject(NsSmartObjects::SmartType_Map);
- } else {
- const Json::Value& id_value = root[kId];
-
- if (true == id_value.isString()) {
- out[strings::S_PARAMS][strings::S_CORRELATION_ID] =
- id_value.asString();
- } else if (true == id_value.isInt()) {
- out[strings::S_PARAMS][strings::S_CORRELATION_ID] =
- id_value.asInt();
- } else if (true == id_value.isDouble()) {
- out[strings::S_PARAMS][strings::S_CORRELATION_ID] =
- id_value.asDouble();
- } else if (true == id_value.isNull()) {
- out[strings::S_PARAMS][strings::S_CORRELATION_ID] =
- NsSmartObjects::SmartObject(NsSmartObjects::SmartType_Null);
- } else {
- result |= kInvalidFormat | kInvalidId;
- }
-
- if (true == root.isMember(kMethod)) {
- message_type_string = kRequest;
- result |= ParseFunctionId<FunctionId>(root[kMethod], out);
- out[strings::S_MSG_PARAMS]
- = NsSmartObjects::SmartObject(NsSmartObjects::SmartType_Map);
+ if (false == root.isMember(kMethod)) {
+ result |= kMethodNotSpecified | kUnknownMethod;
+ } else {
+ result |= ParseFunctionId<FunctionId>(root[kMethod], out);
+ }
+ out[strings::S_MSG_PARAMS] =
+ NsSmartObjects::SmartObject(NsSmartObjects::SmartType_Map);
} else {
- Json::Value method_container;
- bool method_container_found = false;
-
- if (true == root.isMember(kResult)) {
- out[strings::S_MSG_PARAMS]
- = NsSmartObjects::SmartObject(NsSmartObjects::SmartType_Map);
-
- message_type_string = kResponse;
- response_value = root[kResult];
- response_value_found = true;
- method_container = root[kResult];
- method_container_found = true;
- } else if (true == root.isMember(kError)) {
- out[strings::S_MSG_PARAMS]
- = NsSmartObjects::SmartObject(NsSmartObjects::SmartType_Map);
- message_type_string = kErrorResponse;
- response_value = root[kError];
- response_value_found = true;
- is_error_response = true;
-
- if (true == response_value.isObject()) {
- if (true == response_value.isMember(kData)) {
- method_container = response_value[kData];
- method_container_found = true;
- }
- }
+ const Json::Value& id_value = root[kId];
+
+ if (true == id_value.isString()) {
+ out[strings::S_PARAMS][strings::S_CORRELATION_ID] =
+ id_value.asString();
+ } else if (true == id_value.isInt()) {
+ out[strings::S_PARAMS][strings::S_CORRELATION_ID] = id_value.asInt();
+ } else if (true == id_value.isDouble()) {
+ out[strings::S_PARAMS][strings::S_CORRELATION_ID] =
+ id_value.asDouble();
+ } else if (true == id_value.isNull()) {
+ out[strings::S_PARAMS][strings::S_CORRELATION_ID] =
+ NsSmartObjects::SmartObject(NsSmartObjects::SmartType_Null);
} else {
- result |= kUnknownMessageType;
+ result |= kInvalidFormat | kInvalidId;
}
- if (false == method_container_found) {
- result |= kMethodNotSpecified | kUnknownMethod;
- } else if (false == method_container.isObject()) {
- result |= kInvalidFormat | kMethodNotSpecified | kUnknownMethod;
+ if (true == root.isMember(kMethod)) {
+ message_type_string = kRequest;
+ result |= ParseFunctionId<FunctionId>(root[kMethod], out);
+ out[strings::S_MSG_PARAMS] =
+ NsSmartObjects::SmartObject(NsSmartObjects::SmartType_Map);
} else {
- if (false == method_container.isMember(kMethod)) {
+ Json::Value method_container;
+ bool method_container_found = false;
+
+ if (true == root.isMember(kResult)) {
+ out[strings::S_MSG_PARAMS] =
+ NsSmartObjects::SmartObject(NsSmartObjects::SmartType_Map);
+
+ message_type_string = kResponse;
+ response_value = root[kResult];
+ response_value_found = true;
+ method_container = root[kResult];
+ method_container_found = true;
+ } else if (true == root.isMember(kError)) {
+ out[strings::S_MSG_PARAMS] =
+ NsSmartObjects::SmartObject(NsSmartObjects::SmartType_Map);
+ message_type_string = kErrorResponse;
+ response_value = root[kError];
+ response_value_found = true;
+ is_error_response = true;
+
+ if (true == response_value.isObject()) {
+ if (true == response_value.isMember(kData)) {
+ method_container = response_value[kData];
+ method_container_found = true;
+ }
+ }
+ } else {
+ result |= kUnknownMessageType;
+ }
+
+ if (false == method_container_found) {
result |= kMethodNotSpecified | kUnknownMethod;
+ } else if (false == method_container.isObject()) {
+ result |= kInvalidFormat | kMethodNotSpecified | kUnknownMethod;
} else {
- result |= ParseFunctionId<FunctionId>(method_container[kMethod],
- out);
+ if (false == method_container.isMember(kMethod)) {
+ result |= kMethodNotSpecified | kUnknownMethod;
+ } else {
+ result |=
+ ParseFunctionId<FunctionId>(method_container[kMethod], out);
+ }
}
}
}
- }
- if (0 == (result & kUnknownMessageType)) {
- MessageType message_type;
+ if (0 == (result & kUnknownMessageType)) {
+ MessageType message_type;
- if (!NsSmartObjects::EnumConversionHelper<MessageType>::StringToEnum(
- message_type_string, &message_type)) {
- result |= kUnknownMessageType;
- } else {
- out[strings::S_PARAMS][strings::S_MESSAGE_TYPE] = message_type;
+ if (!NsSmartObjects::EnumConversionHelper<MessageType>::StringToEnum(
+ message_type_string, &message_type)) {
+ result |= kUnknownMessageType;
+ } else {
+ out[strings::S_PARAMS][strings::S_MESSAGE_TYPE] = message_type;
+ }
}
- }
- if (true == root.isMember(kParams)) {
- const Json::Value& params_value = root[kParams];
-
- if (false == params_value.isObject()) {
- result |= kInvalidFormat;
- } else {
- jsonValueToObj(root[kParams], out[strings::S_MSG_PARAMS]);
- }
- } else if (true == root.isMember(kResult)) {
- const Json::Value& result_value = root[kResult];
+ if (true == root.isMember(kParams)) {
+ const Json::Value& params_value = root[kParams];
- if (false == result_value.isObject()) {
- result |= kInvalidFormat;
- } else {
- jsonValueToObj(root[kResult], out[strings::S_MSG_PARAMS]);
- }
- } else if (true == is_error_response) {
- jsonValueToObj(response_value[kData], out[strings::S_PARAMS][kData]);
- }
+ if (false == params_value.isObject()) {
+ result |= kInvalidFormat;
+ } else {
+ jsonValueToObj(root[kParams], out[strings::S_MSG_PARAMS]);
+ }
+ } else if (true == root.isMember(kResult)) {
+ const Json::Value& result_value = root[kResult];
- if ((kResponse == message_type_string) ||
- (kErrorResponse == message_type_string)) {
- if (true == out.keyExists(strings::S_MSG_PARAMS)) {
- out[strings::S_MSG_PARAMS].erase(kMethod);
- out[strings::S_MSG_PARAMS].erase(kCode);
+ if (false == result_value.isObject()) {
+ result |= kInvalidFormat;
+ } else {
+ jsonValueToObj(root[kResult], out[strings::S_MSG_PARAMS]);
+ }
+ } else if (true == is_error_response) {
+ jsonValueToObj(response_value[kData], out[strings::S_PARAMS][kData]);
}
- if (false == response_value_found) {
- result |= kResponseCodeNotAvailable;
- } else {
- if (false == response_value.isObject()) {
- result |= kInvalidFormat | kResponseCodeNotAvailable;
+ if ((kResponse == message_type_string) ||
+ (kErrorResponse == message_type_string)) {
+ if (true == out.keyExists(strings::S_MSG_PARAMS)) {
+ out[strings::S_MSG_PARAMS].erase(kMethod);
+ out[strings::S_MSG_PARAMS].erase(kCode);
+ }
- if (true == is_error_response) {
- result |= kErrorResponseMessageNotAvailable;
- }
+ if (false == response_value_found) {
+ result |= kResponseCodeNotAvailable;
} else {
- if (false == response_value.isMember(kCode)) {
- result |= kResponseCodeNotAvailable;
- } else {
- const Json::Value& code_value = response_value[kCode];
-
- if (false == code_value.isInt()) {
- result |= kInvalidFormat | kResponseCodeNotAvailable;
- } else {
- out[strings::S_PARAMS][strings::kCode] = code_value.asInt();
- }
- }
+ if (false == response_value.isObject()) {
+ result |= kInvalidFormat | kResponseCodeNotAvailable;
- if (true == is_error_response) {
- if (false == response_value.isMember(kMessage)) {
+ if (true == is_error_response) {
result |= kErrorResponseMessageNotAvailable;
+ }
+ } else {
+ if (false == response_value.isMember(kCode)) {
+ result |= kResponseCodeNotAvailable;
} else {
- const Json::Value& message_value = response_value[kMessage];
+ const Json::Value& code_value = response_value[kCode];
- if (false == message_value.isString()) {
+ if (false == code_value.isInt()) {
+ result |= kInvalidFormat | kResponseCodeNotAvailable;
+ } else {
+ out[strings::S_PARAMS][strings::kCode] = code_value.asInt();
+ }
+ }
+
+ if (true == is_error_response) {
+ if (false == response_value.isMember(kMessage)) {
result |= kErrorResponseMessageNotAvailable;
} else {
- out[strings::S_PARAMS][strings::kMessage] =
- message_value.asString();
+ const Json::Value& message_value = response_value[kMessage];
+
+ if (false == message_value.isString()) {
+ result |= kErrorResponseMessageNotAvailable;
+ } else {
+ out[strings::S_PARAMS][strings::kMessage] =
+ message_value.asString();
+ }
}
}
}
}
}
}
- }
- out[strings::S_PARAMS][strings::S_PROTOCOL_TYPE] = 1;
- out[strings::S_PARAMS][strings::S_PROTOCOL_VERSION] = 2;
- } catch(...) {
+ out[strings::S_PARAMS][strings::S_PROTOCOL_TYPE] = 1;
+ out[strings::S_PARAMS][strings::S_PROTOCOL_VERSION] = 2;
+ } catch (...) {
result = kParsingError;
}
@@ -469,7 +469,7 @@ int32_t FormatterJsonRpc::FromString(const std::string& str,
template <typename FunctionId>
int32_t FormatterJsonRpc::ParseFunctionId(const Json::Value& method_value,
- NsSmartObjects::SmartObject& out) {
+ NsSmartObjects::SmartObject& out) {
int32_t result = kSuccess;
if (false == method_value.isString()) {
@@ -478,7 +478,7 @@ int32_t FormatterJsonRpc::ParseFunctionId(const Json::Value& method_value,
FunctionId function_id;
if (!NsSmartObjects::EnumConversionHelper<FunctionId>::CStringToEnum(
- method_value.asCString(), &function_id)) {
+ method_value.asCString(), &function_id)) {
result |= kUnknownMethod;
} else {
namespace strings = NsSmartDeviceLink::NsJSONHandler::strings;
@@ -494,4 +494,4 @@ int32_t FormatterJsonRpc::ParseFunctionId(const Json::Value& method_value,
} // namespace NsJSONHandler
} // namespace NsSmartDeviceLink
-#endif // SMARTDEVICELINK_COMPONENTS_JSONHANDLER_INCLUDE_FORMATTERS_FORMATTER_JSON_RPC_H_
+#endif // SMARTDEVICELINK_COMPONENTS_JSONHANDLER_INCLUDE_FORMATTERS_FORMATTER_JSON_RPC_H_
diff --git a/src/components/formatters/include/formatters/generic_json_formatter.h b/src/components/formatters/include/formatters/generic_json_formatter.h
index a4b3f3f712..580a49d73a 100644
--- a/src/components/formatters/include/formatters/generic_json_formatter.h
+++ b/src/components/formatters/include/formatters/generic_json_formatter.h
@@ -35,14 +35,14 @@
#ifndef SMARTDEVICELINK_COMPONENTS_FORMATTERS_INCLUDE_FORMATTERS_GENERIC_JSON_FORMATTER_H_
#define SMARTDEVICELINK_COMPONENTS_FORMATTERS_INCLUDE_FORMATTERS_GENERIC_JSON_FORMATTER_H_
-#include "CFormatterJsonBase.hpp"
+#include "CFormatterJsonBase.h"
namespace NsSmartDeviceLink {
namespace NsJSONHandler {
namespace Formatters {
-class GenericJsonFormatter: public CFormatterJsonBase {
-public:
+class GenericJsonFormatter : public CFormatterJsonBase {
+ public:
/**
* @brief Creates a JSON string from a SmartObject.
*
@@ -64,8 +64,8 @@ public:
NsSmartObjects::SmartObject& out);
};
-} // namespace Formatters
-} // namespace NsJSONHandler
-} // namespace NsSmartDeviceLink
+} // namespace Formatters
+} // namespace NsJSONHandler
+} // namespace NsSmartDeviceLink
-#endif // SMARTDEVICELINK_COMPONENTS_FORMATTERS_INCLUDE_FORMATTERS_GENERIC_JSON_FORMATTER_H_
+#endif // SMARTDEVICELINK_COMPONENTS_FORMATTERS_INCLUDE_FORMATTERS_GENERIC_JSON_FORMATTER_H_
diff --git a/src/components/formatters/include/formatters/meta_formatter.h b/src/components/formatters/include/formatters/meta_formatter.h
index f9fd6fad72..65b8c19863 100644
--- a/src/components/formatters/include/formatters/meta_formatter.h
+++ b/src/components/formatters/include/formatters/meta_formatter.h
@@ -44,7 +44,8 @@ namespace NsJSONHandler {
namespace Formatters {
/**
- * @brief Formats to string the smart object against given schema for given formatter
+ * @brief Formats to string the smart object against given schema for given
+ *formatter
*
* Sample usage:
* CSmartFactory factory;
@@ -54,7 +55,6 @@ namespace Formatters {
*/
class CMetaFormatter {
public:
-
/**
* @brief Creates smart object by the given schema having copied
* matched tree elements from original object.
@@ -66,13 +66,13 @@ class CMetaFormatter {
* @return true if successful, false - otherwise
*/
static bool CreateObjectByPattern(
- const NsSmartDeviceLink::NsSmartObjects::SmartObject& object,
- const NsSmartDeviceLink::NsSmartObjects::CSmartSchema& schema,
- NsSmartDeviceLink::NsSmartObjects::SmartObject& result_object);
+ const NsSmartDeviceLink::NsSmartObjects::SmartObject& object,
+ const NsSmartDeviceLink::NsSmartObjects::CSmartSchema& schema,
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& result_object);
};
-}// namespace NsSmartDeviceLink
-}// namespace NsSmartDeviceLink::NsJSONHandler
-}// namespace NsSmartDeviceLink::NsJSONHandler::Formatters
+} // namespace NsSmartDeviceLink
+} // namespace NsSmartDeviceLink::NsJSONHandler
+} // namespace NsSmartDeviceLink::NsJSONHandler::Formatters
-#endif // __SMARTDEVICELINKCORE_JSONHANDLER_FORMATTERS_METAFORMATTER_H__
+#endif // __SMARTDEVICELINKCORE_JSONHANDLER_FORMATTERS_METAFORMATTER_H__
diff --git a/src/components/formatters/src/CFormatterJsonBase.cpp b/src/components/formatters/src/CFormatterJsonBase.cc
index 64a60e4f8f..0a85a93d21 100644
--- a/src/components/formatters/src/CFormatterJsonBase.cpp
+++ b/src/components/formatters/src/CFormatterJsonBase.cc
@@ -32,12 +32,12 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#include "json/json.h"
+#include "formatters/CFormatterJsonBase.h"
+#include "utils/convert_utils.h"
-#include "formatters/CFormatterJsonBase.hpp"
-
-void NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonBase::jsonValueToObj(
- const Json::Value& value,
- NsSmartDeviceLink::NsSmartObjects::SmartObject& obj) {
+void NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonBase::
+ jsonValueToObj(const Json::Value& value,
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& obj) {
try {
if (value.type() == Json::objectValue) {
obj = NsSmartDeviceLink::NsSmartObjects::SmartObject(
@@ -55,9 +55,10 @@ void NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonBase::jsonValue
for (uint32_t i = 0; i < value.size(); i++) {
jsonValueToObj(value[i], obj[i]);
}
- } else if (value.type() == Json::intValue
- || value.type() == Json::uintValue) {
- obj = value.asInt();
+ } else if (value.type() == Json::intValue) {
+ obj = utils::ConvertLongLongIntToInt64(value.asInt64());
+ } else if (value.type() == Json::uintValue) {
+ obj = utils::ConvertLongLongUIntToUInt64(value.asUInt64());
} else if (value.type() == Json::realValue) {
obj = value.asDouble();
} else if (value.type() == Json::booleanValue) {
@@ -71,9 +72,9 @@ void NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonBase::jsonValue
// ----------------------------------------------------------------------------
-void NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonBase::objToJsonValue(
- const NsSmartDeviceLink::NsSmartObjects::SmartObject &obj,
- Json::Value &item) {
+void NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonBase::
+ objToJsonValue(const NsSmartDeviceLink::NsSmartObjects::SmartObject& obj,
+ Json::Value& item) {
try {
if (NsSmartDeviceLink::NsSmartObjects::SmartType_Array == obj.getType()) {
item = Json::arrayValue;
@@ -85,30 +86,34 @@ void NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonBase::objToJson
item.append(value);
}
- } else if (NsSmartDeviceLink::NsSmartObjects::SmartType_Map
- == obj.getType()) {
+ } else if (NsSmartDeviceLink::NsSmartObjects::SmartType_Map ==
+ obj.getType()) {
item = Json::objectValue;
std::set<std::string> keys = obj.enumerate();
for (std::set<std::string>::const_iterator key = keys.begin();
- key != keys.end(); key++) {
+ key != keys.end();
+ key++) {
Json::Value value(Json::nullValue);
objToJsonValue(obj.getElement(*key), value);
item[*key] = value;
}
- } else if (NsSmartDeviceLink::NsSmartObjects::SmartType_Boolean
- == obj.getType()) {
+ } else if (NsSmartDeviceLink::NsSmartObjects::SmartType_Boolean ==
+ obj.getType()) {
item = obj.asBool();
- } else if (NsSmartDeviceLink::NsSmartObjects::SmartType_Integer
- == obj.getType()) {
- item = obj.asInt();
- } else if (NsSmartDeviceLink::NsSmartObjects::SmartType_Double
- == obj.getType()) {
+ } else if (NsSmartDeviceLink::NsSmartObjects::SmartType_Integer ==
+ obj.getType()) {
+ item = utils::ConvertInt64ToLongLongInt(obj.asInt());
+ } else if (NsSmartDeviceLink::NsSmartObjects::SmartType_UInteger ==
+ obj.getType()) {
+ item = utils::ConvertUInt64ToLongLongUInt(obj.asUInt());
+ } else if (NsSmartDeviceLink::NsSmartObjects::SmartType_Double ==
+ obj.getType()) {
item = obj.asDouble();
- } else if (NsSmartDeviceLink::NsSmartObjects::SmartType_Null
- == obj.getType()) {
+ } else if (NsSmartDeviceLink::NsSmartObjects::SmartType_Null ==
+ obj.getType()) {
item = Json::nullValue;
} else {
item = obj.asString();
diff --git a/src/components/formatters/src/CFormatterJsonSDLRPCv1.cpp b/src/components/formatters/src/CFormatterJsonSDLRPCv1.cc
index 407a001883..b776b9abd8 100644
--- a/src/components/formatters/src/CFormatterJsonSDLRPCv1.cpp
+++ b/src/components/formatters/src/CFormatterJsonSDLRPCv1.cc
@@ -1,34 +1,38 @@
-// Copyright (c) 2013, Ford Motor Company
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// Redistributions of source code must retain the above copyright notice, this
-// list of conditions and the following disclaimer.
-//
-// Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided with the
-// distribution.
-//
-// Neither the name of the Ford Motor Company nor the names of its contributors
-// may be used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-#include "formatters/CFormatterJsonSDLRPCv1.hpp"
+/*
+ * Copyright (c) 2015, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "formatters/CFormatterJsonSDLRPCv1.h"
#include "formatters/meta_formatter.h"
+#include "utils/convert_utils.h"
namespace strings = NsSmartDeviceLink::NsJSONHandler::strings;
namespace smart_objects_ns = NsSmartDeviceLink::NsSmartObjects;
@@ -55,7 +59,8 @@ const int32_t CFormatterJsonSDLRPCv1::kCorrelationIdNotFound = 1 << 3;
const std::string CFormatterJsonSDLRPCv1::getMessageType(
const smart_objects_ns::SmartObject& obj) {
- return obj.getElement(strings::S_PARAMS).getElement(strings::S_MESSAGE_TYPE)
+ return obj.getElement(strings::S_PARAMS)
+ .getElement(strings::S_MESSAGE_TYPE)
.asString();
}
@@ -87,7 +92,8 @@ bool CFormatterJsonSDLRPCv1::toString(const smart_objects_ns::SmartObject& obj,
Json::Value params(Json::objectValue);
smart_objects_ns::SmartObject formattedObj(obj);
- formattedObj.getSchema().unapplySchema(formattedObj); // converts enums(as int32_t) to strings
+ formattedObj.getSchema().unapplySchema(
+ formattedObj); // converts enums(as int32_t) to strings
objToJsonValue(formattedObj.getElement(strings::S_MSG_PARAMS), params);
@@ -96,12 +102,12 @@ bool CFormatterJsonSDLRPCv1::toString(const smart_objects_ns::SmartObject& obj,
root[type][S_PARAMETERS] = params;
if (formattedObj[strings::S_PARAMS].keyExists(strings::S_CORRELATION_ID)) {
- root[type][S_CORRELATION_ID] =
- formattedObj[strings::S_PARAMS][strings::S_CORRELATION_ID].asInt();
+ root[type][S_CORRELATION_ID] = utils::ConvertInt64ToLongLongInt(
+ formattedObj[strings::S_PARAMS][strings::S_CORRELATION_ID].asInt());
}
- root[type][S_NAME] = formattedObj[strings::S_PARAMS][strings::S_FUNCTION_ID]
- .asString();
+ root[type][S_NAME] =
+ formattedObj[strings::S_PARAMS][strings::S_FUNCTION_ID].asString();
outStr = root.toStyledString();
@@ -115,30 +121,33 @@ bool CFormatterJsonSDLRPCv1::toString(const smart_objects_ns::SmartObject& obj,
// ----------------------------------------------------------------------------
-CFormatterJsonSDLRPCv1::tMetaFormatterErrorCode CFormatterJsonSDLRPCv1::MetaFormatToString(
+CFormatterJsonSDLRPCv1::tMetaFormatterErrorCode
+CFormatterJsonSDLRPCv1::MetaFormatToString(
const smart_objects_ns::SmartObject& object,
- const smart_objects_ns::CSmartSchema& schema, std::string& outStr) {
+ const smart_objects_ns::CSmartSchema& schema,
+ std::string& outStr) {
meta_formatter_error_code::tMetaFormatterErrorCode result_code =
meta_formatter_error_code::kErrorOk;
smart_objects_ns::SmartObject tmp_object;
- if (false
- == CMetaFormatter::CreateObjectByPattern(object, schema, tmp_object)) {
+ if (false ==
+ CMetaFormatter::CreateObjectByPattern(object, schema, tmp_object)) {
result_code |= meta_formatter_error_code::kErrorFailedCreateObjectBySchema;
return result_code;
}
// determine whether smart objects are functions
// (in terms of SDLRPC communication)
- bool is_root_object_created_by_schema = ((tmp_object.getType()
- == smart_objects_ns::SmartType_Map)
- && tmp_object.keyExists(strings::S_PARAMS)
- && tmp_object.keyExists(strings::S_MSG_PARAMS));
+ bool is_root_object_created_by_schema =
+ ((tmp_object.getType() == smart_objects_ns::SmartType_Map) &&
+ tmp_object.keyExists(strings::S_PARAMS) &&
+ tmp_object.keyExists(strings::S_MSG_PARAMS));
- bool is_root_object = ((object.getType() == smart_objects_ns::SmartType_Map)
- && object.keyExists(strings::S_PARAMS)
- && object.keyExists(strings::S_MSG_PARAMS));
+ bool is_root_object =
+ ((object.getType() == smart_objects_ns::SmartType_Map) &&
+ object.keyExists(strings::S_PARAMS) &&
+ object.keyExists(strings::S_MSG_PARAMS));
if (false == is_root_object) {
result_code |= meta_formatter_error_code::kErrorObjectIsNotFunction;
@@ -151,7 +160,6 @@ CFormatterJsonSDLRPCv1::tMetaFormatterErrorCode CFormatterJsonSDLRPCv1::MetaForm
return result_code;
}
-
}
}
}
diff --git a/src/components/formatters/src/CFormatterJsonSDLRPCv2.cpp b/src/components/formatters/src/CFormatterJsonSDLRPCv2.cc
index d76e28911c..9e177ea4a8 100644
--- a/src/components/formatters/src/CFormatterJsonSDLRPCv2.cpp
+++ b/src/components/formatters/src/CFormatterJsonSDLRPCv2.cc
@@ -28,7 +28,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
-#include "formatters/CFormatterJsonSDLRPCv2.hpp"
+#include "formatters/CFormatterJsonSDLRPCv2.h"
#include "formatters/meta_formatter.h"
namespace smart_objects_ns = NsSmartDeviceLink::NsSmartObjects;
@@ -47,7 +47,8 @@ bool CFormatterJsonSDLRPCv2::toString(const smart_objects_ns::SmartObject& obj,
Json::Value root(Json::objectValue);
smart_objects_ns::SmartObject formattedObj(obj);
- formattedObj.getSchema().unapplySchema(formattedObj); // converts enums(as int32_t) to strings
+ formattedObj.getSchema().unapplySchema(
+ formattedObj); // converts enums(as int32_t) to strings
objToJsonValue(formattedObj.getElement(strings::S_MSG_PARAMS), root);
@@ -63,31 +64,33 @@ bool CFormatterJsonSDLRPCv2::toString(const smart_objects_ns::SmartObject& obj,
// ----------------------------------------------------------------------------
-CFormatterJsonSDLRPCv2::tMetaFormatterErrorCode CFormatterJsonSDLRPCv2::MetaFormatToString(
+CFormatterJsonSDLRPCv2::tMetaFormatterErrorCode
+CFormatterJsonSDLRPCv2::MetaFormatToString(
const smart_objects_ns::SmartObject& object,
- const smart_objects_ns::CSmartSchema& schema, std::string& outStr) {
-
+ const smart_objects_ns::CSmartSchema& schema,
+ std::string& outStr) {
meta_formatter_error_code::tMetaFormatterErrorCode result_code =
meta_formatter_error_code::kErrorOk;
smart_objects_ns::SmartObject tmp_object;
- if (false
- == CMetaFormatter::CreateObjectByPattern(object, schema, tmp_object)) {
+ if (false ==
+ CMetaFormatter::CreateObjectByPattern(object, schema, tmp_object)) {
result_code |= meta_formatter_error_code::kErrorFailedCreateObjectBySchema;
return result_code;
}
// determine whether smart objects are functions
// (in terms of SDLRPC communication)
- bool is_root_object_created_by_schema = ((tmp_object.getType()
- == smart_objects_ns::SmartType_Map)
- && tmp_object.keyExists(strings::S_PARAMS)
- && tmp_object.keyExists(strings::S_MSG_PARAMS));
+ bool is_root_object_created_by_schema =
+ ((tmp_object.getType() == smart_objects_ns::SmartType_Map) &&
+ tmp_object.keyExists(strings::S_PARAMS) &&
+ tmp_object.keyExists(strings::S_MSG_PARAMS));
- bool is_root_object = ((object.getType() == smart_objects_ns::SmartType_Map)
- && object.keyExists(strings::S_PARAMS)
- && object.keyExists(strings::S_MSG_PARAMS));
+ bool is_root_object =
+ ((object.getType() == smart_objects_ns::SmartType_Map) &&
+ object.keyExists(strings::S_PARAMS) &&
+ object.keyExists(strings::S_MSG_PARAMS));
if (false == is_root_object) {
result_code |= meta_formatter_error_code::kErrorObjectIsNotFunction;
@@ -100,7 +103,6 @@ CFormatterJsonSDLRPCv2::tMetaFormatterErrorCode CFormatterJsonSDLRPCv2::MetaForm
return result_code;
}
-
}
}
}
diff --git a/src/components/formatters/src/CSmartFactory.cpp b/src/components/formatters/src/CSmartFactory.cc
index 363db7696e..6b0808fbfa 100644
--- a/src/components/formatters/src/CSmartFactory.cpp
+++ b/src/components/formatters/src/CSmartFactory.cc
@@ -32,15 +32,21 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
-#include "formatters/CSmartFactory.hpp"
+#include "formatters/CSmartFactory.h"
-const std::string NsSmartDeviceLink::NsJSONHandler::strings::S_MSG_PARAMS("msg_params");
+const std::string NsSmartDeviceLink::NsJSONHandler::strings::S_MSG_PARAMS(
+ "msg_params");
const std::string NsSmartDeviceLink::NsJSONHandler::strings::S_PARAMS("params");
-const std::string NsSmartDeviceLink::NsJSONHandler::strings::S_FUNCTION_ID("function_id");
-const std::string NsSmartDeviceLink::NsJSONHandler::strings::S_MESSAGE_TYPE("message_type");
-const std::string NsSmartDeviceLink::NsJSONHandler::strings::S_PROTOCOL_VERSION("protocol_version");
-const std::string NsSmartDeviceLink::NsJSONHandler::strings::S_PROTOCOL_TYPE("protocol_type");
-const std::string NsSmartDeviceLink::NsJSONHandler::strings::S_CORRELATION_ID("correlation_id");
+const std::string NsSmartDeviceLink::NsJSONHandler::strings::S_FUNCTION_ID(
+ "function_id");
+const std::string NsSmartDeviceLink::NsJSONHandler::strings::S_MESSAGE_TYPE(
+ "message_type");
+const std::string NsSmartDeviceLink::NsJSONHandler::strings::S_PROTOCOL_VERSION(
+ "protocol_version");
+const std::string NsSmartDeviceLink::NsJSONHandler::strings::S_PROTOCOL_TYPE(
+ "protocol_type");
+const std::string NsSmartDeviceLink::NsJSONHandler::strings::S_CORRELATION_ID(
+ "correlation_id");
const std::string NsSmartDeviceLink::NsJSONHandler::strings::kCode("code");
const std::string NsSmartDeviceLink::NsJSONHandler::strings::kMessage(
"message");
diff --git a/src/components/formatters/src/formatter_json_rpc.cc b/src/components/formatters/src/formatter_json_rpc.cc
index 012962bbb2..e349ced4d6 100644
--- a/src/components/formatters/src/formatter_json_rpc.cc
+++ b/src/components/formatters/src/formatter_json_rpc.cc
@@ -33,6 +33,7 @@
// POSSIBILITY OF SUCH DAMAGE.
#include "formatters/formatter_json_rpc.h"
+#include "utils/convert_utils.h"
namespace NsSmartDeviceLink {
namespace NsJSONHandler {
@@ -40,23 +41,23 @@ namespace Formatters {
namespace strings = NsJSONHandler::strings;
-const char *FormatterJsonRpc::kRequest = "request";
-const char *FormatterJsonRpc::kResponse = "response";
-const char *FormatterJsonRpc::kNotification = "notification";
-const char *FormatterJsonRpc::kErrorResponse = "error_response";
-const char *FormatterJsonRpc::kJsonRpc = "jsonrpc";
-const char *FormatterJsonRpc::kJsonRpcExpectedValue = "2.0";
-const char *FormatterJsonRpc::kId = "id";
-const char *FormatterJsonRpc::kMethod = "method";
-const char *FormatterJsonRpc::kParams = "params";
-const char *FormatterJsonRpc::kResult = "result";
-const char *FormatterJsonRpc::kError = "error";
-const char *FormatterJsonRpc::kCode = "code";
-const char *FormatterJsonRpc::kData = "data";
-const char *FormatterJsonRpc::kMessage = "message";
-
-bool FormatterJsonRpc::ToString(const NsSmartObjects::SmartObject &obj,
- std::string &out_str) {
+const char* FormatterJsonRpc::kRequest = "request";
+const char* FormatterJsonRpc::kResponse = "response";
+const char* FormatterJsonRpc::kNotification = "notification";
+const char* FormatterJsonRpc::kErrorResponse = "error_response";
+const char* FormatterJsonRpc::kJsonRpc = "jsonrpc";
+const char* FormatterJsonRpc::kJsonRpcExpectedValue = "2.0";
+const char* FormatterJsonRpc::kId = "id";
+const char* FormatterJsonRpc::kMethod = "method";
+const char* FormatterJsonRpc::kParams = "params";
+const char* FormatterJsonRpc::kResult = "result";
+const char* FormatterJsonRpc::kError = "error";
+const char* FormatterJsonRpc::kCode = "code";
+const char* FormatterJsonRpc::kData = "data";
+const char* FormatterJsonRpc::kMessage = "message";
+
+bool FormatterJsonRpc::ToString(const NsSmartObjects::SmartObject& obj,
+ std::string& out_str) {
bool result = true;
try {
Json::Value root(Json::objectValue);
@@ -70,8 +71,8 @@ bool FormatterJsonRpc::ToString(const NsSmartObjects::SmartObject &obj,
bool is_message_params = formatted_object.keyExists(strings::S_MSG_PARAMS);
bool empty_message_params = true;
if (true == is_message_params) {
- const NsSmartObjects::SmartObject &msg_params = formatted_object
- .getElement(strings::S_MSG_PARAMS);
+ const NsSmartObjects::SmartObject& msg_params =
+ formatted_object.getElement(strings::S_MSG_PARAMS);
result = (NsSmartObjects::SmartType_Map == msg_params.getType());
if (true == result) {
@@ -85,13 +86,13 @@ bool FormatterJsonRpc::ToString(const NsSmartObjects::SmartObject &obj,
if (false == formatted_object.keyExists(strings::S_PARAMS)) {
result = false;
} else {
- const NsSmartObjects::SmartObject &params = formatted_object.getElement(
- strings::S_PARAMS);
+ const NsSmartObjects::SmartObject& params =
+ formatted_object.getElement(strings::S_PARAMS);
if (NsSmartObjects::SmartType_Map != params.getType()) {
result = false;
} else {
- const NsSmartObjects::SmartObject &message_type_object = params
- .getElement(strings::S_MESSAGE_TYPE);
+ const NsSmartObjects::SmartObject& message_type_object =
+ params.getElement(strings::S_MESSAGE_TYPE);
if (NsSmartObjects::SmartType_String != message_type_object.getType()) {
result = false;
@@ -112,13 +113,14 @@ bool FormatterJsonRpc::ToString(const NsSmartObjects::SmartObject &obj,
if (false == params.keyExists(strings::kCode)) {
result = false;
} else {
- const NsSmartObjects::SmartObject &code = params.getElement(
- strings::kCode);
+ const NsSmartObjects::SmartObject& code =
+ params.getElement(strings::kCode);
if (NsSmartObjects::SmartType_Integer != code.getType()) {
result = false;
} else {
- root[kResult][kCode] = code.asInt();
+ root[kResult][kCode] =
+ utils::ConvertInt64ToLongLongInt(code.asInt());
}
}
} else if (kNotification == message_type) {
@@ -129,12 +131,13 @@ bool FormatterJsonRpc::ToString(const NsSmartObjects::SmartObject &obj,
result = result && SetMethod(params, root[kError][kData]);
result = result && SetMessage(params, root[kError]);
- const NsSmartObjects::SmartObject &code = params.getElement(
- strings::kCode);
+ const NsSmartObjects::SmartObject& code =
+ params.getElement(strings::kCode);
if (NsSmartObjects::SmartType_Integer != code.getType()) {
result = false;
} else {
- root[kError][kCode] = code.asInt();
+ root[kError][kCode] =
+ utils::ConvertInt64ToLongLongInt(code.asInt());
}
}
}
@@ -148,12 +151,12 @@ bool FormatterJsonRpc::ToString(const NsSmartObjects::SmartObject &obj,
return result;
}
-bool FormatterJsonRpc::SetMethod(const NsSmartObjects::SmartObject &params,
- Json::Value &method_container) {
+bool FormatterJsonRpc::SetMethod(const NsSmartObjects::SmartObject& params,
+ Json::Value& method_container) {
bool result = false;
if (true == params.keyExists(strings::S_FUNCTION_ID)) {
- const NsSmartObjects::SmartObject &function_id =
+ const NsSmartObjects::SmartObject& function_id =
params.getElement(strings::S_FUNCTION_ID);
if (NsSmartObjects::SmartType_String == function_id.getType()) {
@@ -165,16 +168,16 @@ bool FormatterJsonRpc::SetMethod(const NsSmartObjects::SmartObject &params,
return result;
}
-bool FormatterJsonRpc::SetId(const NsSmartObjects::SmartObject &params,
- Json::Value &id_container) {
+bool FormatterJsonRpc::SetId(const NsSmartObjects::SmartObject& params,
+ Json::Value& id_container) {
bool result = false;
if (true == params.keyExists(strings::S_CORRELATION_ID)) {
- const NsSmartObjects::SmartObject &id = params.getElement(
- strings::S_CORRELATION_ID);
+ const NsSmartObjects::SmartObject& id =
+ params.getElement(strings::S_CORRELATION_ID);
if (NsSmartObjects::SmartType_Integer == id.getType()) {
- id_container[kId] = id.asUInt();
+ id_container[kId] = utils::ConvertUInt64ToLongLongUInt(id.asUInt());
result = true;
}
}
@@ -182,16 +185,16 @@ bool FormatterJsonRpc::SetId(const NsSmartObjects::SmartObject &params,
return result;
}
-bool FormatterJsonRpc::SetMessage(const NsSmartObjects::SmartObject &params,
- Json::Value &message_container) {
+bool FormatterJsonRpc::SetMessage(const NsSmartObjects::SmartObject& params,
+ Json::Value& message_container) {
bool result = false;
if (true == params.keyExists(strings::kMessage)) {
- const NsSmartObjects::SmartObject &message = params.getElement(
- strings::kMessage);
+ const NsSmartObjects::SmartObject& message =
+ params.getElement(strings::kMessage);
if (NsSmartObjects::SmartType_String == message.getType()) {
- message_container[kMessage] = message.asString();
+ message_container[kMessage] = message.asString();
result = true;
}
}
diff --git a/src/components/formatters/src/generic_json_formatter.cc b/src/components/formatters/src/generic_json_formatter.cc
index 6cc2266193..7789a915c2 100644
--- a/src/components/formatters/src/generic_json_formatter.cc
+++ b/src/components/formatters/src/generic_json_formatter.cc
@@ -58,6 +58,6 @@ bool GenericJsonFormatter::FromString(const std::string& str,
return result;
}
-} // namespace Formatters
-} // namespace NsJSONHandler
-} // namespace NsSmartDeviceLink
+} // namespace Formatters
+} // namespace NsJSONHandler
+} // namespace NsSmartDeviceLink
diff --git a/src/components/formatters/src/meta_formatter.cc b/src/components/formatters/src/meta_formatter.cc
index 8b24fd4b0e..fafb84e938 100644
--- a/src/components/formatters/src/meta_formatter.cc
+++ b/src/components/formatters/src/meta_formatter.cc
@@ -47,14 +47,13 @@ bool formatter_ns::CMetaFormatter::CreateObjectByPattern(
const NsSmartDeviceLink::NsSmartObjects::SmartObject& object,
const NsSmartDeviceLink::NsSmartObjects::CSmartSchema& schema,
NsSmartDeviceLink::NsSmartObjects::SmartObject& result_object) {
-
if (smart_objects_ns::SmartType_Invalid == result_object.getType()) {
return false;
}
-
+
schema.BuildObjectBySchema(object, result_object);
result_object.setSchema(schema);
return true;
-}
+}
diff --git a/src/components/formatters/test/CFormatterJsonBase_test.cc b/src/components/formatters/test/CFormatterJsonBase_test.cc
index 9efbfdcf77..ff1f60b8df 100644
--- a/src/components/formatters/test/CFormatterJsonBase_test.cc
+++ b/src/components/formatters/test/CFormatterJsonBase_test.cc
@@ -35,7 +35,7 @@
#include "json/value.h"
#include "gtest/gtest.h"
#include "json/reader.h"
-#include "formatters/CFormatterJsonBase.hpp"
+#include "formatters/CFormatterJsonBase.h"
#include "formatters/generic_json_formatter.h"
namespace test {
@@ -100,10 +100,12 @@ TEST(CFormatterJsonBaseTest, JSonSignedMaxIntValueToSmartObj_ExpectSuccessful) {
EXPECT_EQ(ival, object.asInt());
}
-TEST(CFormatterJsonBaseTest, DISABLED_JSonUnsignedMaxIntValueToSmartObj_ExpectSuccessful) {
+TEST(CFormatterJsonBaseTest,
+ JSonUnsignedMaxIntValueToSmartObj_ExpectSuccessful) {
// Arrange value
Json::UInt ui_val = Json::Value::maxUInt;
- Json::Value json_value(ui_val); // Json value from maximum possible unsigned int
+ Json::Value json_value(
+ ui_val); // Json value from maximum possible unsigned int
SmartObject object;
// Convert json to smart object
CFormatterJsonBase::jsonValueToObj(json_value, object);
@@ -111,15 +113,26 @@ TEST(CFormatterJsonBaseTest, DISABLED_JSonUnsignedMaxIntValueToSmartObj_ExpectSu
EXPECT_EQ(ui_val, object.asUInt());
}
-TEST(CFormatterJsonBaseTest, JSonSignedMaxInt64ValueToSmartObj_ExpectFailed) {
+TEST(CFormatterJsonBaseTest, JSonSignedMaxInt64ValueToSmartObj_ExpectSuccess) {
// Arrange value
Json::Int64 ival = Json::Value::maxInt64;
Json::Value json_value(ival); // Json value from maximum possible signed int
SmartObject object;
// Convert json to smart object
CFormatterJsonBase::jsonValueToObj(json_value, object);
+ // Check conversion was successful
+ EXPECT_EQ(ival, object.asInt());
+}
+
+TEST(CFormatterJsonBaseTest, JSonUnsignedMaxInt64ValueToSmartObj_ExpectFailed) {
+ // Arrange value
+ Json::UInt64 ival = Json::Value::maxUInt64;
+ Json::Value json_value(ival); // Json value from max possible unsigned int
+ SmartObject object;
+ // Convert json to smart object
+ CFormatterJsonBase::jsonValueToObj(json_value, object);
// Check conversion was not successful as there is no such conversion
- EXPECT_EQ(invalid_int64_value, object.asInt64());
+ EXPECT_EQ(invalid_int64_value, object.asInt());
}
TEST(CFormatterJsonBaseTest, JSonBoolValueToSmartObj_ExpectSuccessful) {
@@ -151,7 +164,8 @@ TEST(CFormatterJsonBaseTest, JSonCStringValueToSmartObj_ExpectSuccessful) {
TEST(CFormatterJsonBaseTest, JSonArrayValueToSmartObj_ExpectSuccessful) {
// Arrange value
- const char* json_array = "[\"test1\", \"test2\", \"test3\"]"; // Array in json format
+ const char* json_array =
+ "[\"test1\", \"test2\", \"test3\"]"; // Array in json format
Json::Value json_value; // Json value from array. Will be initialized later
SmartObject object;
Json::Reader reader; // Json reader - Needed for correct parsing
@@ -162,18 +176,21 @@ TEST(CFormatterJsonBaseTest, JSonArrayValueToSmartObj_ExpectSuccessful) {
// Check conversion was successful
EXPECT_TRUE(json_value.isArray());
EXPECT_EQ(3u, object.asArray()->size());
- SmartArray *ptr = NULL; // Smart Array pointer;
+ SmartArray* ptr = NULL; // Smart Array pointer;
EXPECT_NE(ptr, object.asArray());
}
TEST(CFormatterJsonBaseTest, JSonObjectValueToSmartObj_ExpectSuccessful) {
// Arrange value
const char* json_object =
- "{ \"json_test_object\": [\"test1\", \"test2\", \"test3\"], \"json_test_object2\": [\"test11\", \"test12\", \"test13\" ]}"; // Json object
+ "{ \"json_test_object\": [\"test1\", \"test2\", \"test3\"], "
+ "\"json_test_object2\": [\"test11\", \"test12\", \"test13\" ]}";
Json::Value json_value; // Json value from object. Will be initialized later
SmartObject object;
Json::Reader reader; // Json reader - Needed for correct parsing
- ASSERT_TRUE(reader.parse(json_object, json_value)); // If parsing not successful - no sense to continue
+ ASSERT_TRUE(reader.parse(
+ json_object,
+ json_value)); // If parsing not successful - no sense to continue
CFormatterJsonBase::jsonValueToObj(json_value, object);
// Check conversion was successful
EXPECT_TRUE(json_value.isObject());
@@ -193,7 +210,7 @@ TEST(CFormatterJsonBaseTest, JSonObjectValueToSmartObj_ExpectSuccessful) {
EXPECT_EQ(*it, *it1);
++it1;
}
- ASSERT(it == mems.end() && it1 == keys.end());
+ EXPECT_TRUE(it == mems.end() && it1 == keys.end());
}
TEST(CFormatterJsonBaseTest, StringSmartObjectToJSon_ExpectSuccessful) {
@@ -240,7 +257,7 @@ TEST(CFormatterJsonBaseTest, MinIntSmartObjectToJSon_ExpectSuccessful) {
EXPECT_EQ(ival, json_value.asInt());
}
-TEST(CFormatterJsonBaseTest, DISABLED_UnsignedMaxIntSmartObjectToJSon_ExpectSuccessful) {
+TEST(CFormatterJsonBaseTest, UnsignedMaxIntSmartObjectToJSon_ExpectSuccessful) {
// Arrange value
Json::UInt ui_val = Json::Value::maxUInt;
Json::Value json_value; // Json value from maximum unsigned int
@@ -280,13 +297,15 @@ TEST(CFormatterJsonBaseTest, CStringSmartObjectToJSon_ExpectSuccessful) {
TEST(CFormatterJsonBaseTest, ArraySmartObjectToJSon_ExpectSuccessful) {
// Arrange value
- const char* json_array = "[\"test1\", \"test2\", \"test3\"]"; // Array in json format
+ const char* json_array =
+ "[\"test1\", \"test2\", \"test3\"]"; // Array in json format
Json::Value json_value; // Json value from array. Will be initialized later
- Json::Value result; // Json value from array. Will be initialized later
+ Json::Value result; // Json value from array. Will be initialized later
SmartObject object;
Json::Reader reader; // Json reader - Needed for correct parsing
// Parse array to json value
- ASSERT_TRUE(reader.parse(json_array, json_value)); // Convert json array to SmartObject
+ ASSERT_TRUE(reader.parse(json_array,
+ json_value)); // Convert json array to SmartObject
// Convert json array to SmartObject
CFormatterJsonBase::jsonValueToObj(json_value, object);
// Convert SmartObject to JSon
@@ -299,13 +318,18 @@ TEST(CFormatterJsonBaseTest, ArraySmartObjectToJSon_ExpectSuccessful) {
TEST(CFormatterJsonBaseTest, JSonObjectValueToObj_ExpectSuccessful) {
// Arrange value
const char* json_object =
- "{ \"json_test_object\": [\"test1\", \"test2\", \"test3\"], \"json_test_object2\": [\"test11\", \"test12\", \"test13\" ]}"; // Json object
- Json::Value json_value; // Json value from json object. Will be initialized later
- Json::Value result; // Json value from Smart object. Will keep conversion result
+ "{ \"json_test_object\": [\"test1\", \"test2\", \"test3\"], "
+ "\"json_test_object2\": [\"test11\", \"test12\", \"test13\" ]}";
+ Json::Value
+ json_value; // Json value from json object. Will be initialized later
+ Json::Value
+ result; // Json value from Smart object. Will keep conversion result
SmartObject object;
Json::Reader reader; // Json reader - Needed for correct parsing
// Parse json object to correct json value
- ASSERT_TRUE(reader.parse(json_object, json_value)); // If parsing not successful - no sense to continue
+ ASSERT_TRUE(reader.parse(
+ json_object,
+ json_value)); // If parsing not successful - no sense to continue
// Convert json array to SmartObject
CFormatterJsonBase::jsonValueToObj(json_value, object);
// Convert SmartObject to JSon
@@ -329,7 +353,7 @@ TEST(CFormatterJsonBaseTest, JSonObjectValueToObj_ExpectSuccessful) {
EXPECT_EQ(*it, *it1);
++it1;
}
- ASSERT(it == mems.end() && it1 == keys.end());
+ EXPECT_TRUE(it == mems.end() && it1 == keys.end());
}
} // namespace formatters
diff --git a/src/components/formatters/test/CMakeLists.txt b/src/components/formatters/test/CMakeLists.txt
index b9966c8670..d245626dae 100644
--- a/src/components/formatters/test/CMakeLists.txt
+++ b/src/components/formatters/test/CMakeLists.txt
@@ -37,7 +37,7 @@ include_directories(
${COMPONENTS_DIR}/formatters/include
${COMPONENTS_DIR}/formatters/test/include
${CMAKE_BINARY_DIR}/src/components/interfaces
- ${CMAKE_SOURCE_DIR}/src/3rd_party-static/jsoncpp/include
+ ${JSONCPP_INCLUDE_DIRECTORY}
)
set(LIBRARIES
diff --git a/src/components/formatters/test/CSmartFactory_test.cc b/src/components/formatters/test/CSmartFactory_test.cc
index 41a77f1f1e..f98af88328 100644
--- a/src/components/formatters/test/CSmartFactory_test.cc
+++ b/src/components/formatters/test/CSmartFactory_test.cc
@@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "SmartFactoryTestHelper.h"
-#include "formatters/CSmartFactory.hpp"
+#include "formatters/SmartFactoryTestHelper.h"
+#include "formatters/CSmartFactory.h"
#include "gtest/gtest.h"
namespace test {
@@ -51,7 +51,8 @@ TEST(CSmartFactoryTest, CreateSmartFactory_ExpectCreated) {
EXPECT_EQ(2u, test_factory.structs_schemes().size());
}
-TEST(CSmartFactoryTest, CreateSmartObjWithSchema1_ExpectCreatedObjectToCorrespondSmSchema1) {
+TEST(CSmartFactoryTest,
+ CreateSmartObjWithSchema1_ExpectCreatedObjectToCorrespondSmSchema1) {
CSmartFactoryTest test_factory;
// Create SmartObject with attached SmartChmema
SmartObject obj = test_factory.CreateSmartObject(FunctionIdTest::Function1,
@@ -70,7 +71,8 @@ TEST(CSmartFactoryTest, CreateSmartObjWithSchema1_ExpectCreatedObjectToCorrespon
EXPECT_TRUE(obj.isValid());
}
-TEST(CSmartFactoryTest, CreateSmartObjWithNotExistedSchema_ExpectCreatedObjectNotValid) {
+TEST(CSmartFactoryTest,
+ CreateSmartObjWithNotExistedSchema_ExpectCreatedObjectNotValid) {
CSmartFactoryTest test_factory;
// Create SmartObject with attached SmartChmema
SmartObject obj = test_factory.CreateSmartObject(
@@ -81,7 +83,9 @@ TEST(CSmartFactoryTest, CreateSmartObjWithNotExistedSchema_ExpectCreatedObjectNo
EXPECT_TRUE(obj.isValid());
}
-TEST(CSmartFactoryTest, CreateSmartObjectWithSchema1_MissedOneField_ExpectCreatedNotCorrespondSmartSchema) {
+TEST(
+ CSmartFactoryTest,
+ CreateSmartObjectWithSchema1_MissedOneField_ExpectCreatedNotCorrespondSmartSchema) {
CSmartFactoryTest test_factory;
// Create SmartObject with attached SmartChmema
SmartObject obj = test_factory.CreateSmartObject(FunctionIdTest::Function1,
@@ -99,7 +103,9 @@ TEST(CSmartFactoryTest, CreateSmartObjectWithSchema1_MissedOneField_ExpectCreate
EXPECT_FALSE(obj.isValid());
}
-TEST(CSmartFactoryTest, CreateSmartObjectWithSchema1_AddOutOfRangeValue_ExpectCreatedNotCorrespondSmartSchema) {
+TEST(
+ CSmartFactoryTest,
+ CreateSmartObjectWithSchema1_AddOutOfRangeValue_ExpectCreatedNotCorrespondSmartSchema) {
CSmartFactoryTest test_factory;
// Create SmartObject with attached SmartChmema
SmartObject obj = test_factory.CreateSmartObject(FunctionIdTest::Function1,
@@ -118,7 +124,9 @@ TEST(CSmartFactoryTest, CreateSmartObjectWithSchema1_AddOutOfRangeValue_ExpectCr
EXPECT_FALSE(obj.isValid());
}
-TEST(CSmartFactoryTest, CreateSmartObjectWithSchema1_AddInvalidValue_ExpectCreatedNotCorrespondSmartSchema) {
+TEST(
+ CSmartFactoryTest,
+ CreateSmartObjectWithSchema1_AddInvalidValue_ExpectCreatedNotCorrespondSmartSchema) {
CSmartFactoryTest test_factory;
// Create SmartObject with attached SmartChmema
SmartObject obj = test_factory.CreateSmartObject(FunctionIdTest::Function1,
@@ -137,7 +145,8 @@ TEST(CSmartFactoryTest, CreateSmartObjectWithSchema1_AddInvalidValue_ExpectCreat
EXPECT_FALSE(obj.isValid());
}
-TEST(CSmartFactoryTest, CreateSmartObj_AttachSchema1_ExpectCreatedObjectCorrespondsSmSchema1) {
+TEST(CSmartFactoryTest,
+ CreateSmartObj_AttachSchema1_ExpectCreatedObjectCorrespondsSmSchema1) {
CSmartFactoryTest test_factory;
// Create empty SmartObject without any schema
SmartObject obj;
@@ -158,7 +167,9 @@ TEST(CSmartFactoryTest, CreateSmartObj_AttachSchema1_ExpectCreatedObjectCorrespo
EXPECT_TRUE(obj.isValid());
}
-TEST(CSmartFactoryTest, CreateSmartObj_AttachSchema1_MissOneField_ExpectCreatedObjectNotCorrespondsSmSchema1) {
+TEST(
+ CSmartFactoryTest,
+ CreateSmartObj_AttachSchema1_MissOneField_ExpectCreatedObjectNotCorrespondsSmSchema1) {
CSmartFactoryTest test_factory;
// Create empty SmartObject without any schema
SmartObject obj;
@@ -178,7 +189,8 @@ TEST(CSmartFactoryTest, CreateSmartObj_AttachSchema1_MissOneField_ExpectCreatedO
EXPECT_FALSE(obj.isValid());
}
-TEST(CSmartFactoryTest, CreateSmartObj_AttachNotExistedSchema_ExpectSmSchemaNotAttached) {
+TEST(CSmartFactoryTest,
+ CreateSmartObj_AttachNotExistedSchema_ExpectSmSchemaNotAttached) {
CSmartFactoryTest test_factory;
// Create empty SmartObject without any schema
SmartObject obj;
@@ -190,7 +202,9 @@ TEST(CSmartFactoryTest, CreateSmartObj_AttachNotExistedSchema_ExpectSmSchemaNotA
EXPECT_TRUE(SmartType::SmartType_Map == obj.getType());
}
-TEST(CSmartFactoryTest, CreateSmartObj_AttachSchema1_AddInvalidValue_ExpectCreatedObjectNotCorrespondsSmSchema1) {
+TEST(
+ CSmartFactoryTest,
+ CreateSmartObj_AttachSchema1_AddInvalidValue_ExpectCreatedObjectNotCorrespondsSmSchema1) {
CSmartFactoryTest test_factory;
// Create empty SmartObject without any schema
SmartObject obj;
@@ -211,7 +225,8 @@ TEST(CSmartFactoryTest, CreateSmartObj_AttachSchema1_AddInvalidValue_ExpectCreat
EXPECT_FALSE(obj.isValid());
}
-TEST(CSmartFactoryTest, CreateSmartObj_AttachSchema1_ExpectCreatedObjectCorrespondsSmSchema) {
+TEST(CSmartFactoryTest,
+ CreateSmartObj_AttachSchema1_ExpectCreatedObjectCorrespondsSmSchema) {
CSmartFactoryTest test_factory;
// Create empty SmartObject without any schema
SmartObject obj;
@@ -225,7 +240,9 @@ TEST(CSmartFactoryTest, CreateSmartObj_AttachSchema1_ExpectCreatedObjectCorrespo
EXPECT_TRUE(obj.isValid());
}
-TEST(CSmartFactoryTest, CreateSmartObj_AttachSchema1_OneMandatoryFieldMissed_ExpectCreatedObjectNotCorrespondsSmSchema) {
+TEST(
+ CSmartFactoryTest,
+ CreateSmartObj_AttachSchema1_OneMandatoryFieldMissed_ExpectCreatedObjectNotCorrespondsSmSchema) {
CSmartFactoryTest test_factory;
// Create empty SmartObject without any schema
SmartObject obj;
@@ -238,7 +255,8 @@ TEST(CSmartFactoryTest, CreateSmartObj_AttachSchema1_OneMandatoryFieldMissed_Exp
EXPECT_FALSE(obj.isValid());
}
-TEST(CSmartFactoryTest, CreateSmartObj_AttachSchema2_ExpectCreatedObjectCorrespondsSmSchema) {
+TEST(CSmartFactoryTest,
+ CreateSmartObj_AttachSchema2_ExpectCreatedObjectCorrespondsSmSchema) {
CSmartFactoryTest test_factory;
// Create empty SmartObject without any schema
SmartObject obj;
@@ -252,7 +270,8 @@ TEST(CSmartFactoryTest, CreateSmartObj_AttachSchema2_ExpectCreatedObjectCorrespo
EXPECT_TRUE(obj.isValid());
}
-TEST(CSmartFactoryTest, CreateSmartObj_AttachSchema_ExpectCreatedObjectCorrespondsSmSchema) {
+TEST(CSmartFactoryTest,
+ CreateSmartObj_AttachSchema_ExpectCreatedObjectCorrespondsSmSchema) {
CSmartFactoryTest test_factory;
// Create empty SmartObject without any schema
SmartObject obj;
@@ -269,11 +288,13 @@ TEST(CSmartFactoryTest, CreateSmartObj_AttachSchema_ExpectCreatedObjectCorrespon
EXPECT_TRUE(obj.isValid());
}
-TEST(CSmartFactoryTest, CreateSmartObj_WithSchemaFromStructId_ExpectCreatedObjectCorrespondsSmSchema) {
+TEST(
+ CSmartFactoryTest,
+ CreateSmartObj_WithSchemaFromStructId_ExpectCreatedObjectCorrespondsSmSchema) {
CSmartFactoryTest test_factory;
// Create empty SmartObject with schema correspopnding StructId
- SmartObject obj = test_factory.CreateSmartObject(
- StructIdentifiersTest::Common_1);
+ SmartObject obj =
+ test_factory.CreateSmartObject(StructIdentifiersTest::Common_1);
// Add fields
obj["text"] = "test";
obj["position"] = 200;
@@ -288,11 +309,13 @@ TEST(CSmartFactoryTest, CreateSmartObj_WithSchemaFromStructId_ExpectCreatedObjec
EXPECT_TRUE(obj.isValid());
}
-TEST(CSmartFactoryTest, CreateSmartObj_WithSchemaFromStructId_MissedOneField_ExpectCreatedObjectNotCorrespondsSmSchema) {
+TEST(
+ CSmartFactoryTest,
+ CreateSmartObj_WithSchemaFromStructId_MissedOneField_ExpectCreatedObjectNotCorrespondsSmSchema) {
CSmartFactoryTest test_factory;
// Create empty SmartObject with schema correspopnding StructId
- SmartObject obj = test_factory.CreateSmartObject(
- StructIdentifiersTest::Common_1);
+ SmartObject obj =
+ test_factory.CreateSmartObject(StructIdentifiersTest::Common_1);
// Add fields. One missed.
obj["text"] = "test";
obj["image"]["text"] = "test2";
@@ -306,11 +329,13 @@ TEST(CSmartFactoryTest, CreateSmartObj_WithSchemaFromStructId_MissedOneField_Exp
EXPECT_FALSE(obj.isValid());
}
-TEST(CSmartFactoryTest, CreateSmartObj_WithSchemaFromStructId2_ExpectCreatedObjectCorrespondsSmSchema) {
+TEST(
+ CSmartFactoryTest,
+ CreateSmartObj_WithSchemaFromStructId2_ExpectCreatedObjectCorrespondsSmSchema) {
CSmartFactoryTest test_factory;
// Create empty SmartObject with schema correspopnding StructId
- SmartObject obj = test_factory.CreateSmartObject(
- StructIdentifiersTest::Common_2);
+ SmartObject obj =
+ test_factory.CreateSmartObject(StructIdentifiersTest::Common_2);
// Add fields
obj["text"] = "test";
obj["position"] = 200;
@@ -325,11 +350,13 @@ TEST(CSmartFactoryTest, CreateSmartObj_WithSchemaFromStructId2_ExpectCreatedObje
EXPECT_TRUE(obj.isValid());
}
-TEST(CSmartFactoryTest, CreateSmartObj_WithSchemaFromStructId2_MissedOneField_ExpectCreatedObjectNotCorrespondsSmSchema) {
+TEST(
+ CSmartFactoryTest,
+ CreateSmartObj_WithSchemaFromStructId2_MissedOneField_ExpectCreatedObjectNotCorrespondsSmSchema) {
CSmartFactoryTest test_factory;
// Create empty SmartObject with schema correspopnding StructId
- SmartObject obj = test_factory.CreateSmartObject(
- StructIdentifiersTest::Common_2);
+ SmartObject obj =
+ test_factory.CreateSmartObject(StructIdentifiersTest::Common_2);
// Add fields. One missed.
obj["text"] = "test";
obj["image"]["text"] = "test2";
@@ -340,11 +367,13 @@ TEST(CSmartFactoryTest, CreateSmartObj_WithSchemaFromStructId2_MissedOneField_Ex
EXPECT_FALSE(obj.isValid());
}
-TEST(CSmartFactoryTest, CreateSmartObj_WithSchemaFromStructId2_InvalidValueAdded_ExpectCreatedObjectNotCorrespondsSmSchema) {
+TEST(
+ CSmartFactoryTest,
+ CreateSmartObj_WithSchemaFromStructId2_InvalidValueAdded_ExpectCreatedObjectNotCorrespondsSmSchema) {
CSmartFactoryTest test_factory;
// Create empty SmartObject with schema correspopnding StructId
- SmartObject obj = test_factory.CreateSmartObject(
- StructIdentifiersTest::Common_2);
+ SmartObject obj =
+ test_factory.CreateSmartObject(StructIdentifiersTest::Common_2);
// Add fields. One missed.
obj["text"] = 111;
obj["position"] = 200;
@@ -359,32 +388,34 @@ TEST(CSmartFactoryTest, CreateSmartObj_WithSchemaFromStructId2_InvalidValueAdded
TEST(CSmartFactoryTest, GetSchemaWithSmartFactory_ExpectReceivedSchema) {
CSmartFactoryTest test_factory;
CSmartSchema schema;
- EXPECT_TRUE(
- test_factory.GetSchema(FunctionIdTest::Function1,
- MessageTypeTest::request, schema));
+ EXPECT_TRUE(test_factory.GetSchema(
+ FunctionIdTest::Function1, MessageTypeTest::request, schema));
}
-TEST(CSmartFactoryTest, GetNotExistedSchemaWithSmartFactory_ExpectNotReceivedSchema) {
+TEST(CSmartFactoryTest,
+ GetNotExistedSchemaWithSmartFactory_ExpectNotReceivedSchema) {
CSmartFactoryTest test_factory;
CSmartSchema schema;
- EXPECT_FALSE(
- test_factory.GetSchema(FunctionIdTest::Function1,
- MessageTypeTest::INVALID_ENUM, schema));
+ EXPECT_FALSE(test_factory.GetSchema(
+ FunctionIdTest::Function1, MessageTypeTest::INVALID_ENUM, schema));
}
-TEST(CSmartFactoryTest, GetSchemaWithSmartFactoryWithStructId1_ExpectReceivedSchema) {
+TEST(CSmartFactoryTest,
+ GetSchemaWithSmartFactoryWithStructId1_ExpectReceivedSchema) {
CSmartFactoryTest test_factory;
CSmartSchema schema;
EXPECT_TRUE(test_factory.GetSchema(StructIdentifiersTest::Common_1, schema));
}
-TEST(CSmartFactoryTest, GetSchemaWithSmartFactoryWithStructId2_ExpectReceivedSchema) {
+TEST(CSmartFactoryTest,
+ GetSchemaWithSmartFactoryWithStructId2_ExpectReceivedSchema) {
CSmartFactoryTest test_factory;
CSmartSchema schema;
EXPECT_TRUE(test_factory.GetSchema(StructIdentifiersTest::Common_2, schema));
}
-TEST(CSmartFactoryTest, GetNotExistedSchemaWithSmartFactoryWithStructId_ExpectNotReceivedSchema) {
+TEST(CSmartFactoryTest,
+ GetNotExistedSchemaWithSmartFactoryWithStructId_ExpectNotReceivedSchema) {
CSmartFactoryTest test_factory;
CSmartSchema schema;
EXPECT_FALSE(
@@ -394,4 +425,3 @@ TEST(CSmartFactoryTest, GetNotExistedSchemaWithSmartFactoryWithStructId_ExpectNo
} // namespace formatters
} // namespace components
} // namespace test
-
diff --git a/src/components/formatters/test/cFormatterJsonSDLRPCv1_test.cc b/src/components/formatters/test/cFormatterJsonSDLRPCv1_test.cc
index 55b7f886fd..91701c8aab 100644
--- a/src/components/formatters/test/cFormatterJsonSDLRPCv1_test.cc
+++ b/src/components/formatters/test/cFormatterJsonSDLRPCv1_test.cc
@@ -32,8 +32,8 @@
#include "gtest/gtest.h"
-#include "formatters/CFormatterJsonSDLRPCv1.hpp"
-#include "create_smartSchema.h"
+#include "formatters/CFormatterJsonSDLRPCv1.h"
+#include "formatters/create_smartSchema.h"
namespace test {
namespace components {
@@ -89,7 +89,8 @@ TEST(CFormatterJsonSDLRPCv1Test, SmObjWithRequestWithoutMsgNotValid_ToString) {
EXPECT_EQ(expectOutputJsonString, jsonString);
}
-TEST(CFormatterJsonSDLRPCv1Test, SmObjWithRequestWithEmptyMsgWithTestSchemaToString) {
+TEST(CFormatterJsonSDLRPCv1Test,
+ SmObjWithRequestWithEmptyMsgWithTestSchemaToString) {
SmartObject srcObj;
CSmartSchema schema = initObjectSchema();
srcObj.setSchema(schema);
@@ -121,7 +122,8 @@ TEST(CFormatterJsonSDLRPCv1Test, SmObjWithRequestWithEmptyMsgWithTestSchemaToStr
EXPECT_EQ(expectOutputJsonString, jsonString);
}
-TEST(CFormatterJsonSDLRPCv1Test, SmObjWithRequestWithNonemptyMsgWithTestSchemaToString) {
+TEST(CFormatterJsonSDLRPCv1Test,
+ SmObjWithRequestWithNonemptyMsgWithTestSchemaToString) {
SmartObject srcObj;
CSmartSchema schema = initObjectSchema();
srcObj.setSchema(schema);
@@ -278,7 +280,8 @@ TEST(CFormatterJsonSDLRPCv1Test, SmObjWithResponseToString) {
EXPECT_EQ(expectOutputJsonString, jsonString);
}
-TEST(CFormatterJsonSDLRPCv1Test, SmObjWithResponseWithoutSchemaWithoutParamsToString) {
+TEST(CFormatterJsonSDLRPCv1Test,
+ SmObjWithResponseWithoutSchemaWithoutParamsToString) {
SmartObject srcObj;
srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::response;
std::string jsonString;
@@ -326,7 +329,8 @@ TEST(CFormatterJsonSDLRPCv1Test, StringRequestToSmObj) {
obj.setSchema(schema);
bool result = CFormatterJsonSDLRPCv1::fromString<FunctionIDTest::eType,
- MessageTypeTest::eType>(inputJsonString, obj);
+ MessageTypeTest::eType>(
+ inputJsonString, obj);
EXPECT_EQ(CFormatterJsonSDLRPCv1::kSuccess, result);
EXPECT_EQ(Errors::eType::OK, obj.validate());
@@ -369,7 +373,8 @@ TEST(CFormatterJsonSDLRPCv1Test, StringRequestWithoutNameToSmartObject) {
SmartObject obj;
bool result = CFormatterJsonSDLRPCv1::fromString<FunctionIDTest::eType,
- MessageTypeTest::eType>(inputJsonString, obj);
+ MessageTypeTest::eType>(
+ inputJsonString, obj);
EXPECT_EQ(CFormatterJsonSDLRPCv1::kParsingError, result);
@@ -410,7 +415,8 @@ TEST(CFormatterJsonSDLRPCv1Test, StringRequestWithIncorrectCorIDToSmartObject) {
SmartObject obj;
bool result = CFormatterJsonSDLRPCv1::fromString<FunctionIDTest::eType,
- MessageTypeTest::eType>(inputJsonString, obj);
+ MessageTypeTest::eType>(
+ inputJsonString, obj);
EXPECT_EQ(CFormatterJsonSDLRPCv1::kParsingError, result);
EXPECT_EQ(obj[S_PARAMS][S_MESSAGE_TYPE], MessageTypeTest::request);
@@ -440,7 +446,8 @@ TEST(CFormatterJsonSDLRPCv1Test, StringResponceToSmartObject) {
obj.setSchema(schema);
bool result = CFormatterJsonSDLRPCv1::fromString<FunctionIDTest::eType,
- MessageTypeTest::eType>(inputJsonString, obj);
+ MessageTypeTest::eType>(
+ inputJsonString, obj);
EXPECT_EQ(CFormatterJsonSDLRPCv1::kSuccess, result);
EXPECT_EQ(obj[S_PARAMS][S_MESSAGE_TYPE], MessageTypeTest::response);
EXPECT_EQ(obj[S_PARAMS][S_FUNCTION_ID], 0);
@@ -467,7 +474,8 @@ TEST(CFormatterJsonSDLRPCv1Test, StringNotificationToSmartObject) {
obj.setSchema(schema);
bool result = CFormatterJsonSDLRPCv1::fromString<FunctionIDTest::eType,
- MessageTypeTest::eType>(inputJsonString, obj);
+ MessageTypeTest::eType>(
+ inputJsonString, obj);
EXPECT_EQ(CFormatterJsonSDLRPCv1::kSuccess, result);
EXPECT_EQ(Errors::eType::OK, obj.validate());
EXPECT_EQ(obj[S_PARAMS][S_MESSAGE_TYPE], MessageTypeTest::notification);
@@ -497,6 +505,6 @@ TEST(CFormatterJsonSDLRPCv1Test, MetaFormatToString) {
EXPECT_EQ(meta_formatter_error_code::kErrorOk, result);
}
-} // namespace formatters
-} // namespace components
-} // namespace test
+} // namespace formatters
+} // namespace components
+} // namespace test
diff --git a/src/components/formatters/test/cFormatterJsonSDLRPCv2_test.cc b/src/components/formatters/test/cFormatterJsonSDLRPCv2_test.cc
index 814cff4ab7..feb7dd3129 100644
--- a/src/components/formatters/test/cFormatterJsonSDLRPCv2_test.cc
+++ b/src/components/formatters/test/cFormatterJsonSDLRPCv2_test.cc
@@ -31,8 +31,8 @@
*/
#include "gtest/gtest.h"
-#include "create_smartSchema.h"
-#include "formatters/CFormatterJsonSDLRPCv2.hpp"
+#include "formatters/create_smartSchema.h"
+#include "formatters/CFormatterJsonSDLRPCv2.h"
namespace test {
namespace components {
@@ -75,7 +75,8 @@ TEST(CFormatterJsonSDLRPCv2Test, SmObjWithRequestWithoutMsgNotValid_ToString) {
EXPECT_EQ(expectOutputJsonString, jsonString);
}
-TEST(CFormatterJsonSDLRPCv2Test, SmObjWithRequestWithEmptyMsgWithTestSchemaToString) {
+TEST(CFormatterJsonSDLRPCv2Test,
+ SmObjWithRequestWithEmptyMsgWithTestSchemaToString) {
SmartObject srcObj;
CSmartSchema schema = initObjectSchema();
srcObj.setSchema(schema);
@@ -100,7 +101,8 @@ TEST(CFormatterJsonSDLRPCv2Test, SmObjWithRequestWithEmptyMsgWithTestSchemaToStr
EXPECT_EQ(expectOutputJsonString, jsonString);
}
-TEST(CFormatterJsonSDLRPCv2Test, SmObjWithRequestWithNonemptyMsgWithTestSchemaToString) {
+TEST(CFormatterJsonSDLRPCv2Test,
+ SmObjWithRequestWithNonemptyMsgWithTestSchemaToString) {
SmartObject srcObj;
CSmartSchema schema = initObjectSchema();
srcObj.setSchema(schema);
@@ -216,7 +218,8 @@ TEST(CFormatterJsonSDLRPCv2Test, SmObjWithResponseToString) {
EXPECT_EQ(expectOutputJsonString, jsonString);
}
-TEST(CFormatterJsonSDLRPCv2Test, SmObjWithResponseWithoutSchemaWithoutParamsToString) {
+TEST(CFormatterJsonSDLRPCv2Test,
+ SmObjWithResponseWithoutSchemaWithoutParamsToString) {
SmartObject srcObj;
srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::response;
std::string jsonString;
@@ -252,9 +255,11 @@ TEST(CFormatterJsonSDLRPCv2Test, StringRequestWithoutCorIdToSmObj) {
obj.setSchema(schema);
bool result = CFormatterJsonSDLRPCv2::fromString<FunctionIDTest::eType,
- MessageTypeTest::eType>(inputJsonString, obj,
- FunctionIDTest::RegisterAppInterface,
- MessageTypeTest::request);
+ MessageTypeTest::eType>(
+ inputJsonString,
+ obj,
+ FunctionIDTest::RegisterAppInterface,
+ MessageTypeTest::request);
EXPECT_EQ(true, result);
EXPECT_EQ(Errors::eType::MISSING_MANDATORY_PARAMETER, obj.validate());
@@ -294,9 +299,12 @@ TEST(CFormatterJsonSDLRPCv2Test, StringRequestWithCorIdToSmObj) {
obj.setSchema(schema);
int32_t corId = 10;
bool result = CFormatterJsonSDLRPCv2::fromString<FunctionIDTest::eType,
- MessageTypeTest::eType>(inputJsonString, obj,
- FunctionIDTest::RegisterAppInterface,
- MessageTypeTest::request, corId);
+ MessageTypeTest::eType>(
+ inputJsonString,
+ obj,
+ FunctionIDTest::RegisterAppInterface,
+ MessageTypeTest::request,
+ corId);
EXPECT_EQ(true, result);
EXPECT_EQ(Errors::eType::OK, obj.validate());
@@ -328,9 +336,12 @@ TEST(CFormatterJsonSDLRPCv2Test, StringResponceWithCorIdToSmartObject) {
obj.setSchema(schema);
int32_t corId = 10;
bool result = CFormatterJsonSDLRPCv2::fromString<FunctionIDTest::eType,
- MessageTypeTest::eType>(inputJsonString, obj,
- FunctionIDTest::RegisterAppInterface,
- MessageTypeTest::response, corId);
+ MessageTypeTest::eType>(
+ inputJsonString,
+ obj,
+ FunctionIDTest::RegisterAppInterface,
+ MessageTypeTest::response,
+ corId);
EXPECT_EQ(true, result);
EXPECT_EQ(obj[S_PARAMS][S_MESSAGE_TYPE], MessageTypeTest::response);
@@ -354,9 +365,12 @@ TEST(CFormatterJsonSDLRPCv2Test, StringNotificationToSmartObject) {
obj.setSchema(schema);
int32_t corId = 10;
bool result = CFormatterJsonSDLRPCv2::fromString<FunctionIDTest::eType,
- MessageTypeTest::eType>(inputJsonString, obj,
- FunctionIDTest::SetGlobalProperties,
- MessageTypeTest::notification, corId);
+ MessageTypeTest::eType>(
+ inputJsonString,
+ obj,
+ FunctionIDTest::SetGlobalProperties,
+ MessageTypeTest::notification,
+ corId);
EXPECT_EQ(true, result);
EXPECT_EQ(Errors::eType::OK, obj.validate());
EXPECT_EQ(obj[S_PARAMS][S_MESSAGE_TYPE], MessageTypeTest::notification);
diff --git a/src/components/formatters/test/formatter_json_rpc_test.cc b/src/components/formatters/test/formatter_json_rpc_test.cc
index 9047d6790a..c2b0d73394 100644
--- a/src/components/formatters/test/formatter_json_rpc_test.cc
+++ b/src/components/formatters/test/formatter_json_rpc_test.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Ford Motor Company
+ * Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,21 +31,65 @@
*/
#include <algorithm>
+#include "formatters/formatter_json_rpc.h"
+#include <string>
+#include <set>
+#include <algorithm>
+#include <json/writer.h>
#include "gtest/gtest.h"
#include "formatters/formatter_json_rpc.h"
-#include "formatters/CSmartFactory.hpp"
+#include <string>
+#include <set>
+#include "gtest/gtest.h"
+#include "formatters/CSmartFactory.h"
#include "HMI_API_schema.h"
#include "MOBILE_API_schema.h"
namespace test {
namespace components {
-namespace formatters {
+namespace formatters_test {
using namespace NsSmartDeviceLink::NsSmartObjects;
using namespace NsSmartDeviceLink::NsJSONHandler::Formatters;
using namespace NsSmartDeviceLink::NsJSONHandler::strings;
-TEST(FormatterJsonRPCTest, CorrectRPCv1_request_SmartObjectToString_EXPECT_SUCCESS) {
+void CompactJson(std::string& str) {
+ Json::Value root;
+ Json::Reader reader;
+ reader.parse(str, root);
+ Json::FastWriter writer;
+ str = writer.write(root);
+ if (str[str.size() - 1] == '\n') {
+ str.erase(str.size() - 1, 1);
+ }
+}
+
+namespace {
+const int64_t big_64int = 100000000000;
+const std::string str_with_big_int64 = "100000000000";
+} // namespace
+
+TEST(FormatterJsonRPCTest, CheckCompactJson) {
+ std::string before_compact(
+ "{\n \"jsonrpc\" : \"2.0\",\n \"method\" : "
+ "\"BasicCommunication.OnSystemRequest\","
+ "\n \"params\" : {\n \"fileName\" : \"file \n Name\",\n "
+ "\"length\" : 100000000000,\n"
+ "\"offset\" : 100000000000,\n \"requestType\" : \"PROPRIETARY\"\n "
+ "}\n}\n");
+ std::string after_compact = before_compact;
+ CompactJson(after_compact);
+
+ EXPECT_NE(before_compact, after_compact);
+
+ std::string expected(
+ "{\"jsonrpc\":\"2.0\",\"method\":\"BasicCommunication.OnSystemRequest\","
+ "\"params\":{\"fileName\":\"file \\n Name\",\"length\":100000000000,"
+ "\"offset\":100000000000,\"requestType\":\"PROPRIETARY\"}}");
+ EXPECT_EQ(expected, after_compact);
+}
+
+TEST(FormatterJsonRPCTest, CorrectRPCv1Request_ToString_Success) {
// Create SmartObject
SmartObject obj;
obj[S_PARAMS][S_FUNCTION_ID] = hmi_apis::FunctionID::VR_IsReady;
@@ -59,15 +103,15 @@ TEST(FormatterJsonRPCTest, CorrectRPCv1_request_SmartObjectToString_EXPECT_SUCCE
EXPECT_TRUE(factory.attachSchema(obj, false));
std::string result;
- // Convert SmrtObject to Json string
+ // Convert SmartObject to Json string
EXPECT_TRUE(FormatterJsonRpc::ToString(obj, result));
- EXPECT_EQ(
- std::string(
- "{\n \"id\" : 4444,\n \"jsonrpc\" : \"2.0\",\n \"method\" : \"VR.IsReady\"\n}\n"),
- result);
+ CompactJson(result);
+ const std::string json_string(
+ "{\"id\":4444,\"jsonrpc\":\"2.0\",\"method\":\"VR.IsReady\"}");
+ EXPECT_EQ(json_string, result);
}
-TEST(FormatterJsonRPCTest, CorrectRPCv2_request_SmartObjectToString_EXPECT_SUCCESS) {
+TEST(FormatterJsonRPCTest, CorrectRPCv2Request_ToString_Success) {
// Create SmartObject
SmartObject obj;
obj[S_PARAMS][S_FUNCTION_ID] = mobile_apis::FunctionID::AddCommandID;
@@ -79,15 +123,45 @@ TEST(FormatterJsonRPCTest, CorrectRPCv2_request_SmartObjectToString_EXPECT_SUCCE
EXPECT_TRUE(factory.attachSchema(obj, false));
std::string result;
- // Convert SmrtObject to Json string
+ // Convert SmartObject to Json string
+ EXPECT_TRUE(FormatterJsonRpc::ToString(obj, result));
+ CompactJson(result);
+ const std::string json_string(
+ "{\"id\":4444,\"jsonrpc\":\"2.0\",\"method\":\"AddCommandID\"}");
+ EXPECT_EQ(json_string, result);
+}
+
+TEST(FormatterJsonRPCTest, UpperBoundValuesInSystemRequest_ToString_Success) {
+ // Create SmartObject
+ SmartObject obj;
+ obj[S_PARAMS][S_FUNCTION_ID] =
+ hmi_apis::FunctionID::BasicCommunication_OnSystemRequest;
+ obj[S_PARAMS][S_MESSAGE_TYPE] = hmi_apis::messageType::notification;
+ obj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
+ obj[S_PARAMS][S_PROTOCOL_TYPE] = 1;
+ obj[S_PARAMS][S_CORRELATION_ID] = 4444;
+ obj[S_MSG_PARAMS] = SmartObject(SmartType::SmartType_Map);
+ obj[S_MSG_PARAMS]["requestType"] = hmi_apis::Common_RequestType::PROPRIETARY;
+ obj[S_MSG_PARAMS]["fileName"] = "fileName";
+ obj[S_MSG_PARAMS]["length"] = big_64int;
+ obj[S_MSG_PARAMS]["offset"] = big_64int;
+ // Attach Schema
+
+ hmi_apis::HMI_API factory;
+ EXPECT_TRUE(factory.attachSchema(obj, false));
+ EXPECT_EQ(Errors::OK, obj.validate());
+ std::string result;
+ // Convert SmartObject to Json string
EXPECT_TRUE(FormatterJsonRpc::ToString(obj, result));
- EXPECT_EQ(
- std::string(
- "{\n \"id\" : 4444,\n \"jsonrpc\" : \"2.0\",\n \"method\" : \"AddCommandID\"\n}\n"),
- result);
+ CompactJson(result);
+ const std::string json_string(
+ "{\"jsonrpc\":\"2.0\",\"method\":\"BasicCommunication.OnSystemRequest\","
+ "\"params\":{\"fileName\":\"fileName\",\"length\":100000000000,"
+ "\"offset\":100000000000,\"requestType\":\"PROPRIETARY\"}}");
+ EXPECT_EQ(json_string, result);
}
-TEST(FormatterJsonRPCTest, CorrectRPCv1_notification_SmartObjectToString_EXPECT_SUCCESS) {
+TEST(FormatterJsonRPCTest, CorrectRPCv1Notification_ToString_Success) {
// Create SmartObject
SmartObject obj;
std::string result;
@@ -100,20 +174,139 @@ TEST(FormatterJsonRPCTest, CorrectRPCv1_notification_SmartObjectToString_EXPECT_
// Attach Schema
hmi_apis::HMI_API factory;
EXPECT_TRUE(factory.attachSchema(obj, false));
- // Convert SmrtObject to Json string
+ // Convert SmartObject to Json string
+ EXPECT_TRUE(FormatterJsonRpc::ToString(obj, result));
+ CompactJson(result);
+ const std::string json_string(
+ "{\"jsonrpc\":\"2.0\",\"method\":\"Buttons.OnButtonPress\",\"params\":{}"
+ "}");
+ EXPECT_EQ(json_string, result);
+}
+
+TEST(FormatterJsonRPCTest, CorrectResponseToString_Success) {
+ // Create SmartObject
+ SmartObject obj;
+ obj[S_PARAMS][S_FUNCTION_ID] = hmi_apis::FunctionID::VR_AddCommand;
+ obj[S_PARAMS][S_MESSAGE_TYPE] = hmi_apis::messageType::response;
+ obj[S_PARAMS][S_CORRELATION_ID] = 4440;
+ obj[S_PARAMS][kCode] = hmi_apis::Common_Result::SUCCESS;
+ obj[S_MSG_PARAMS] = SmartObject(SmartType::SmartType_Map);
+ // Attach Schema
+ hmi_apis::HMI_API factory;
+ EXPECT_TRUE(factory.attachSchema(obj, false));
+
+ std::string result;
+ // Convert SmartObject to Json string
+ EXPECT_TRUE(FormatterJsonRpc::ToString(obj, result));
+ CompactJson(result);
+ const std::string json_string(
+ "{\"id\":4440,\"jsonrpc\":\"2.0\",\"result\":{\"code\":0,\"method\":\"VR."
+ "AddCommand\"}}");
+ EXPECT_EQ(json_string, result);
+}
+
+TEST(FormatterJsonRPCTest, ErrorResponse_ToString_Success) {
+ // Create SmartObject
+ SmartObject obj;
+ obj[S_PARAMS][S_FUNCTION_ID] = hmi_apis::FunctionID::VR_AddCommand;
+ obj[S_PARAMS][S_MESSAGE_TYPE] = hmi_apis::messageType::error_response;
+ obj[S_PARAMS][S_CORRELATION_ID] = 4440;
+ obj[S_PARAMS][kCode] = hmi_apis::Common_Result::GENERIC_ERROR;
+ obj[S_PARAMS][kMessage] = "Some error";
+ obj[S_MSG_PARAMS] = SmartObject(SmartType::SmartType_Map);
+ // Attach Schema
+ hmi_apis::HMI_API factory;
+ EXPECT_TRUE(factory.attachSchema(obj, false));
+
+ std::string result;
+ // Convert SmartObject to Json string
+ EXPECT_TRUE(FormatterJsonRpc::ToString(obj, result));
+ CompactJson(result);
+
+ const std::string json_string(
+ "{\"error\":{\"code\":22,\"data\":{\"method\":\"VR.AddCommand\"},"
+ "\"message\":\"Some error\"},\"id\":4440,\"jsonrpc\":\"2.0\"}");
+ EXPECT_EQ(json_string, result);
+}
+
+TEST(FormatterJsonRPCTest, ResponseWithoutCorID_ToString_Fail) {
+ // Create SmartObject
+ SmartObject obj;
+ obj[S_PARAMS][S_FUNCTION_ID] = hmi_apis::FunctionID::VR_AddCommand;
+ obj[S_PARAMS][S_MESSAGE_TYPE] = hmi_apis::messageType::response;
+ obj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
+ obj[S_PARAMS][S_PROTOCOL_TYPE] = 1;
+ obj[S_PARAMS][S_CORRELATION_ID] = 4444;
+ obj[S_MSG_PARAMS] = SmartObject(SmartType::SmartType_Map);
+ // Attach Schema
+ hmi_apis::HMI_API factory;
+ EXPECT_TRUE(factory.attachSchema(obj, false));
+
+ std::string result;
+ // Convert SmartObject to Json string will finish wrong
+ EXPECT_FALSE(FormatterJsonRpc::ToString(obj, result));
+}
+
+TEST(FormatterJsonRPCTest, RequestWithoutMSGParams_ToString_Success) {
+ // Create SmartObject
+ SmartObject obj;
+ obj[S_PARAMS][S_FUNCTION_ID] = mobile_apis::FunctionID::AddCommandID;
+ obj[S_PARAMS][S_MESSAGE_TYPE] = mobile_apis::messageType::request;
+ obj[S_PARAMS][S_CORRELATION_ID] = 4444;
+ // Attach Schema
+ mobile_apis::MOBILE_API factory;
+ EXPECT_TRUE(factory.attachSchema(obj, false));
+
+ std::string result;
+ // Convert SmartObject to Json string
EXPECT_TRUE(FormatterJsonRpc::ToString(obj, result));
- EXPECT_EQ(
- std::string(
- "{\n \"jsonrpc\" : \"2.0\",\n \"method\" : \"Buttons.OnButtonPress\",\n \"params\" : {}\n}\n"),
- result);
+ CompactJson(result);
+ const std::string json_string(
+ "{\"id\":4444,\"jsonrpc\":\"2.0\",\"method\":\"AddCommandID\"}");
+ EXPECT_EQ(json_string, result);
+}
+
+TEST(FormatterJsonRPCTest, RequestWithoutCorID_ToString_Fail) {
+ // Create SmartObject
+ SmartObject obj;
+ obj[S_PARAMS][S_FUNCTION_ID] = mobile_apis::FunctionID::AddCommandID;
+ obj[S_PARAMS][S_MESSAGE_TYPE] = mobile_apis::messageType::request;
+ obj[S_MSG_PARAMS] = SmartObject(SmartType::SmartType_Map);
+ // Attach Schema
+ mobile_apis::MOBILE_API factory;
+ EXPECT_TRUE(factory.attachSchema(obj, false));
+
+ std::string result;
+ // Converting SmartObject to Json string is failed
+ EXPECT_FALSE(FormatterJsonRpc::ToString(obj, result));
+ CompactJson(result);
+
+ const std::string json_string(
+ "{\"jsonrpc\":\"2.0\",\"method\":\"AddCommandID\"}");
+ EXPECT_EQ(json_string, result);
}
-TEST(FormatterJsonRPCTest, InvalidRPC_SmartObjectToString_EXPECT_FALSE) {
+TEST(FormatterJsonRPCTest, RequestWithoutType_ToString_Fail) {
// Create SmartObject
SmartObject obj;
+ obj[S_PARAMS][S_FUNCTION_ID] = mobile_apis::FunctionID::AddCommandID;
+ obj[S_MSG_PARAMS] = SmartObject(SmartType::SmartType_Map);
+ // Attach Schema is impossible
+ mobile_apis::MOBILE_API factory;
+ EXPECT_FALSE(factory.attachSchema(obj, false));
+
+ std::string result;
+ // Converting SmartObject to Json string is failed
+ EXPECT_FALSE(FormatterJsonRpc::ToString(obj, result));
+ EXPECT_EQ(std::string("{\n \"jsonrpc\" : \"2.0\"\n}\n"), result);
+}
+
+TEST(FormatterJsonRPCTest, InvalidRPC_ToString_False) {
+ // Create SmartObject with notification id and response message type
+ SmartObject obj;
std::string result;
obj[S_PARAMS][S_FUNCTION_ID] =
- hmi_apis::FunctionID::BasicCommunication_OnReady;
+ hmi_apis::FunctionID::BasicCommunication_OnReady;
obj[S_PARAMS][S_MESSAGE_TYPE] = hmi_apis::messageType::response;
obj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
obj[S_PARAMS][S_PROTOCOL_TYPE] = 1;
@@ -128,72 +321,110 @@ TEST(FormatterJsonRPCTest, InvalidRPC_SmartObjectToString_EXPECT_FALSE) {
EXPECT_EQ(std::string("{\n \"jsonrpc\" : \"2.0\"\n}\n"), result);
}
-TEST(FormatterJsonRPCTest, FromStringNotificationToSmartObj_ExpectSuccess) {
+TEST(FormatterJsonRPCTest, Notification_ToSmartObject_Success) {
// Source Json string
const std::string json_string(
- "{\n \"jsonrpc\" : \"2.0\",\n \"method\" : \"BasicCommunication.OnReady\",\n \"params\" : {}\n}\n");
+ "{\n \"jsonrpc\" : \"2.0\",\n \"method\" : "
+ "\"BasicCommunication.OnReady\",\n \"params\" : {}\n}\n");
// Smart Object to keep result
SmartObject obj;
// Convert json string to smart object
- EXPECT_EQ(
- 0,
- (FormatterJsonRpc::FromString<hmi_apis::FunctionID::eType,
- hmi_apis::messageType::eType>(json_string, obj)));
+ int32_t result = FormatterJsonRpc::FromString<hmi_apis::FunctionID::eType,
+ hmi_apis::messageType::eType>(
+ json_string, obj);
+ EXPECT_EQ(0, result);
// Get keys collection from Smart Object
std::set<std::string> keys = obj["params"].enumerate();
EXPECT_EQ(4u, keys.size());
}
-TEST(FormatterJsonRPCTest, FromStringToSmartObjInvalidFormat_ExpectFalse) {
+TEST(FormatterJsonRPCTest, InvalidFormatToSmartObject_False) {
// Source Json string
const std::string json_string(
- "{\n \"method\" : \"BasicCommunication.OnReady\",\n \"params\" : {}\n}\n");
+ "{\n \"method\" : \"BasicCommunication.OnReady\",\n \"params\" : "
+ "{}\n}\n");
// Smart Object to keep result
SmartObject obj;
// Convert json string to smart object
- EXPECT_EQ(
- 2,
- (FormatterJsonRpc::FromString<hmi_apis::FunctionID::eType,
- hmi_apis::messageType::eType>(json_string, obj)));
+ int32_t result = FormatterJsonRpc::FromString<hmi_apis::FunctionID::eType,
+ hmi_apis::messageType::eType>(
+ json_string, obj);
+ EXPECT_EQ(2, result);
// Get keys collection from Smart Object
std::set<std::string> keys = obj["params"].enumerate();
EXPECT_EQ(4u, keys.size());
}
-TEST(FormatterJsonRPCTest, FromStringRequestToSmartObj_ExpectSuccess) {
+TEST(FormatterJsonRPCTest, RequestToSmartObject_Success) {
// Source Json string
const std::string json_string(
- "{\n \"id\" : 4444,\n \"jsonrpc\" : \"2.0\",\n \"method\" : \"VR.IsReady\"\n}\n");
+ "{\n \"id\" : 4444,\n \"jsonrpc\" : \"2.0\",\n \"method\" : "
+ "\"VR.IsReady\"\n}\n");
// Smart Object to keep result
SmartObject obj;
// Convert json string to smart object
- EXPECT_EQ(
- 0,
- (FormatterJsonRpc::FromString<hmi_apis::FunctionID::eType,
- hmi_apis::messageType::eType>(json_string, obj)));
+ int32_t result = FormatterJsonRpc::FromString<hmi_apis::FunctionID::eType,
+ hmi_apis::messageType::eType>(
+ json_string, obj);
+ int32_t function_id = hmi_apis::FunctionID::VR_IsReady;
+ EXPECT_EQ(0, result);
// Get keys collection from Smart Object
std::set<std::string> keys = obj["params"].enumerate();
- std::set<std::string>::iterator it1 = keys.begin();
EXPECT_EQ(5u, keys.size());
+ EXPECT_EQ(4444, obj["params"]["correlation_id"].asInt());
+ EXPECT_EQ(function_id, obj["params"]["function_id"].asInt());
+ EXPECT_EQ(0, obj["params"]["message_type"].asInt());
+ EXPECT_EQ(1, obj["params"]["protocol_type"].asInt());
+ EXPECT_EQ(2, obj["params"]["protocol_version"].asInt());
}
-TEST(FormatterJsonRPCTest, FromStringResponseToSmartObj_ExpectSuccess) {
+TEST(FormatterJsonRPCTest, ResponseToSmartObject_Success) {
// Source Json string
const std::string json_string(
- "{\n \"id\" : 4444,\n \"jsonrpc\" : \"2.0\",\n \"method\" : \"VR.IsReady\"\n}\n");
+ "{\"id\":4440,\"jsonrpc\":\"2.0\",\"result\":{\"code\":0,\"method\":\"VR."
+ "AddCommand\"}}");
// Smart Object to keep result
SmartObject obj;
// Convert json string to smart object
- EXPECT_EQ(
- 0,
- (FormatterJsonRpc::FromString<hmi_apis::FunctionID::eType,
- hmi_apis::messageType::eType>(json_string, obj)));
+ int32_t result = FormatterJsonRpc::FromString<hmi_apis::FunctionID::eType,
+ hmi_apis::messageType::eType>(
+ json_string, obj);
+
+ int32_t function_id = hmi_apis::FunctionID::VR_AddCommand;
+
+ EXPECT_EQ(0, result);
// Get keys collection from Smart Object
std::set<std::string> keys = obj["params"].enumerate();
- std::set<std::string>::iterator it1 = keys.begin();
- EXPECT_EQ(5u, keys.size());
+ EXPECT_EQ(6u, keys.size());
+ EXPECT_EQ(0, obj["params"]["code"].asInt());
+ EXPECT_EQ(4440, obj["params"]["correlation_id"].asInt());
+ EXPECT_EQ(function_id, obj["params"]["function_id"].asInt());
+ EXPECT_EQ(1, obj["params"]["message_type"].asInt());
+ EXPECT_EQ(1, obj["params"]["protocol_type"].asInt());
+ EXPECT_EQ(2, obj["params"]["protocol_version"].asInt());
+}
+
+TEST(FormatterJsonRPCTest, StringWithUpperBoundValueToSmartObject_Success) {
+ // Source Json string
+ const std::string json_string(
+ "{\"jsonrpc\":\"2.0\",\"method\":\"BasicCommunication.OnSystemRequest\","
+ "\"params\":{\"fileName\":\"filename\",\"length\":100000000000,"
+ "\"requestType\":\"PROPRIETARY\"}}");
+ // Smart Object to keep result
+ SmartObject obj;
+ // Convert json string to smart object
+
+ int32_t res = FormatterJsonRpc::FromString<hmi_apis::FunctionID::eType,
+ hmi_apis::messageType::eType>(
+ json_string, obj);
+ // Get keys collection from Smart Object
+ EXPECT_EQ(0, res);
+ EXPECT_EQ(big_64int, obj["msg_params"]["length"].asInt());
+ EXPECT_EQ(str_with_big_int64, obj["msg_params"]["length"].asString());
+ std::set<std::string> keys = obj["params"].enumerate();
+ EXPECT_EQ(4u, keys.size());
}
-} // namespace formatters
+} // namespace formatters_test
} // namespace components
} // namespace test
diff --git a/src/components/formatters/test/generic_json_formatter_test.cc b/src/components/formatters/test/generic_json_formatter_test.cc
index 51da8c91ff..41ecfd9ee3 100644
--- a/src/components/formatters/test/generic_json_formatter_test.cc
+++ b/src/components/formatters/test/generic_json_formatter_test.cc
@@ -76,18 +76,20 @@ TEST(GenericJsonFormatter, ToString) {
obj["subobject"]["arrayField"][1] = 'c';
obj["subobject"]["arrayField"][2][0] = 10.0;
formatters::GenericJsonFormatter::ToString(obj, result);
- ASSERT_STREQ("{\n"
- " \"intField\" : 100500,\n"
- " \"stringField\" : \"s\",\n"
- " \"subobject\" : {\n"
- " \"arrayField\" : [\n"
- " 0,\n"
- " \"c\",\n"
- " [ 10.0 ]\n"
- " ],\n"
- " \"boolField\" : false\n"
- " }\n"
- "}\n", result.c_str());
+ ASSERT_STREQ(
+ "{\n"
+ " \"intField\" : 100500,\n"
+ " \"stringField\" : \"s\",\n"
+ " \"subobject\" : {\n"
+ " \"arrayField\" : [\n"
+ " 0,\n"
+ " \"c\",\n"
+ " [ 10.0 ]\n"
+ " ],\n"
+ " \"boolField\" : false\n"
+ " }\n"
+ "}\n",
+ result.c_str());
}
TEST(GenericJsonFormatter, FromString) {
@@ -120,8 +122,8 @@ TEST(GenericJsonFormatter, FromString) {
ASSERT_EQ(smartobj::SmartType_String, result.getType());
ASSERT_STREQ("str", result.asString().c_str());
- ASSERT_TRUE(formatters::GenericJsonFormatter::FromString("[true, null, 10]",
- result));
+ ASSERT_TRUE(
+ formatters::GenericJsonFormatter::FromString("[true, null, 10]", result));
ASSERT_EQ(smartobj::SmartType_Array, result.getType());
ASSERT_EQ(smartobj::SmartType_Boolean, result.getElement(0U).getType());
ASSERT_EQ(true, result.getElement(0U).asBool());
@@ -129,15 +131,15 @@ TEST(GenericJsonFormatter, FromString) {
ASSERT_EQ(smartobj::SmartType_Integer, result.getElement(2U).getType());
ASSERT_EQ(10, result.getElement(2U).asInt());
- ASSERT_TRUE(
- formatters::GenericJsonFormatter::FromString("{"
- " \"intField\": 100500,"
- " \"subobject\": {"
- " \"arrayField\": [1, null],"
- " \"strField\": \"str\""
- " }"
- "}",
- result));
+ ASSERT_TRUE(formatters::GenericJsonFormatter::FromString(
+ "{"
+ " \"intField\": 100500,"
+ " \"subobject\": {"
+ " \"arrayField\": [1, null],"
+ " \"strField\": \"str\""
+ " }"
+ "}",
+ result));
ASSERT_EQ(smartobj::SmartType_Map, result.getType());
ASSERT_EQ(smartobj::SmartType_Integer,
result.getElement("intField").getType());
@@ -146,17 +148,27 @@ TEST(GenericJsonFormatter, FromString) {
ASSERT_EQ(smartobj::SmartType_Array,
result.getElement("subobject").getElement("arrayField").getType());
ASSERT_EQ(smartobj::SmartType_Integer,
- result.getElement("subobject").getElement("arrayField").getElement(0U).getType());
- ASSERT_EQ(1, result.getElement("subobject").getElement("arrayField").getElement(0U).asInt());
+ result.getElement("subobject")
+ .getElement("arrayField")
+ .getElement(0U)
+ .getType());
+ ASSERT_EQ(1,
+ result.getElement("subobject")
+ .getElement("arrayField")
+ .getElement(0U)
+ .asInt());
ASSERT_EQ(smartobj::SmartType_Null,
- result.getElement("subobject").getElement("arrayField").getElement(1U).getType());
+ result.getElement("subobject")
+ .getElement("arrayField")
+ .getElement(1U)
+ .getType());
ASSERT_EQ(smartobj::SmartType_String,
result.getElement("subobject").getElement("strField").getType());
ASSERT_STREQ(
- "str",
- result.getElement("subobject").getElement("strField").asString().c_str());
+ "str",
+ result.getElement("subobject").getElement("strField").asString().c_str());
}
-} // formatters
-} // components
-} // test
+} // formatters
+} // components
+} // test
diff --git a/src/components/formatters/test/include/SmartFactoryTestHelper.h b/src/components/formatters/test/include/formatters/SmartFactoryTestHelper.h
index ca7021b844..d195fe1833 100644
--- a/src/components/formatters/test/include/SmartFactoryTestHelper.h
+++ b/src/components/formatters/test/include/formatters/SmartFactoryTestHelper.h
@@ -36,7 +36,7 @@
#include <map>
#include <set>
-#include "formatters/CSmartFactory.hpp"
+#include "formatters/CSmartFactory.h"
#include "HMI_API_schema.h"
#include "smart_objects/always_true_schema_item.h"
#include "smart_objects/always_false_schema_item.h"
@@ -74,12 +74,7 @@ enum eType {
} // namespace TestType
namespace FunctionIdTest {
-enum eType {
- INVALID_ENUM = -1,
- Function1,
- Function2,
- Function3
-};
+enum eType { INVALID_ENUM = -1, Function1, Function2, Function3 };
} // namespace FunctionIdTest
namespace MessageTypeTest {
@@ -93,69 +88,67 @@ enum eType {
} // namespace MessageTypeTest
namespace StructIdentifiersTest {
-enum eType {
- INVALID_ENUM = -1,
- Common_1,
- Common_2,
- Common_3
-};
+enum eType { INVALID_ENUM = -1, Common_1, Common_2, Common_3 };
} // namespace StructIdentifiersTest
class CSmartFactoryTest : public CSmartFactory<FunctionIdTest::eType,
- MessageTypeTest::eType, StructIdentifiersTest::eType> {
+ MessageTypeTest::eType,
+ StructIdentifiersTest::eType> {
public:
CSmartFactoryTest();
std::map<SmartSchemaKey<FunctionIdTest::eType, MessageTypeTest::eType>,
- CSmartSchema> function_schemes() {
+ CSmartSchema>
+ function_schemes() {
return functions_schemes_;
}
std::map<StructIdentifiersTest::eType, CSmartSchema> structs_schemes() {
return structs_schemes_;
}
+
protected:
typedef std::map<const StructIdentifiersTest::eType,
- utils::SharedPtr<ISchemaItem> > TStructsSchemaItems;
+ utils::SharedPtr<ISchemaItem> > TStructsSchemaItems;
static utils::SharedPtr<ISchemaItem> ProvideObjectSchemaItemForStruct(
- TStructsSchemaItems &struct_schema_items,
+ TStructsSchemaItems& struct_schema_items,
const StructIdentifiersTest::eType struct_id);
- void InitStructSchemes(TStructsSchemaItems &struct_schema_items);
+ void InitStructSchemes(TStructsSchemaItems& struct_schema_items);
void InitFunctionSchemes(
- const TStructsSchemaItems &struct_schema_items,
- const std::set<FunctionIdTest::eType> &function_id_items,
- const std::set<MessageTypeTest::eType> &message_type_items);
+ const TStructsSchemaItems& struct_schema_items,
+ const std::set<FunctionIdTest::eType>& function_id_items,
+ const std::set<MessageTypeTest::eType>& message_type_items);
static CSmartSchema InitFunction_Function1_request(
- const std::set<FunctionIdTest::eType> &function_id_items,
- const std::set<MessageTypeTest::eType> &message_type_items);
+ const std::set<FunctionIdTest::eType>& function_id_items,
+ const std::set<MessageTypeTest::eType>& message_type_items);
static CSmartSchema InitFunction_Function1_response(
- const TStructsSchemaItems &struct_schema_items,
- const std::set<FunctionIdTest::eType> &function_id_items,
- const std::set<MessageTypeTest::eType> &message_type_items);
+ const TStructsSchemaItems& struct_schema_items,
+ const std::set<FunctionIdTest::eType>& function_id_items,
+ const std::set<MessageTypeTest::eType>& message_type_items);
static CSmartSchema InitFunction_Function2_request(
- const std::set<FunctionIdTest::eType> &function_id_items,
- const std::set<MessageTypeTest::eType> &message_type_items);
+ const std::set<FunctionIdTest::eType>& function_id_items,
+ const std::set<MessageTypeTest::eType>& message_type_items);
static CSmartSchema InitFunction_Function2_response(
- const TStructsSchemaItems &struct_schema_items,
- const std::set<FunctionIdTest::eType> &function_id_items,
- const std::set<MessageTypeTest::eType> &message_type_items);
+ const TStructsSchemaItems& struct_schema_items,
+ const std::set<FunctionIdTest::eType>& function_id_items,
+ const std::set<MessageTypeTest::eType>& message_type_items);
static CSmartSchema InitFunction_Function3_request(
- const std::set<FunctionIdTest::eType> &function_id_items,
- const std::set<MessageTypeTest::eType> &message_type_items);
+ const std::set<FunctionIdTest::eType>& function_id_items,
+ const std::set<MessageTypeTest::eType>& message_type_items);
static CSmartSchema InitFunction_Function3_response(
- const TStructsSchemaItems &struct_schema_items,
- const std::set<FunctionIdTest::eType> &function_id_items,
- const std::set<MessageTypeTest::eType> &message_type_items);
+ const TStructsSchemaItems& struct_schema_items,
+ const std::set<FunctionIdTest::eType>& function_id_items,
+ const std::set<MessageTypeTest::eType>& message_type_items);
static utils::SharedPtr<ISchemaItem> InitStructSchemaItem_Common_1(
- TStructsSchemaItems &struct_schema_items);
+ TStructsSchemaItems& struct_schema_items);
static utils::SharedPtr<ISchemaItem> InitStructSchemaItem_Common_2();
};
diff --git a/src/components/formatters/test/include/create_smartSchema.h b/src/components/formatters/test/include/formatters/create_smartSchema.h
index c3bc2651e5..3514b7fe94 100644
--- a/src/components/formatters/test/include/create_smartSchema.h
+++ b/src/components/formatters/test/include/formatters/create_smartSchema.h
@@ -33,7 +33,7 @@
#ifndef SRC_COMPONENTS_FORMATTERS_TEST_INCLUDE_CREATESMARTSCHEMA_H_
#define SRC_COMPONENTS_FORMATTERS_TEST_INCLUDE_CREATESMARTSCHEMA_H_
-#include "formatters/CFormatterJsonSDLRPCv1.hpp"
+#include "formatters/CFormatterJsonSDLRPCv1.h"
#include "SmartFactoryTestHelper.h"
namespace test {
@@ -54,18 +54,10 @@ enum eType {
}
namespace Language {
-enum eType {
- INVALID_ENUM = -1,
- EN_EU,
- RU_RU
-};
+enum eType { INVALID_ENUM = -1, EN_EU, RU_RU };
}
namespace AppTypeTest {
-enum eType {
- INVALID_ENUM = -1,
- SYSTEM,
- MEDIA
-};
+enum eType { INVALID_ENUM = -1, SYSTEM, MEDIA };
}
namespace SpeechCapabilities {
enum eType {
@@ -75,11 +67,7 @@ enum eType {
}
namespace StructIdentifiers {
-enum eType {
- INVALID_ENUM = -1,
- Struct1,
- Struct2
-};
+enum eType { INVALID_ENUM = -1, Struct1, Struct2 };
}
CSmartSchema initObjectSchema();
diff --git a/src/components/formatters/test/include/meta_formatter_test_helper.h b/src/components/formatters/test/include/formatters/meta_formatter_test_helper.h
index e2be3beb64..1494c75c4b 100644
--- a/src/components/formatters/test/include/meta_formatter_test_helper.h
+++ b/src/components/formatters/test/include/formatters/meta_formatter_test_helper.h
@@ -36,8 +36,8 @@
#include "gtest/gtest.h"
#include "smart_objects/smart_object.h"
-#include "formatters/CFormatterJsonSDLRPCv1.hpp"
-#include "formatters/CSmartFactory.hpp"
+#include "formatters/CFormatterJsonSDLRPCv1.h"
+#include "formatters/CSmartFactory.h"
#include "create_smartSchema.h"
namespace test {
@@ -46,7 +46,6 @@ namespace formatters {
class CMetaFormatterTestHelper : public ::testing::Test {
protected:
-
virtual void SetUp();
virtual void TearDown();
@@ -80,4 +79,4 @@ class CMetaFormatterTestHelper : public ::testing::Test {
} // namespace components
} // namespace test
-#endif // SRC_COMPONENTS_FORMATTERS_TEST_INCLUDE_METAFORMATTERTESTHELPER_H_
+#endif // SRC_COMPONENTS_FORMATTERS_TEST_INCLUDE_METAFORMATTERTESTHELPER_H_
diff --git a/src/components/formatters/test/meta_formatter_test.cc b/src/components/formatters/test/meta_formatter_test.cc
index 17c2506ac6..27f5e70e8f 100644
--- a/src/components/formatters/test/meta_formatter_test.cc
+++ b/src/components/formatters/test/meta_formatter_test.cc
@@ -32,17 +32,19 @@
#include "gtest/gtest.h"
#include "formatters/meta_formatter.h"
-#include "meta_formatter_test_helper.h"
+#include "formatters/meta_formatter_test_helper.h"
namespace test {
namespace components {
namespace formatters {
-TEST_F(CMetaFormatterTestHelper, inputObjectIdenticalToSchemaWithAndWithoutMandatoryParams) {
+TEST_F(CMetaFormatterTestHelper,
+ inputObjectIdenticalToSchemaWithAndWithoutMandatoryParams) {
Json::Value value;
Json::Reader reader;
- CSmartFactory<FunctionIDTest::eType, MessageTypeTest::eType,
- StructIdentifiers::eType> factory_;
+ CSmartFactory<FunctionIDTest::eType,
+ MessageTypeTest::eType,
+ StructIdentifiers::eType> factory_;
SmartObject object1 = factory_.CreateSmartObject(
FunctionIDTest::RegisterAppInterface, MessageTypeTest::request);
@@ -59,31 +61,32 @@ TEST_F(CMetaFormatterTestHelper, inputObjectIdenticalToSchemaWithAndWithoutManda
FillObjectIdenticalToSchema(object1);
FillObjectIdenticalToSchemaWithoutNoMandatoriesParams(object2);
bool creationresult;
- creationresult = CMetaFormatter::CreateObjectByPattern(object1, schema,
- result_object1);
+ creationresult =
+ CMetaFormatter::CreateObjectByPattern(object1, schema, result_object1);
EXPECT_TRUE(creationresult);
- creationresult = CMetaFormatter::CreateObjectByPattern(object2, schema,
- result_object2);
+ creationresult =
+ CMetaFormatter::CreateObjectByPattern(object2, schema, result_object2);
EXPECT_TRUE(creationresult);
// Uncomment code to print objects in console
-// std::string formatted_string;
-// CFormatterJsonSDLRPCv1::toString(object1, formatted_string);
-// printf("object1 %s\n", formatted_string.c_str());
-//
-// CFormatterJsonSDLRPCv1::toString(result_object1, formatted_string);
-// printf("result_object1 %s\n", formatted_string.c_str());
-//
-// CFormatterJsonSDLRPCv1::toString(object2, formatted_string);
-// printf("object2 %s\n", formatted_string.c_str());
-//
-// CFormatterJsonSDLRPCv1::toString(result_object2, formatted_string);
-// printf("result_object2 %s\n", formatted_string.c_str());
+ // std::string formatted_string;
+ // CFormatterJsonSDLRPCv1::toString(object1, formatted_string);
+ // printf("object1 %s\n", formatted_string.c_str());
+ //
+ // CFormatterJsonSDLRPCv1::toString(result_object1, formatted_string);
+ // printf("result_object1 %s\n", formatted_string.c_str());
+ //
+ // CFormatterJsonSDLRPCv1::toString(object2, formatted_string);
+ // printf("object2 %s\n", formatted_string.c_str());
+ //
+ // CFormatterJsonSDLRPCv1::toString(result_object2, formatted_string);
+ // printf("result_object2 %s\n", formatted_string.c_str());
CompareObjects(object1, result_object1);
CompareObjects(object2, result_object2);
- // Enums must be unapplied (converted to string) in order to be compared against strings
+ // Enums must be unapplied (converted to string) in order to be compared
+ // against strings
result_object1.getSchema().unapplySchema(result_object1);
EXPECT_EQ("request", result_object1[S_PARAMS][S_MESSAGE_TYPE].asString());
EXPECT_EQ("RegisterAppInterface",
@@ -102,25 +105,24 @@ TEST_F(CMetaFormatterTestHelper, NormalSchemaWithEmptyObject) {
// Get schema
CSmartSchema schema = initSchemaForMetaFormatter();
- bool create_object_result = CMetaFormatter::CreateObjectByPattern(
- object, schema, result_object);
+ bool create_object_result =
+ CMetaFormatter::CreateObjectByPattern(object, schema, result_object);
EXPECT_TRUE(create_object_result);
FillObjectWithDefaultValues(expected_object);
CompareObjects(expected_object, result_object);
-// Uncomment code to print objects in console
-// std::string str;
-// AnyObjectToJsonString(result_object, str);
-// printf("result_object(default) %s", str.c_str());
-// AnyObjectToJsonString(expected_object, str);
-// printf("expected_object %s", str.c_str());
-
-
+ // Uncomment code to print objects in console
+ // std::string str;
+ // AnyObjectToJsonString(result_object, str);
+ // printf("result_object(default) %s", str.c_str());
+ // AnyObjectToJsonString(expected_object, str);
+ // printf("expected_object %s", str.c_str());
}
-TEST_F(CMetaFormatterTestHelper, NormalSchemaWithObjectWithoutSomeMandatoryFields) {
+TEST_F(CMetaFormatterTestHelper,
+ NormalSchemaWithObjectWithoutSomeMandatoryFields) {
SmartObject object;
SmartObject result_object;
@@ -137,58 +139,61 @@ TEST_F(CMetaFormatterTestHelper, NormalSchemaWithObjectWithoutSomeMandatoryField
EXPECT_EQ(
0, result_object[S_MSG_PARAMS]["syncMsgVersion"]["minorVersion"].asInt());
-// Uncomment code to print object in console
-// std::string str;
-// AnyObjectToJsonString(result_object, str);
-// printf("result_object %s", str.c_str());
-
+ // Uncomment code to print object in console
+ // std::string str;
+ // AnyObjectToJsonString(result_object, str);
+ // printf("result_object %s", str.c_str());
}
TEST_F(CMetaFormatterTestHelper, ObjectWithEmptyMap) {
std::map<std::string, CObjectSchemaItem::SMember> schemaMembersMap;
- CSmartSchema map_schema = CSmartSchema(
- CObjectSchemaItem::create(schemaMembersMap));
+ CSmartSchema map_schema =
+ CSmartSchema(CObjectSchemaItem::create(schemaMembersMap));
SmartObject object;
SmartObject result_object_empty_map;
SmartObject object_empty_map = SmartObject(SmartType_Map);
- CMetaFormatter::CreateObjectByPattern(object_empty_map, map_schema,
- result_object_empty_map);
- EXPECT_EQ(SmartType_Map, result_object_empty_map.getType())<< "smartObject is not map type";
- EXPECT_EQ(0u, result_object_empty_map.length())<< "non empty map";
-
- CMetaFormatter::CreateObjectByPattern(object, map_schema,
- result_object_empty_map);
- EXPECT_EQ(SmartType_Map, result_object_empty_map.getType())<< "smartObject is not map type";
- EXPECT_EQ(0u, result_object_empty_map.length())<< "non empty map";
+ CMetaFormatter::CreateObjectByPattern(
+ object_empty_map, map_schema, result_object_empty_map);
+ EXPECT_EQ(SmartType_Map, result_object_empty_map.getType())
+ << "smartObject is not map type";
+ EXPECT_EQ(0u, result_object_empty_map.length()) << "non empty map";
+
+ CMetaFormatter::CreateObjectByPattern(
+ object, map_schema, result_object_empty_map);
+ EXPECT_EQ(SmartType_Map, result_object_empty_map.getType())
+ << "smartObject is not map type";
+ EXPECT_EQ(0u, result_object_empty_map.length()) << "non empty map";
object["field1"] = 0;
object["field2"] = SmartObject();
- CMetaFormatter::CreateObjectByPattern(object, map_schema,
- result_object_empty_map);
- EXPECT_EQ(SmartType_Map, result_object_empty_map.getType())<< "smartObject is not map type";
- EXPECT_EQ(0u, result_object_empty_map.length())<< "non empty map";
+ CMetaFormatter::CreateObjectByPattern(
+ object, map_schema, result_object_empty_map);
+ EXPECT_EQ(SmartType_Map, result_object_empty_map.getType())
+ << "smartObject is not map type";
+ EXPECT_EQ(0u, result_object_empty_map.length()) << "non empty map";
// Fill object with any values. Result must be the same
FillObjectIdenticalToSchema(object);
- CMetaFormatter::CreateObjectByPattern(object, map_schema,
- result_object_empty_map);
- EXPECT_EQ(SmartType_Map, result_object_empty_map.getType())<< "smartObject is not map type";
- EXPECT_EQ(0u, result_object_empty_map.length())<< "non empty map";
+ CMetaFormatter::CreateObjectByPattern(
+ object, map_schema, result_object_empty_map);
+ EXPECT_EQ(SmartType_Map, result_object_empty_map.getType())
+ << "smartObject is not map type";
+ EXPECT_EQ(0u, result_object_empty_map.length()) << "non empty map";
// Fill object with any values. Result must be the same
FillObjectIdenticalToSchemaWithoutNoMandatoriesParams(object);
- CMetaFormatter::CreateObjectByPattern(object, map_schema,
- result_object_empty_map);
- EXPECT_EQ(SmartType_Map, result_object_empty_map.getType())<< "smartObject is not map type";
- EXPECT_EQ(0u, result_object_empty_map.length())<< "non empty map";
-
-// Uncomment code to print object in console
-// std::string str;
-// AnyObjectToJsonString(result_object_empty_map, str);
-// printf("result_object(empty map) %s", str.c_str());
-
+ CMetaFormatter::CreateObjectByPattern(
+ object, map_schema, result_object_empty_map);
+ EXPECT_EQ(SmartType_Map, result_object_empty_map.getType())
+ << "smartObject is not map type";
+ EXPECT_EQ(0u, result_object_empty_map.length()) << "non empty map";
+
+ // Uncomment code to print object in console
+ // std::string str;
+ // AnyObjectToJsonString(result_object_empty_map, str);
+ // printf("result_object(empty map) %s", str.c_str());
}
TEST_F(CMetaFormatterTestHelper, ObjectWithEmptyArray) {
@@ -199,38 +204,42 @@ TEST_F(CMetaFormatterTestHelper, ObjectWithEmptyArray) {
SmartObject object_empty_aray = SmartObject(SmartType_Array);
- CMetaFormatter::CreateObjectByPattern(object_empty_aray, array_schema,
- result_object_empty_array);
- EXPECT_EQ(SmartType_Array, result_object_empty_array.getType())<< "smartObject is not array type";
- EXPECT_EQ(0u, result_object_empty_array.length())<< "non empty array";
+ CMetaFormatter::CreateObjectByPattern(
+ object_empty_aray, array_schema, result_object_empty_array);
+ EXPECT_EQ(SmartType_Array, result_object_empty_array.getType())
+ << "smartObject is not array type";
+ EXPECT_EQ(0u, result_object_empty_array.length()) << "non empty array";
- CMetaFormatter::CreateObjectByPattern(object, array_schema,
- result_object_empty_array);
- EXPECT_EQ(SmartType_Array, result_object_empty_array.getType())<< "smartObject is not array type";
- EXPECT_EQ(0u, result_object_empty_array.length())<< "non empty array";
+ CMetaFormatter::CreateObjectByPattern(
+ object, array_schema, result_object_empty_array);
+ EXPECT_EQ(SmartType_Array, result_object_empty_array.getType())
+ << "smartObject is not array type";
+ EXPECT_EQ(0u, result_object_empty_array.length()) << "non empty array";
// Fill object with any values. Result must be the same
FillObjectIdenticalToSchema(object);
- CMetaFormatter::CreateObjectByPattern(object, array_schema,
- result_object_empty_array);
- EXPECT_EQ(SmartType_Array, result_object_empty_array.getType())<< "smartObject is not array type";
- EXPECT_EQ(0u, result_object_empty_array.length())<< "non empty array";
+ CMetaFormatter::CreateObjectByPattern(
+ object, array_schema, result_object_empty_array);
+ EXPECT_EQ(SmartType_Array, result_object_empty_array.getType())
+ << "smartObject is not array type";
+ EXPECT_EQ(0u, result_object_empty_array.length()) << "non empty array";
// Fill object with any values. Result must be the same
FillObjectWithoutSomeMandatoryFields(object);
- CMetaFormatter::CreateObjectByPattern(object, array_schema,
- result_object_empty_array);
- EXPECT_EQ(SmartType_Array, result_object_empty_array.getType())<< "smartObject is not array type";
- EXPECT_EQ(0u, result_object_empty_array.length())<< "non empty array";
-
-// Uncomment code to print object in console
-// std::string str;
-// AnyObjectToJsonString(result_object_empty_array, str);
-// printf("result_object(empty array) %s", str.c_str());
-
+ CMetaFormatter::CreateObjectByPattern(
+ object, array_schema, result_object_empty_array);
+ EXPECT_EQ(SmartType_Array, result_object_empty_array.getType())
+ << "smartObject is not array type";
+ EXPECT_EQ(0u, result_object_empty_array.length()) << "non empty array";
+
+ // Uncomment code to print object in console
+ // std::string str;
+ // AnyObjectToJsonString(result_object_empty_array, str);
+ // printf("result_object(empty array) %s", str.c_str());
}
-TEST_F(CMetaFormatterTestHelper, ObjectWithEmptyArrayAndEmptyMapWithOtherParameters) {
+TEST_F(CMetaFormatterTestHelper,
+ ObjectWithEmptyArrayAndEmptyMapWithOtherParameters) {
// Arrange
SmartObject result_object;
SmartObject object;
@@ -254,8 +263,8 @@ TEST_F(CMetaFormatterTestHelper, ObjectWithEmptyArrayAndEmptyMapWithOtherParamet
TNumberSchemaItem<int>::create(TSchemaItemParameter<int>(1),
TSchemaItemParameter<int>(2)),
false);
- paramsMembersMap[S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), false);
+ paramsMembersMap[S_PROTOCOL_TYPE] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), false);
std::map<std::string, CObjectSchemaItem::SMember> schemaMembersMap;
@@ -286,7 +295,8 @@ TEST_F(CMetaFormatterTestHelper, ObjectWithEmptyArrayAndEmptyMapWithOtherParamet
schemaMembersMap["non_mandatory_string"] = CObjectSchemaItem::SMember(
CStringSchemaItem::create(
- TSchemaItemParameter<size_t>(0), TSchemaItemParameter<size_t>(500),
+ TSchemaItemParameter<size_t>(0),
+ TSchemaItemParameter<size_t>(500),
TSchemaItemParameter<std::string>("ignoredDefValue")),
false);
@@ -313,13 +323,12 @@ TEST_F(CMetaFormatterTestHelper, ObjectWithEmptyArrayAndEmptyMapWithOtherParamet
CMetaFormatter::CreateObjectByPattern(object, schema, result_object);
-// Uncomment code to print object in console
-// std::string str;
-// AnyObjectToJsonString(object, str);
-// printf("object %s", str.c_str());
-// AnyObjectToJsonString(result_object, str);
-// printf("result_object %s", str.c_str());
-
+ // Uncomment code to print object in console
+ // std::string str;
+ // AnyObjectToJsonString(object, str);
+ // printf("object %s", str.c_str());
+ // AnyObjectToJsonString(result_object, str);
+ // printf("result_object %s", str.c_str());
// Assert
EXPECT_EQ(500, result_object[S_PARAMS][S_FUNCTION_ID].asInt());
diff --git a/src/components/formatters/test/src/SmartFactoryTestHelper.cc b/src/components/formatters/test/src/SmartFactoryTestHelper.cc
index 8f601afc29..2dd76f85f8 100644
--- a/src/components/formatters/test/src/SmartFactoryTestHelper.cc
+++ b/src/components/formatters/test/src/SmartFactoryTestHelper.cc
@@ -30,27 +30,38 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "SmartFactoryTestHelper.h"
+#include "formatters/SmartFactoryTestHelper.h"
using namespace test::components::formatters;
-template<>
-const EnumConversionHelper<TestType::eType>::EnumToCStringMap EnumConversionHelper<
- test::components::formatters::TestType::eType>::enum_to_cstring_map_ =
- EnumConversionHelper<test::components::formatters::TestType::eType>::InitEnumToCStringMap();
-
-template<>
-const EnumConversionHelper<TestType::eType>::CStringToEnumMap EnumConversionHelper<
- test::components::formatters::TestType::eType>::cstring_to_enum_map_ =
- EnumConversionHelper<test::components::formatters::TestType::eType>::InitCStringToEnumMap();
-
-template<>
+template <>
+const EnumConversionHelper<TestType::eType>::EnumToCStringMap
+ EnumConversionHelper<
+ test::components::formatters::TestType::eType>::enum_to_cstring_map_ =
+ EnumConversionHelper<test::components::formatters::TestType::eType>::
+ InitEnumToCStringMap();
+
+template <>
+const EnumConversionHelper<TestType::eType>::CStringToEnumMap
+ EnumConversionHelper<
+ test::components::formatters::TestType::eType>::cstring_to_enum_map_ =
+ EnumConversionHelper<test::components::formatters::TestType::eType>::
+ InitCStringToEnumMap();
+
+template <>
const char* const EnumConversionHelper<TestType::eType>::cstring_values_[] = {
- "APPLICATION_NOT_REGISTERED", "SUCCESS", "TOO_MANY_PENDING_REQUESTS",
- "REJECTED", "INVALID_DATA", "OUT_OF_MEMORY", "ABORTED", "USER_DISALLOWED",
- "GENERIC_ERROR", "DISALLOWED" };
-
-template<>
+ "APPLICATION_NOT_REGISTERED",
+ "SUCCESS",
+ "TOO_MANY_PENDING_REQUESTS",
+ "REJECTED",
+ "INVALID_DATA",
+ "OUT_OF_MEMORY",
+ "ABORTED",
+ "USER_DISALLOWED",
+ "GENERIC_ERROR",
+ "DISALLOWED"};
+
+template <>
const TestType::eType EnumConversionHelper<TestType::eType>::enum_values_[] = {
test::components::formatters::TestType::APPLICATION_NOT_REGISTERED,
test::components::formatters::TestType::SUCCESS,
@@ -61,51 +72,64 @@ const TestType::eType EnumConversionHelper<TestType::eType>::enum_values_[] = {
test::components::formatters::TestType::ABORTED,
test::components::formatters::TestType::USER_DISALLOWED,
test::components::formatters::TestType::GENERIC_ERROR,
- test::components::formatters::TestType::DISALLOWED };
-
-template<>
-const EnumConversionHelper<FunctionIdTest::eType>::EnumToCStringMap EnumConversionHelper<
- test::components::formatters::FunctionIdTest::eType>::enum_to_cstring_map_ =
- EnumConversionHelper<test::components::formatters::FunctionIdTest::eType>::InitEnumToCStringMap();
-
-template<>
-const EnumConversionHelper<FunctionIdTest::eType>::CStringToEnumMap EnumConversionHelper<
- test::components::formatters::FunctionIdTest::eType>::cstring_to_enum_map_ =
- EnumConversionHelper<test::components::formatters::FunctionIdTest::eType>::InitCStringToEnumMap();
-
-template<>
-const char* const EnumConversionHelper<FunctionIdTest::eType>::cstring_values_[] =
- { "Function1", "Function2", "Function3" };
-
-template<>
-const FunctionIdTest::eType EnumConversionHelper<FunctionIdTest::eType>::enum_values_[] =
- { test::components::formatters::FunctionIdTest::Function1,
+ test::components::formatters::TestType::DISALLOWED};
+
+template <>
+const EnumConversionHelper<FunctionIdTest::eType>::EnumToCStringMap
+ EnumConversionHelper<test::components::formatters::FunctionIdTest::eType>::
+ enum_to_cstring_map_ = EnumConversionHelper<
+ test::components::formatters::FunctionIdTest::eType>::
+ InitEnumToCStringMap();
+
+template <>
+const EnumConversionHelper<FunctionIdTest::eType>::CStringToEnumMap
+ EnumConversionHelper<test::components::formatters::FunctionIdTest::eType>::
+ cstring_to_enum_map_ = EnumConversionHelper<
+ test::components::formatters::FunctionIdTest::eType>::
+ InitCStringToEnumMap();
+
+template <>
+const char* const
+ EnumConversionHelper<FunctionIdTest::eType>::cstring_values_[] = {
+ "Function1", "Function2", "Function3"};
+
+template <>
+const FunctionIdTest::eType
+ EnumConversionHelper<FunctionIdTest::eType>::enum_values_[] = {
+ test::components::formatters::FunctionIdTest::Function1,
test::components::formatters::FunctionIdTest::Function2,
- test::components::formatters::FunctionIdTest::Function3 };
-
-template<>
-const EnumConversionHelper<MessageTypeTest::eType>::EnumToCStringMap EnumConversionHelper<
- test::components::formatters::MessageTypeTest::eType>::enum_to_cstring_map_ =
- EnumConversionHelper<test::components::formatters::MessageTypeTest::eType>::InitEnumToCStringMap();
-
-template<>
-const EnumConversionHelper<MessageTypeTest::eType>::CStringToEnumMap EnumConversionHelper<
- test::components::formatters::MessageTypeTest::eType>::cstring_to_enum_map_ =
- EnumConversionHelper<test::components::formatters::MessageTypeTest::eType>::InitCStringToEnumMap();
-
-template<>
-const char* const EnumConversionHelper<MessageTypeTest::eType>::cstring_values_[] =
- { "request", "response", "notification" };
-
-template<>
-const MessageTypeTest::eType EnumConversionHelper<MessageTypeTest::eType>::enum_values_[] =
- { test::components::formatters::MessageTypeTest::request,
+ test::components::formatters::FunctionIdTest::Function3};
+
+template <>
+const EnumConversionHelper<MessageTypeTest::eType>::EnumToCStringMap
+ EnumConversionHelper<test::components::formatters::MessageTypeTest::eType>::
+ enum_to_cstring_map_ = EnumConversionHelper<
+ test::components::formatters::MessageTypeTest::eType>::
+ InitEnumToCStringMap();
+
+template <>
+const EnumConversionHelper<MessageTypeTest::eType>::CStringToEnumMap
+ EnumConversionHelper<test::components::formatters::MessageTypeTest::eType>::
+ cstring_to_enum_map_ = EnumConversionHelper<
+ test::components::formatters::MessageTypeTest::eType>::
+ InitCStringToEnumMap();
+
+template <>
+const char* const
+ EnumConversionHelper<MessageTypeTest::eType>::cstring_values_[] = {
+ "request", "response", "notification"};
+
+template <>
+const MessageTypeTest::eType
+ EnumConversionHelper<MessageTypeTest::eType>::enum_values_[] = {
+ test::components::formatters::MessageTypeTest::request,
test::components::formatters::MessageTypeTest::response,
- test::components::formatters::MessageTypeTest::notification };
+ test::components::formatters::MessageTypeTest::notification};
CSmartFactoryTest::CSmartFactoryTest()
- : CSmartFactory<FunctionIdTest::eType, MessageTypeTest::eType,
- StructIdentifiersTest::eType>() {
+ : CSmartFactory<FunctionIdTest::eType,
+ MessageTypeTest::eType,
+ StructIdentifiersTest::eType>() {
TStructsSchemaItems struct_schema_items;
InitStructSchemes(struct_schema_items);
std::set<FunctionIdTest::eType> function_id_items;
@@ -118,51 +142,49 @@ CSmartFactoryTest::CSmartFactoryTest()
message_type_items.insert(MessageTypeTest::response);
message_type_items.insert(MessageTypeTest::notification);
message_type_items.insert(MessageTypeTest::error_response);
- InitFunctionSchemes(struct_schema_items, function_id_items,
- message_type_items);
+ InitFunctionSchemes(
+ struct_schema_items, function_id_items, message_type_items);
}
void CSmartFactoryTest::InitStructSchemes(
- TStructsSchemaItems &struct_schema_items) {
+ TStructsSchemaItems& struct_schema_items) {
utils::SharedPtr<ISchemaItem> struct_schema_item_Common_1 =
InitStructSchemaItem_Common_1(struct_schema_items);
- struct_schema_items.insert(
- std::make_pair(StructIdentifiersTest::Common_1,
- struct_schema_item_Common_1));
+ struct_schema_items.insert(std::make_pair(StructIdentifiersTest::Common_1,
+ struct_schema_item_Common_1));
structs_schemes_.insert(
std::make_pair(StructIdentifiersTest::Common_1,
CSmartSchema(struct_schema_item_Common_1)));
utils::SharedPtr<ISchemaItem> struct_schema_item_Common_2 =
InitStructSchemaItem_Common_2();
- struct_schema_items.insert(
- std::make_pair(StructIdentifiersTest::Common_2,
- struct_schema_item_Common_2));
+ struct_schema_items.insert(std::make_pair(StructIdentifiersTest::Common_2,
+ struct_schema_item_Common_2));
structs_schemes_.insert(
std::make_pair(StructIdentifiersTest::Common_2,
CSmartSchema(struct_schema_item_Common_2)));
}
void CSmartFactoryTest::InitFunctionSchemes(
- const TStructsSchemaItems &struct_schema_items,
- const std::set<FunctionIdTest::eType> &function_id_items,
- const std::set<MessageTypeTest::eType> &message_type_items) {
+ const TStructsSchemaItems& struct_schema_items,
+ const std::set<FunctionIdTest::eType>& function_id_items,
+ const std::set<MessageTypeTest::eType>& message_type_items) {
CObjectSchemaItem::Members params_members;
params_members[S_FUNCTION_ID] = CObjectSchemaItem::SMember(
TEnumSchemaItem<FunctionIdTest::eType>::create(function_id_items), true);
params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(
TEnumSchemaItem<MessageTypeTest::eType>::create(message_type_items),
true);
- params_members[S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
- params_members[S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
- params_members[S_CORRELATION_ID] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
- params_members[kCode] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
- params_members[kMessage] = CObjectSchemaItem::SMember(
- CStringSchemaItem::create(), true);
+ params_members[S_PROTOCOL_VERSION] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[S_PROTOCOL_TYPE] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[S_CORRELATION_ID] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[kCode] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[kMessage] =
+ CObjectSchemaItem::SMember(CStringSchemaItem::create(), true);
CObjectSchemaItem::Members root_members_map;
root_members_map[NsSmartDeviceLink::NsJSONHandler::strings::S_PARAMS] =
@@ -172,68 +194,52 @@ void CSmartFactoryTest::InitFunctionSchemes(
CSmartSchema error_response_schema(
CObjectSchemaItem::create(root_members_map));
- functions_schemes_.insert(
- std::make_pair(
- SmartSchemaKey<FunctionIdTest::eType, MessageTypeTest::eType>(
- FunctionIdTest::Function1, MessageTypeTest::error_response),
- error_response_schema));
- functions_schemes_.insert(
- std::make_pair(
- SmartSchemaKey<FunctionIdTest::eType, MessageTypeTest::eType>(
- FunctionIdTest::Function1, MessageTypeTest::request),
- InitFunction_Function1_request(function_id_items,
- message_type_items)));
- functions_schemes_.insert(
- std::make_pair(
- SmartSchemaKey<FunctionIdTest::eType, MessageTypeTest::eType>(
- FunctionIdTest::Function1, MessageTypeTest::response),
- InitFunction_Function1_response(struct_schema_items,
- function_id_items,
- message_type_items)));
-
- functions_schemes_.insert(
- std::make_pair(
- SmartSchemaKey<FunctionIdTest::eType, MessageTypeTest::eType>(
- FunctionIdTest::Function2, MessageTypeTest::error_response),
- error_response_schema));
- functions_schemes_.insert(
- std::make_pair(
- SmartSchemaKey<FunctionIdTest::eType, MessageTypeTest::eType>(
- FunctionIdTest::Function2, MessageTypeTest::request),
- InitFunction_Function2_request(function_id_items,
- message_type_items)));
- functions_schemes_.insert(
- std::make_pair(
- SmartSchemaKey<FunctionIdTest::eType, MessageTypeTest::eType>(
- FunctionIdTest::Function2, MessageTypeTest::response),
- InitFunction_Function2_response(struct_schema_items,
- function_id_items,
- message_type_items)));
-
- functions_schemes_.insert(
- std::make_pair(
- SmartSchemaKey<FunctionIdTest::eType, MessageTypeTest::eType>(
- FunctionIdTest::Function3, MessageTypeTest::error_response),
- error_response_schema));
- functions_schemes_.insert(
- std::make_pair(
- SmartSchemaKey<FunctionIdTest::eType, MessageTypeTest::eType>(
- FunctionIdTest::Function3, MessageTypeTest::request),
- InitFunction_Function3_request(function_id_items,
- message_type_items)));
- functions_schemes_.insert(
- std::make_pair(
- SmartSchemaKey<FunctionIdTest::eType, MessageTypeTest::eType>(
- FunctionIdTest::Function3, MessageTypeTest::response),
- InitFunction_Function3_response(struct_schema_items,
- function_id_items,
- message_type_items)));
+ functions_schemes_.insert(std::make_pair(
+ SmartSchemaKey<FunctionIdTest::eType, MessageTypeTest::eType>(
+ FunctionIdTest::Function1, MessageTypeTest::error_response),
+ error_response_schema));
+ functions_schemes_.insert(std::make_pair(
+ SmartSchemaKey<FunctionIdTest::eType, MessageTypeTest::eType>(
+ FunctionIdTest::Function1, MessageTypeTest::request),
+ InitFunction_Function1_request(function_id_items, message_type_items)));
+ functions_schemes_.insert(std::make_pair(
+ SmartSchemaKey<FunctionIdTest::eType, MessageTypeTest::eType>(
+ FunctionIdTest::Function1, MessageTypeTest::response),
+ InitFunction_Function1_response(
+ struct_schema_items, function_id_items, message_type_items)));
+
+ functions_schemes_.insert(std::make_pair(
+ SmartSchemaKey<FunctionIdTest::eType, MessageTypeTest::eType>(
+ FunctionIdTest::Function2, MessageTypeTest::error_response),
+ error_response_schema));
+ functions_schemes_.insert(std::make_pair(
+ SmartSchemaKey<FunctionIdTest::eType, MessageTypeTest::eType>(
+ FunctionIdTest::Function2, MessageTypeTest::request),
+ InitFunction_Function2_request(function_id_items, message_type_items)));
+ functions_schemes_.insert(std::make_pair(
+ SmartSchemaKey<FunctionIdTest::eType, MessageTypeTest::eType>(
+ FunctionIdTest::Function2, MessageTypeTest::response),
+ InitFunction_Function2_response(
+ struct_schema_items, function_id_items, message_type_items)));
+
+ functions_schemes_.insert(std::make_pair(
+ SmartSchemaKey<FunctionIdTest::eType, MessageTypeTest::eType>(
+ FunctionIdTest::Function3, MessageTypeTest::error_response),
+ error_response_schema));
+ functions_schemes_.insert(std::make_pair(
+ SmartSchemaKey<FunctionIdTest::eType, MessageTypeTest::eType>(
+ FunctionIdTest::Function3, MessageTypeTest::request),
+ InitFunction_Function3_request(function_id_items, message_type_items)));
+ functions_schemes_.insert(std::make_pair(
+ SmartSchemaKey<FunctionIdTest::eType, MessageTypeTest::eType>(
+ FunctionIdTest::Function3, MessageTypeTest::response),
+ InitFunction_Function3_response(
+ struct_schema_items, function_id_items, message_type_items)));
}
CSmartSchema CSmartFactoryTest::InitFunction_Function1_request(
- const std::set<FunctionIdTest::eType> &function_id_items,
- const std::set<MessageTypeTest::eType> &message_type_items) {
-
+ const std::set<FunctionIdTest::eType>& function_id_items,
+ const std::set<MessageTypeTest::eType>& message_type_items) {
CObjectSchemaItem::Members schema_members;
CObjectSchemaItem::Members params_members;
@@ -242,12 +248,12 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function1_request(
params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(
TEnumSchemaItem<MessageTypeTest::eType>::create(message_type_items),
true);
- params_members[S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
- params_members[S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
- params_members[S_CORRELATION_ID] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
+ params_members[S_PROTOCOL_VERSION] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[S_PROTOCOL_TYPE] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[S_CORRELATION_ID] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
CObjectSchemaItem::Members root_members_map;
root_members_map[S_MSG_PARAMS] = CObjectSchemaItem::SMember(
@@ -259,17 +265,17 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function1_request(
}
CSmartSchema CSmartFactoryTest::InitFunction_Function1_response(
- const TStructsSchemaItems &struct_schema_items,
- const std::set<FunctionIdTest::eType> &function_id_items,
- const std::set<MessageTypeTest::eType> &message_type_items) {
+ const TStructsSchemaItems& struct_schema_items,
+ const std::set<FunctionIdTest::eType>& function_id_items,
+ const std::set<MessageTypeTest::eType>& message_type_items) {
// Function parameter available.
- utils::SharedPtr<ISchemaItem> available_SchemaItem = CBoolSchemaItem::create(
- TSchemaItemParameter<bool>());
+ utils::SharedPtr<ISchemaItem> available_SchemaItem =
+ CBoolSchemaItem::create(TSchemaItemParameter<bool>());
CObjectSchemaItem::Members schema_members;
- schema_members["available"] = CObjectSchemaItem::SMember(available_SchemaItem,
- true);
+ schema_members["available"] =
+ CObjectSchemaItem::SMember(available_SchemaItem, true);
CObjectSchemaItem::Members params_members;
params_members[S_FUNCTION_ID] = CObjectSchemaItem::SMember(
@@ -277,14 +283,14 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function1_response(
params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(
TEnumSchemaItem<MessageTypeTest::eType>::create(message_type_items),
true);
- params_members[S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
- params_members[S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
- params_members[S_CORRELATION_ID] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
- params_members[kCode] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
+ params_members[S_PROTOCOL_VERSION] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[S_PROTOCOL_TYPE] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[S_CORRELATION_ID] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[kCode] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
CObjectSchemaItem::Members root_members_map;
root_members_map[S_MSG_PARAMS] = CObjectSchemaItem::SMember(
@@ -296,8 +302,8 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function1_response(
}
CSmartSchema CSmartFactoryTest::InitFunction_Function2_request(
- const std::set<FunctionIdTest::eType> &function_id_items,
- const std::set<MessageTypeTest::eType> &message_type_items) {
+ const std::set<FunctionIdTest::eType>& function_id_items,
+ const std::set<MessageTypeTest::eType>& message_type_items) {
CObjectSchemaItem::Members schema_members;
CObjectSchemaItem::Members params_members;
@@ -306,12 +312,12 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function2_request(
params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(
TEnumSchemaItem<MessageTypeTest::eType>::create(message_type_items),
true);
- params_members[S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
- params_members[S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
- params_members[S_CORRELATION_ID] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
+ params_members[S_PROTOCOL_VERSION] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[S_PROTOCOL_TYPE] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[S_CORRELATION_ID] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
CObjectSchemaItem::Members root_members_map;
root_members_map[S_MSG_PARAMS] = CObjectSchemaItem::SMember(
@@ -323,17 +329,17 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function2_request(
}
CSmartSchema CSmartFactoryTest::InitFunction_Function2_response(
- const TStructsSchemaItems &struct_schema_items,
- const std::set<FunctionIdTest::eType> &function_id_items,
- const std::set<MessageTypeTest::eType> &message_type_items) {
+ const TStructsSchemaItems& struct_schema_items,
+ const std::set<FunctionIdTest::eType>& function_id_items,
+ const std::set<MessageTypeTest::eType>& message_type_items) {
// Function parameter available.
- utils::SharedPtr<ISchemaItem> available_SchemaItem = CBoolSchemaItem::create(
- TSchemaItemParameter<bool>());
+ utils::SharedPtr<ISchemaItem> available_SchemaItem =
+ CBoolSchemaItem::create(TSchemaItemParameter<bool>());
CObjectSchemaItem::Members schema_members;
- schema_members["available"] = CObjectSchemaItem::SMember(available_SchemaItem,
- true);
+ schema_members["available"] =
+ CObjectSchemaItem::SMember(available_SchemaItem, true);
CObjectSchemaItem::Members params_members;
params_members[S_FUNCTION_ID] = CObjectSchemaItem::SMember(
@@ -341,14 +347,14 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function2_response(
params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(
TEnumSchemaItem<MessageTypeTest::eType>::create(message_type_items),
true);
- params_members[S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
- params_members[S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
- params_members[S_CORRELATION_ID] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
- params_members[kCode] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
+ params_members[S_PROTOCOL_VERSION] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[S_PROTOCOL_TYPE] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[S_CORRELATION_ID] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[kCode] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
CObjectSchemaItem::Members root_members_map;
root_members_map[S_MSG_PARAMS] = CObjectSchemaItem::SMember(
@@ -360,8 +366,8 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function2_response(
}
CSmartSchema CSmartFactoryTest::InitFunction_Function3_request(
- const std::set<FunctionIdTest::eType> &function_id_items,
- const std::set<MessageTypeTest::eType> &message_type_items) {
+ const std::set<FunctionIdTest::eType>& function_id_items,
+ const std::set<MessageTypeTest::eType>& message_type_items) {
CObjectSchemaItem::Members schema_members;
CObjectSchemaItem::Members params_members;
@@ -370,12 +376,12 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function3_request(
params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(
TEnumSchemaItem<MessageTypeTest::eType>::create(message_type_items),
true);
- params_members[S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
- params_members[S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
- params_members[S_CORRELATION_ID] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
+ params_members[S_PROTOCOL_VERSION] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[S_PROTOCOL_TYPE] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[S_CORRELATION_ID] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
CObjectSchemaItem::Members root_members_map;
root_members_map[S_MSG_PARAMS] = CObjectSchemaItem::SMember(
@@ -387,19 +393,19 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function3_request(
}
CSmartSchema CSmartFactoryTest::InitFunction_Function3_response(
- const TStructsSchemaItems &struct_schema_items,
- const std::set<FunctionIdTest::eType> &function_id_items,
- const std::set<MessageTypeTest::eType> &message_type_items) {
+ const TStructsSchemaItems& struct_schema_items,
+ const std::set<FunctionIdTest::eType>& function_id_items,
+ const std::set<MessageTypeTest::eType>& message_type_items) {
// Function parameter available.
//
// Must be true if VR is present and ready to communicate with SDL.
- utils::SharedPtr<ISchemaItem> available_SchemaItem = CBoolSchemaItem::create(
- TSchemaItemParameter<bool>());
+ utils::SharedPtr<ISchemaItem> available_SchemaItem =
+ CBoolSchemaItem::create(TSchemaItemParameter<bool>());
CObjectSchemaItem::Members schema_members;
- schema_members["available"] = CObjectSchemaItem::SMember(available_SchemaItem,
- true);
+ schema_members["available"] =
+ CObjectSchemaItem::SMember(available_SchemaItem, true);
CObjectSchemaItem::Members params_members;
params_members[S_FUNCTION_ID] = CObjectSchemaItem::SMember(
@@ -407,14 +413,14 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function3_response(
params_members[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(
TEnumSchemaItem<MessageTypeTest::eType>::create(message_type_items),
true);
- params_members[S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
- params_members[S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
- params_members[S_CORRELATION_ID] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
- params_members[kCode] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
+ params_members[S_PROTOCOL_VERSION] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[S_PROTOCOL_TYPE] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[S_CORRELATION_ID] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
+ params_members[kCode] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
CObjectSchemaItem::Members root_members_map;
root_members_map[S_MSG_PARAMS] = CObjectSchemaItem::SMember(
@@ -426,13 +432,14 @@ CSmartSchema CSmartFactoryTest::InitFunction_Function3_response(
}
utils::SharedPtr<ISchemaItem> CSmartFactoryTest::InitStructSchemaItem_Common_1(
- TStructsSchemaItems &struct_schema_items) {
+ TStructsSchemaItems& struct_schema_items) {
// Struct member text.
//
// Text to display
- utils::SharedPtr<ISchemaItem> text_SchemaItem = CStringSchemaItem::create(
- TSchemaItemParameter<size_t>(1), TSchemaItemParameter<size_t>(500),
- TSchemaItemParameter<std::string>());
+ utils::SharedPtr<ISchemaItem> text_SchemaItem =
+ CStringSchemaItem::create(TSchemaItemParameter<size_t>(1),
+ TSchemaItemParameter<size_t>(500),
+ TSchemaItemParameter<std::string>());
// Struct member image.
//
@@ -454,8 +461,8 @@ utils::SharedPtr<ISchemaItem> CSmartFactoryTest::InitStructSchemaItem_Common_1(
CObjectSchemaItem::Members schema_members;
schema_members["text"] = CObjectSchemaItem::SMember(text_SchemaItem, true);
- schema_members["position"] = CObjectSchemaItem::SMember(position_SchemaItem,
- true);
+ schema_members["position"] =
+ CObjectSchemaItem::SMember(position_SchemaItem, true);
CObjectSchemaItem::Members root_members_map;
root_members_map[""] = CObjectSchemaItem::SMember(
@@ -465,13 +472,15 @@ utils::SharedPtr<ISchemaItem> CSmartFactoryTest::InitStructSchemaItem_Common_1(
return CObjectSchemaItem::create(schema_members);
}
-utils::SharedPtr<ISchemaItem> CSmartFactoryTest::InitStructSchemaItem_Common_2() {
+utils::SharedPtr<ISchemaItem>
+CSmartFactoryTest::InitStructSchemaItem_Common_2() {
// Struct member text.
//
// Text to display
- utils::SharedPtr<ISchemaItem> text_SchemaItem = CStringSchemaItem::create(
- TSchemaItemParameter<size_t>(1), TSchemaItemParameter<size_t>(500),
- TSchemaItemParameter<std::string>());
+ utils::SharedPtr<ISchemaItem> text_SchemaItem =
+ CStringSchemaItem::create(TSchemaItemParameter<size_t>(1),
+ TSchemaItemParameter<size_t>(500),
+ TSchemaItemParameter<std::string>());
// Struct member position.
//
// Position to display item
@@ -482,20 +491,20 @@ utils::SharedPtr<ISchemaItem> CSmartFactoryTest::InitStructSchemaItem_Common_2()
CObjectSchemaItem::Members schema_members;
schema_members["text"] = CObjectSchemaItem::SMember(text_SchemaItem, true);
- schema_members["position"] = CObjectSchemaItem::SMember(position_SchemaItem,
- true);
+ schema_members["position"] =
+ CObjectSchemaItem::SMember(position_SchemaItem, true);
return CObjectSchemaItem::create(schema_members);
}
-utils::SharedPtr<ISchemaItem> CSmartFactoryTest::ProvideObjectSchemaItemForStruct(
- TStructsSchemaItems &struct_schema_items,
+utils::SharedPtr<ISchemaItem>
+CSmartFactoryTest::ProvideObjectSchemaItemForStruct(
+ TStructsSchemaItems& struct_schema_items,
const StructIdentifiersTest::eType struct_id) {
- const TStructsSchemaItems::const_iterator it = struct_schema_items.find(
- struct_id);
+ const TStructsSchemaItems::const_iterator it =
+ struct_schema_items.find(struct_id);
if (it != struct_schema_items.end()) {
return it->second;
}
return NsSmartDeviceLink::NsSmartObjects::CAlwaysFalseSchemaItem::create();
}
-
diff --git a/src/components/formatters/test/src/create_smartSchema.cc b/src/components/formatters/test/src/create_smartSchema.cc
index 9d44567dcd..75663d4488 100644
--- a/src/components/formatters/test/src/create_smartSchema.cc
+++ b/src/components/formatters/test/src/create_smartSchema.cc
@@ -30,7 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "create_smartSchema.h"
+#include "formatters/create_smartSchema.h"
namespace test {
namespace components {
namespace formatters {
@@ -39,82 +39,105 @@ using namespace NsSmartDeviceLink::NsJSONHandler::strings;
using namespace NsSmartDeviceLink::NsJSONHandler::Formatters;
using namespace NsSmartDeviceLink::NsSmartObjects;
-template<>
-const EnumConversionHelper<FunctionIDTest::eType>::EnumToCStringMap EnumConversionHelper<
- test::components::formatters::FunctionIDTest::eType>::enum_to_cstring_map_ =
- EnumConversionHelper<test::components::formatters::FunctionIDTest::eType>::InitEnumToCStringMap();
-
-template<>
-const EnumConversionHelper<FunctionIDTest::eType>::CStringToEnumMap EnumConversionHelper<
- test::components::formatters::FunctionIDTest::eType>::cstring_to_enum_map_ =
- EnumConversionHelper<test::components::formatters::FunctionIDTest::eType>::InitCStringToEnumMap();
-
-template<>
-const char* const EnumConversionHelper<FunctionIDTest::eType>::cstring_values_[] =
- { "RegisterAppInterface", "UnregisterAppInterface", "SetGlobalProperties" };
-
-template<>
-const FunctionIDTest::eType EnumConversionHelper<FunctionIDTest::eType>::enum_values_[] =
- { test::components::formatters::FunctionIDTest::RegisterAppInterface,
+template <>
+const EnumConversionHelper<FunctionIDTest::eType>::EnumToCStringMap
+ EnumConversionHelper<test::components::formatters::FunctionIDTest::eType>::
+ enum_to_cstring_map_ = EnumConversionHelper<
+ test::components::formatters::FunctionIDTest::eType>::
+ InitEnumToCStringMap();
+
+template <>
+const EnumConversionHelper<FunctionIDTest::eType>::CStringToEnumMap
+ EnumConversionHelper<test::components::formatters::FunctionIDTest::eType>::
+ cstring_to_enum_map_ = EnumConversionHelper<
+ test::components::formatters::FunctionIDTest::eType>::
+ InitCStringToEnumMap();
+
+template <>
+const char* const
+ EnumConversionHelper<FunctionIDTest::eType>::cstring_values_[] = {
+ "RegisterAppInterface",
+ "UnregisterAppInterface",
+ "SetGlobalProperties"};
+
+template <>
+const FunctionIDTest::eType
+ EnumConversionHelper<FunctionIDTest::eType>::enum_values_[] = {
+ test::components::formatters::FunctionIDTest::RegisterAppInterface,
test::components::formatters::FunctionIDTest::UnregisterAppInterface,
- test::components::formatters::FunctionIDTest::SetGlobalProperties };
-
-template<>
-const EnumConversionHelper<Language::eType>::EnumToCStringMap EnumConversionHelper<
- test::components::formatters::Language::eType>::enum_to_cstring_map_ =
- EnumConversionHelper<test::components::formatters::Language::eType>::InitEnumToCStringMap();
-
-template<>
-const EnumConversionHelper<Language::eType>::CStringToEnumMap EnumConversionHelper<
- test::components::formatters::Language::eType>::cstring_to_enum_map_ =
- EnumConversionHelper<test::components::formatters::Language::eType>::InitCStringToEnumMap();
-
-template<>
-const char* const EnumConversionHelper<Language::eType>::cstring_values_[] =
- { "EN_EU", "RU_RU"};
-
-template<>
-const Language::eType EnumConversionHelper<Language::eType>::enum_values_[] =
- { test::components::formatters::Language::EN_EU,
- test::components::formatters::Language::RU_RU};
-
-template<>
-const EnumConversionHelper<SpeechCapabilities::eType>::EnumToCStringMap EnumConversionHelper<
- test::components::formatters::SpeechCapabilities::eType>::enum_to_cstring_map_ =
- EnumConversionHelper<test::components::formatters::SpeechCapabilities::eType>::InitEnumToCStringMap();
-
-template<>
-const EnumConversionHelper<SpeechCapabilities::eType>::CStringToEnumMap EnumConversionHelper<
- test::components::formatters::SpeechCapabilities::eType>::cstring_to_enum_map_ =
- EnumConversionHelper<test::components::formatters::SpeechCapabilities::eType>::InitCStringToEnumMap();
-
-template<>
-const char* const EnumConversionHelper<SpeechCapabilities::eType>::cstring_values_[] =
- { "SC_TEXT"};
-
-template<>
-const SpeechCapabilities::eType EnumConversionHelper<SpeechCapabilities::eType>::enum_values_[] =
- { test::components::formatters::SpeechCapabilities::SC_TEXT};
-
-template<>
-const EnumConversionHelper<AppTypeTest::eType>::EnumToCStringMap EnumConversionHelper<
- test::components::formatters::AppTypeTest::eType>::enum_to_cstring_map_ =
- EnumConversionHelper<test::components::formatters::AppTypeTest::eType>::InitEnumToCStringMap();
-
-template<>
-const EnumConversionHelper<AppTypeTest::eType>::CStringToEnumMap EnumConversionHelper<
- test::components::formatters::AppTypeTest::eType>::cstring_to_enum_map_ =
- EnumConversionHelper<test::components::formatters::AppTypeTest::eType>::InitCStringToEnumMap();
-
-template<>
+ test::components::formatters::FunctionIDTest::SetGlobalProperties};
+
+template <>
+const EnumConversionHelper<Language::eType>::EnumToCStringMap
+ EnumConversionHelper<
+ test::components::formatters::Language::eType>::enum_to_cstring_map_ =
+ EnumConversionHelper<test::components::formatters::Language::eType>::
+ InitEnumToCStringMap();
+
+template <>
+const EnumConversionHelper<Language::eType>::CStringToEnumMap
+ EnumConversionHelper<
+ test::components::formatters::Language::eType>::cstring_to_enum_map_ =
+ EnumConversionHelper<test::components::formatters::Language::eType>::
+ InitCStringToEnumMap();
+
+template <>
+const char* const EnumConversionHelper<Language::eType>::cstring_values_[] = {
+ "EN_EU", "RU_RU"};
+
+template <>
+const Language::eType EnumConversionHelper<Language::eType>::enum_values_[] = {
+ test::components::formatters::Language::EN_EU,
+ test::components::formatters::Language::RU_RU};
+
+template <>
+const EnumConversionHelper<SpeechCapabilities::eType>::EnumToCStringMap
+ EnumConversionHelper<test::components::formatters::SpeechCapabilities::
+ eType>::enum_to_cstring_map_ =
+ EnumConversionHelper<test::components::formatters::SpeechCapabilities::
+ eType>::InitEnumToCStringMap();
+
+template <>
+const EnumConversionHelper<SpeechCapabilities::eType>::CStringToEnumMap
+ EnumConversionHelper<test::components::formatters::SpeechCapabilities::
+ eType>::cstring_to_enum_map_ =
+ EnumConversionHelper<test::components::formatters::SpeechCapabilities::
+ eType>::InitCStringToEnumMap();
+
+template <>
+const char* const
+ EnumConversionHelper<SpeechCapabilities::eType>::cstring_values_[] = {
+ "SC_TEXT"};
+
+template <>
+const SpeechCapabilities::eType
+ EnumConversionHelper<SpeechCapabilities::eType>::enum_values_[] = {
+ test::components::formatters::SpeechCapabilities::SC_TEXT};
+
+template <>
+const EnumConversionHelper<AppTypeTest::eType>::EnumToCStringMap
+ EnumConversionHelper<test::components::formatters::AppTypeTest::eType>::
+ enum_to_cstring_map_ = EnumConversionHelper<
+ test::components::formatters::AppTypeTest::eType>::
+ InitEnumToCStringMap();
+
+template <>
+const EnumConversionHelper<AppTypeTest::eType>::CStringToEnumMap
+ EnumConversionHelper<test::components::formatters::AppTypeTest::eType>::
+ cstring_to_enum_map_ = EnumConversionHelper<
+ test::components::formatters::AppTypeTest::eType>::
+ InitCStringToEnumMap();
+
+template <>
const char* const EnumConversionHelper<AppTypeTest::eType>::cstring_values_[] =
- { "SYSTEM", "MEDIA"};
+ {"SYSTEM", "MEDIA"};
-template<>
-const AppTypeTest::eType EnumConversionHelper<AppTypeTest::eType>::enum_values_[] =
- { test::components::formatters::AppTypeTest::SYSTEM,
- test::components::formatters::AppTypeTest::MEDIA,
- };
+template <>
+const AppTypeTest::eType
+ EnumConversionHelper<AppTypeTest::eType>::enum_values_[] = {
+ test::components::formatters::AppTypeTest::SYSTEM,
+ test::components::formatters::AppTypeTest::MEDIA,
+};
CSmartSchema initObjectSchema() {
std::set<TestType::eType> resultCode_allowedEnumSubsetValues;
@@ -147,50 +170,52 @@ CSmartSchema initObjectSchema() {
messageType_allowedEnumSubsetValues.insert(MessageTypeTest::notification);
// Create result item
- ISchemaItemPtr success_SchemaItem = CBoolSchemaItem::create(
- TSchemaItemParameter<bool>());
+ ISchemaItemPtr success_SchemaItem =
+ CBoolSchemaItem::create(TSchemaItemParameter<bool>());
ISchemaItemPtr resultCode_SchemaItem =
TEnumSchemaItem<TestType::eType>::create(
resultCode_allowedEnumSubsetValues,
TSchemaItemParameter<TestType::eType>());
// Create info value with min 0 length and max 1000
- ISchemaItemPtr info_SchemaItem = CStringSchemaItem::create(
- TSchemaItemParameter<size_t>(0), TSchemaItemParameter<size_t>(1000),
- TSchemaItemParameter<std::string>());
+ ISchemaItemPtr info_SchemaItem =
+ CStringSchemaItem::create(TSchemaItemParameter<size_t>(0),
+ TSchemaItemParameter<size_t>(1000),
+ TSchemaItemParameter<std::string>());
- ISchemaItemPtr tryAgainTime_SchemaItem = TNumberSchemaItem<int>::create(
- TSchemaItemParameter<int>(0), TSchemaItemParameter<int>(2000000000),
- TSchemaItemParameter<int>());
+ ISchemaItemPtr tryAgainTime_SchemaItem =
+ TNumberSchemaItem<int>::create(TSchemaItemParameter<int>(0),
+ TSchemaItemParameter<int>(2000000000),
+ TSchemaItemParameter<int>());
// Map of parameters
std::map<std::string, CObjectSchemaItem::SMember> schemaMembersMap;
- schemaMembersMap["success"] = CObjectSchemaItem::SMember(success_SchemaItem,
- false);
- schemaMembersMap["resultCode"] = CObjectSchemaItem::SMember(
- resultCode_SchemaItem, false);
+ schemaMembersMap["success"] =
+ CObjectSchemaItem::SMember(success_SchemaItem, false);
+ schemaMembersMap["resultCode"] =
+ CObjectSchemaItem::SMember(resultCode_SchemaItem, false);
schemaMembersMap["info"] = CObjectSchemaItem::SMember(info_SchemaItem, false);
- schemaMembersMap["tryAgainTime"] = CObjectSchemaItem::SMember(
- tryAgainTime_SchemaItem, false);
+ schemaMembersMap["tryAgainTime"] =
+ CObjectSchemaItem::SMember(tryAgainTime_SchemaItem, false);
std::map<std::string, CObjectSchemaItem::SMember> paramsMembersMap;
- paramsMembersMap[S_FUNCTION_ID] = CObjectSchemaItem::SMember(
- TEnumSchemaItem<FunctionIDTest::eType>::create(
- functionId_allowedEnumSubsetValues),
- true);
+ paramsMembersMap[S_FUNCTION_ID] =
+ CObjectSchemaItem::SMember(TEnumSchemaItem<FunctionIDTest::eType>::create(
+ functionId_allowedEnumSubsetValues),
+ true);
paramsMembersMap[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(
TEnumSchemaItem<MessageTypeTest::eType>::create(
messageType_allowedEnumSubsetValues),
true);
- paramsMembersMap[S_CORRELATION_ID] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
+ paramsMembersMap[S_CORRELATION_ID] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
paramsMembersMap[S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(
TNumberSchemaItem<int>::create(TSchemaItemParameter<int>(1),
TSchemaItemParameter<int>(2)),
true);
- paramsMembersMap[S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
+ paramsMembersMap[S_PROTOCOL_TYPE] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
std::map<std::string, CObjectSchemaItem::SMember> rootMembersMap;
rootMembersMap[S_MSG_PARAMS] = CObjectSchemaItem::SMember(
@@ -200,7 +225,6 @@ CSmartSchema initObjectSchema() {
return CSmartSchema(CObjectSchemaItem::create(rootMembersMap));
};
-
CSmartSchema initSchemaForMetaFormatter() {
std::set<TestType::eType> resultCode_allowedEnumSubsetValues;
resultCode_allowedEnumSubsetValues.insert(
@@ -229,13 +253,14 @@ CSmartSchema initSchemaForMetaFormatter() {
languageDesired_allowedEnumSubsetValues.insert(Language::RU_RU);
languageDesired_allowedEnumSubsetValues.insert(Language::EN_EU);
-
std::set<AppTypeTest::eType> appType_allowedEnumSubsetValues;
appType_allowedEnumSubsetValues.insert(AppTypeTest::SYSTEM);
appType_allowedEnumSubsetValues.insert(AppTypeTest::MEDIA);
- std::set<SpeechCapabilities::eType> speechCapabilities_allowedEnumSubsetValues;
- speechCapabilities_allowedEnumSubsetValues.insert(SpeechCapabilities::SC_TEXT);
+ std::set<SpeechCapabilities::eType>
+ speechCapabilities_allowedEnumSubsetValues;
+ speechCapabilities_allowedEnumSubsetValues.insert(
+ SpeechCapabilities::SC_TEXT);
// Possible message types
std::set<MessageTypeTest::eType> messageType_allowedEnumSubsetValues;
@@ -244,21 +269,25 @@ CSmartSchema initSchemaForMetaFormatter() {
messageType_allowedEnumSubsetValues.insert(MessageTypeTest::notification);
// Create param items
- ISchemaItemPtr appID_SchemaItem = CStringSchemaItem::create(
- TSchemaItemParameter<size_t>(0), TSchemaItemParameter<size_t>(1000),
- TSchemaItemParameter<std::string>());
- ISchemaItemPtr appName_SchemaItem = CStringSchemaItem::create(
- TSchemaItemParameter<size_t>(0), TSchemaItemParameter<size_t>(1000),
- TSchemaItemParameter<std::string>());
- ISchemaItemPtr isMediaApplication_SchemaItem = CBoolSchemaItem::create(
- TSchemaItemParameter<bool>());
- ISchemaItemPtr ngnMediaScreenAppName_SchemaItem = CStringSchemaItem::create(
- TSchemaItemParameter<size_t>(0), TSchemaItemParameter<size_t>(1000),
- TSchemaItemParameter<std::string>());
-
- ISchemaItemPtr ttsNameItem_SchemaItem = CStringSchemaItem::create(
- TSchemaItemParameter<size_t>(0), TSchemaItemParameter<size_t>(1000),
- TSchemaItemParameter<std::string>());
+ ISchemaItemPtr appID_SchemaItem =
+ CStringSchemaItem::create(TSchemaItemParameter<size_t>(0),
+ TSchemaItemParameter<size_t>(1000),
+ TSchemaItemParameter<std::string>());
+ ISchemaItemPtr appName_SchemaItem =
+ CStringSchemaItem::create(TSchemaItemParameter<size_t>(0),
+ TSchemaItemParameter<size_t>(1000),
+ TSchemaItemParameter<std::string>());
+ ISchemaItemPtr isMediaApplication_SchemaItem =
+ CBoolSchemaItem::create(TSchemaItemParameter<bool>());
+ ISchemaItemPtr ngnMediaScreenAppName_SchemaItem =
+ CStringSchemaItem::create(TSchemaItemParameter<size_t>(0),
+ TSchemaItemParameter<size_t>(1000),
+ TSchemaItemParameter<std::string>());
+
+ ISchemaItemPtr ttsNameItem_SchemaItem =
+ CStringSchemaItem::create(TSchemaItemParameter<size_t>(0),
+ TSchemaItemParameter<size_t>(1000),
+ TSchemaItemParameter<std::string>());
ISchemaItemPtr ttstype_SchemaItem =
TEnumSchemaItem<SpeechCapabilities::eType>::create(
@@ -266,10 +295,9 @@ CSmartSchema initSchemaForMetaFormatter() {
TSchemaItemParameter<SpeechCapabilities::eType>());
std::map<std::string, CObjectSchemaItem::SMember> ttsMap;
- ttsMap["text"]=CObjectSchemaItem::SMember(ttsNameItem_SchemaItem,
- false);
- ttsMap["type"]=CObjectSchemaItem::SMember(ttstype_SchemaItem,
- false);;
+ ttsMap["text"] = CObjectSchemaItem::SMember(ttsNameItem_SchemaItem, false);
+ ttsMap["type"] = CObjectSchemaItem::SMember(ttstype_SchemaItem, false);
+ ;
ISchemaItemPtr hmiDisplayLanguageDesired_SchemaItem =
TEnumSchemaItem<Language::eType>::create(
@@ -281,9 +309,10 @@ CSmartSchema initSchemaForMetaFormatter() {
languageDesired_allowedEnumSubsetValues,
TSchemaItemParameter<Language::eType>());
- ISchemaItemPtr vrElementSchemaItem = CStringSchemaItem::create(
- TSchemaItemParameter<size_t>(0), TSchemaItemParameter<size_t>(1000),
- TSchemaItemParameter<std::string>());
+ ISchemaItemPtr vrElementSchemaItem =
+ CStringSchemaItem::create(TSchemaItemParameter<size_t>(0),
+ TSchemaItemParameter<size_t>(1000),
+ TSchemaItemParameter<std::string>());
ISchemaItemPtr appTypeElementSchemaItem =
TEnumSchemaItem<AppTypeTest::eType>::create(
@@ -294,75 +323,81 @@ CSmartSchema initSchemaForMetaFormatter() {
ISchemaItemPtr ttsName_SchemaItem =
CArraySchemaItem::create(ttsElementSchemaItem,
- TSchemaItemParameter<size_t>(0), TSchemaItemParameter<size_t>(1000));
+ TSchemaItemParameter<size_t>(0),
+ TSchemaItemParameter<size_t>(1000));
ISchemaItemPtr vrSynonyms_SchemaItem =
CArraySchemaItem::create(vrElementSchemaItem,
- TSchemaItemParameter<size_t>(0), TSchemaItemParameter<size_t>(1000));
+ TSchemaItemParameter<size_t>(0),
+ TSchemaItemParameter<size_t>(1000));
ISchemaItemPtr appType_SchemaItem =
CArraySchemaItem::create(appTypeElementSchemaItem,
- TSchemaItemParameter<size_t>(0), TSchemaItemParameter<size_t>(1000));
-
+ TSchemaItemParameter<size_t>(0),
+ TSchemaItemParameter<size_t>(1000));
ISchemaItemPtr majorVersion_SchemaItem = TNumberSchemaItem<int>::create();
ISchemaItemPtr minorVersion_SchemaItem = TNumberSchemaItem<int>::create();
- ISchemaItemPtr syncMsg_SchemaItem =CStringSchemaItem::create(
- TSchemaItemParameter<size_t>(0), TSchemaItemParameter<size_t>(1000),
- TSchemaItemParameter<std::string>());
+ ISchemaItemPtr syncMsg_SchemaItem =
+ CStringSchemaItem::create(TSchemaItemParameter<size_t>(0),
+ TSchemaItemParameter<size_t>(1000),
+ TSchemaItemParameter<std::string>());
ISchemaItemPtr syncMsgVersion_SchemaItem =
CArraySchemaItem::create(syncMsg_SchemaItem,
- TSchemaItemParameter<size_t>(0), TSchemaItemParameter<size_t>(1000));
+ TSchemaItemParameter<size_t>(0),
+ TSchemaItemParameter<size_t>(1000));
// Creation map for syncMsgVersion
std::map<std::string, CObjectSchemaItem::SMember> schemaSyncMsgVersionMap;
- schemaSyncMsgVersionMap["majorVersion"]=CObjectSchemaItem::SMember(majorVersion_SchemaItem,
- false);
- schemaSyncMsgVersionMap["minorVersion"]=CObjectSchemaItem::SMember(minorVersion_SchemaItem,
- false);;
+ schemaSyncMsgVersionMap["majorVersion"] =
+ CObjectSchemaItem::SMember(majorVersion_SchemaItem, false);
+ schemaSyncMsgVersionMap["minorVersion"] =
+ CObjectSchemaItem::SMember(minorVersion_SchemaItem, false);
+ ;
// Map of parameters
std::map<std::string, CObjectSchemaItem::SMember> schemaMembersMap;
- schemaMembersMap["appID"] = CObjectSchemaItem::SMember(appID_SchemaItem,
- false);
- schemaMembersMap["appName"] = CObjectSchemaItem::SMember(appName_SchemaItem,
- false);
- schemaMembersMap["appType"] = CObjectSchemaItem::SMember(appType_SchemaItem,
- false);
- schemaMembersMap["hmiDisplayLanguageDesired"] = CObjectSchemaItem::SMember(hmiDisplayLanguageDesired_SchemaItem,
- false);
- schemaMembersMap["isMediaApplication"] = CObjectSchemaItem::SMember(isMediaApplication_SchemaItem,
- false);
- schemaMembersMap["languageDesired"] = CObjectSchemaItem::SMember(languageDesired_SchemaItem,
- false);
- schemaMembersMap["ngnMediaScreenAppName"] = CObjectSchemaItem::SMember(ngnMediaScreenAppName_SchemaItem,
- false);
- schemaMembersMap["syncMsgVersion"] = CObjectSchemaItem::SMember(CObjectSchemaItem::create(schemaSyncMsgVersionMap),
- false);
- schemaMembersMap["ttsName"] = CObjectSchemaItem::SMember(ttsName_SchemaItem,
- false);
- schemaMembersMap["vrSynonyms"] = CObjectSchemaItem::SMember(vrSynonyms_SchemaItem, false);
+ schemaMembersMap["appID"] =
+ CObjectSchemaItem::SMember(appID_SchemaItem, false);
+ schemaMembersMap["appName"] =
+ CObjectSchemaItem::SMember(appName_SchemaItem, false);
+ schemaMembersMap["appType"] =
+ CObjectSchemaItem::SMember(appType_SchemaItem, false);
+ schemaMembersMap["hmiDisplayLanguageDesired"] =
+ CObjectSchemaItem::SMember(hmiDisplayLanguageDesired_SchemaItem, false);
+ schemaMembersMap["isMediaApplication"] =
+ CObjectSchemaItem::SMember(isMediaApplication_SchemaItem, false);
+ schemaMembersMap["languageDesired"] =
+ CObjectSchemaItem::SMember(languageDesired_SchemaItem, false);
+ schemaMembersMap["ngnMediaScreenAppName"] =
+ CObjectSchemaItem::SMember(ngnMediaScreenAppName_SchemaItem, false);
+ schemaMembersMap["syncMsgVersion"] = CObjectSchemaItem::SMember(
+ CObjectSchemaItem::create(schemaSyncMsgVersionMap), false);
+ schemaMembersMap["ttsName"] =
+ CObjectSchemaItem::SMember(ttsName_SchemaItem, false);
+ schemaMembersMap["vrSynonyms"] =
+ CObjectSchemaItem::SMember(vrSynonyms_SchemaItem, false);
std::map<std::string, CObjectSchemaItem::SMember> paramsMembersMap;
- paramsMembersMap[S_FUNCTION_ID] = CObjectSchemaItem::SMember(
- TEnumSchemaItem<FunctionIDTest::eType>::create(
- functionId_allowedEnumSubsetValues),
- true);
+ paramsMembersMap[S_FUNCTION_ID] =
+ CObjectSchemaItem::SMember(TEnumSchemaItem<FunctionIDTest::eType>::create(
+ functionId_allowedEnumSubsetValues),
+ true);
paramsMembersMap[S_MESSAGE_TYPE] = CObjectSchemaItem::SMember(
TEnumSchemaItem<MessageTypeTest::eType>::create(
messageType_allowedEnumSubsetValues),
true);
- paramsMembersMap[S_CORRELATION_ID] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
+ paramsMembersMap[S_CORRELATION_ID] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
paramsMembersMap[S_PROTOCOL_VERSION] = CObjectSchemaItem::SMember(
TNumberSchemaItem<int>::create(TSchemaItemParameter<int>(1),
TSchemaItemParameter<int>(2)),
true);
- paramsMembersMap[S_PROTOCOL_TYPE] = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(), true);
+ paramsMembersMap[S_PROTOCOL_TYPE] =
+ CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
std::map<std::string, CObjectSchemaItem::SMember> rootMembersMap;
rootMembersMap[S_MSG_PARAMS] = CObjectSchemaItem::SMember(
@@ -372,8 +407,6 @@ CSmartSchema initSchemaForMetaFormatter() {
return CSmartSchema(CObjectSchemaItem::create(rootMembersMap));
};
-
-
} // namespace formatters
} // namespace components
} // namespace test
diff --git a/src/components/formatters/test/src/meta_formatter_test_helper.cc b/src/components/formatters/test/src/meta_formatter_test_helper.cc
index 3445d948bb..a963c08a52 100644
--- a/src/components/formatters/test/src/meta_formatter_test_helper.cc
+++ b/src/components/formatters/test/src/meta_formatter_test_helper.cc
@@ -30,7 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "gtest/gtest.h"
-#include "meta_formatter_test_helper.h"
+#include "formatters/meta_formatter_test_helper.h"
namespace test {
namespace components {
@@ -58,7 +58,6 @@ void CMetaFormatterTestHelper::TearDown() {
void CMetaFormatterTestHelper::AnyObjectToJsonString(
const SmartObject& obj, std::string& result_string) {
-
Json::Value params(Json::objectValue);
SmartObject formattedObj(obj);
@@ -71,7 +70,6 @@ void CMetaFormatterTestHelper::AnyObjectToJsonString(
//-----------------------------------------------------------
void CMetaFormatterTestHelper::FillObjectIdenticalToSchema(SmartObject& obj) {
-
obj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request;
obj[S_PARAMS][S_FUNCTION_ID] = FunctionIDTest::RegisterAppInterface;
obj[S_PARAMS][S_CORRELATION_ID] = 12;
@@ -95,8 +93,8 @@ void CMetaFormatterTestHelper::FillObjectIdenticalToSchema(SmartObject& obj) {
}
//-----------------------------------------------------------
-void CMetaFormatterTestHelper::FillObjectIdenticalToSchemaWithoutNoMandatoriesParams(
- SmartObject& obj) {
+void CMetaFormatterTestHelper::
+ FillObjectIdenticalToSchemaWithoutNoMandatoriesParams(SmartObject& obj) {
obj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request;
obj[S_PARAMS][S_FUNCTION_ID] = FunctionIDTest::RegisterAppInterface;
obj[S_PARAMS][S_CORRELATION_ID] = 12;
@@ -113,16 +111,15 @@ void CMetaFormatterTestHelper::FillObjectIdenticalToSchemaWithoutNoMandatoriesPa
obj[S_MSG_PARAMS]["appID"] = "APP ID";
// Commented not mandatory params for check creation object without them
-// obj[S_MSG_PARAMS]["ttsName"][0]["text"] = "ABC";
-// obj[S_MSG_PARAMS]["ttsName"][0]["type"] =
-// SpeechCapabilities::SC_TEXT;
-
-// obj[S_MSG_PARAMS]["vrSynonyms"][0] = "Synonym1";
-// obj[S_MSG_PARAMS]["vrSynonyms"][1] = "Synonym2";
+ // obj[S_MSG_PARAMS]["ttsName"][0]["text"] = "ABC";
+ // obj[S_MSG_PARAMS]["ttsName"][0]["type"] =
+ // SpeechCapabilities::SC_TEXT;
-// obj[S_MSG_PARAMS]["appType"][0] = AppTypeTest::SYSTEM; // not mandatory
-// obj[S_MSG_PARAMS]["appType"][1] = AppTypeTest::MEDIA;
+ // obj[S_MSG_PARAMS]["vrSynonyms"][0] = "Synonym1";
+ // obj[S_MSG_PARAMS]["vrSynonyms"][1] = "Synonym2";
+ // obj[S_MSG_PARAMS]["appType"][0] = AppTypeTest::SYSTEM; // not mandatory
+ // obj[S_MSG_PARAMS]["appType"][1] = AppTypeTest::MEDIA;
}
void CMetaFormatterTestHelper::FillObjectWithoutSomeMandatoryFields(
@@ -133,10 +130,10 @@ void CMetaFormatterTestHelper::FillObjectWithoutSomeMandatoryFields(
obj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
obj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
-// Commented mandatory params for check creation object without them
-// obj[S_PARAMS][S_CORRELATION_ID] = 12;
-// obj[S_MSG_PARAMS]["syncMsgVersion"]["majorVersion"] = 2;
-// obj[S_MSG_PARAMS]["syncMsgVersion"]["minorVersion"] = 10;
+ // Commented mandatory params for check creation object without them
+ // obj[S_PARAMS][S_CORRELATION_ID] = 12;
+ // obj[S_MSG_PARAMS]["syncMsgVersion"]["majorVersion"] = 2;
+ // obj[S_MSG_PARAMS]["syncMsgVersion"]["minorVersion"] = 10;
obj[S_MSG_PARAMS]["appName"] = "APP NAME";
obj[S_MSG_PARAMS]["ttsName"][0]["text"] = "ABC";
@@ -156,7 +153,6 @@ void CMetaFormatterTestHelper::FillObjectWithoutSomeMandatoryFields(
void CMetaFormatterTestHelper::CompareObjects(const SmartObject& first,
const SmartObject& second) {
-
if (SmartType_Array == first.getType()) {
ASSERT_EQ(SmartType_Array, second.getType());
for (size_t i = 0; i < first.length(); i++) {
@@ -164,10 +160,11 @@ void CMetaFormatterTestHelper::CompareObjects(const SmartObject& first,
}
} else if (SmartType_Map == first.getType()) {
ASSERT_EQ(SmartType_Map, second.getType());
- std::set < std::string > keys = first.enumerate();
+ std::set<std::string> keys = first.enumerate();
for (std::set<std::string>::const_iterator key = keys.begin();
- key != keys.end(); key++) {
+ key != keys.end();
+ key++) {
CompareObjects(first.getElement(*key), second.getElement(*key));
}
} else if (SmartType_Boolean == first.getType()) {
@@ -181,14 +178,13 @@ void CMetaFormatterTestHelper::CompareObjects(const SmartObject& first,
} else if (SmartType_Null == first.getType()) {
ASSERT_EQ(SmartType_Null, second.getType());
} else {
- FAIL()<< "Unknown SmartObject type: " << first.getType();
+ FAIL() << "Unknown SmartObject type: " << first.getType();
}
}
//-----------------------------------------------------------
void CMetaFormatterTestHelper::FillObjectWithDefaultValues(SmartObject& obj) {
-
obj[S_PARAMS][S_MESSAGE_TYPE] = -1;
obj[S_PARAMS][S_FUNCTION_ID] = -1;
obj[S_PARAMS][S_CORRELATION_ID] = 0;
@@ -204,17 +200,16 @@ void CMetaFormatterTestHelper::FillObjectWithDefaultValues(SmartObject& obj) {
obj[S_MSG_PARAMS]["hmiDisplayLanguageDesired"] = -1;
obj[S_MSG_PARAMS]["appID"] = "";
-// Commented params for check creation object with only default values
-// obj[S_MSG_PARAMS]["ttsName"][0]["text"] = "ABC";
-// obj[S_MSG_PARAMS]["ttsName"][0]["type"] =
-// SpeechCapabilities::SC_TEXT;
-
-// obj[S_MSG_PARAMS]["vrSynonyms"][0] = "Synonym1";
-// obj[S_MSG_PARAMS]["vrSynonyms"][1] = "Synonym2";
+ // Commented params for check creation object with only default values
+ // obj[S_MSG_PARAMS]["ttsName"][0]["text"] = "ABC";
+ // obj[S_MSG_PARAMS]["ttsName"][0]["type"] =
+ // SpeechCapabilities::SC_TEXT;
-// obj[S_MSG_PARAMS]["appType"][0] = AppTypeTest::SYSTEM;
-// obj[S_MSG_PARAMS]["appType"][1] = AppTypeTest::MEDIA;
+ // obj[S_MSG_PARAMS]["vrSynonyms"][0] = "Synonym1";
+ // obj[S_MSG_PARAMS]["vrSynonyms"][1] = "Synonym2";
+ // obj[S_MSG_PARAMS]["appType"][0] = AppTypeTest::SYSTEM;
+ // obj[S_MSG_PARAMS]["appType"][1] = AppTypeTest::MEDIA;
}
} // namespace formatters