summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacobkeeler <jacob.keeler@livioradio.com>2017-11-30 15:19:11 -0500
committerjacobkeeler <jacob.keeler@livioradio.com>2017-11-30 15:19:11 -0500
commit273e26304efb215af3416f86ab86c1c7fd39f974 (patch)
tree5b756554c190eec764565076c84c9a3fb5c3193a
parent3800d598555ea45f2b61741b53a959cdd678e705 (diff)
downloadsdl_core-273e26304efb215af3416f86ab86c1c7fd39f974.tar.gz
Use ValidationReport objects for reporting rather than strings
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc31
-rw-r--r--src/components/application_manager/src/commands/mobile/system_request.cc2
-rw-r--r--src/components/application_manager/src/hmi_capabilities_impl.cc35
-rw-r--r--src/components/application_manager/src/resumption/resumption_data_json.cc2
-rw-r--r--src/components/application_manager/test/resumption/resumption_data_json_test.cc4
-rw-r--r--src/components/formatters/include/formatters/CFormatterJsonBase.h3
-rw-r--r--src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h3
-rw-r--r--src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h2
-rw-r--r--src/components/formatters/include/formatters/formatter_json_rpc.h10
-rw-r--r--src/components/formatters/src/CFormatterJsonBase.cc11
-rw-r--r--src/components/formatters/src/generic_json_formatter.cc2
-rw-r--r--src/components/formatters/test/CFormatterJsonBase_test.cc30
-rw-r--r--src/components/formatters/test/CSmartFactory_test.cc131
-rw-r--r--src/components/formatters/test/cFormatterJsonSDLRPCv1_test.cc30
-rw-r--r--src/components/formatters/test/cFormatterJsonSDLRPCv2_test.cc37
-rw-r--r--src/components/formatters/test/formatter_json_rpc_test.cc6
-rw-r--r--src/components/include/rpc_base/validation_report.h (renamed from src/components/rpc_base/include/rpc_base/validation_report.h)7
-rw-r--r--src/components/rpc_base/test/rpc_base_test.cc22
-rw-r--r--src/components/rpc_base/test/validation_report_test.cc2
-rw-r--r--src/components/smart_objects/include/smart_objects/always_false_schema_item.h5
-rw-r--r--src/components/smart_objects/include/smart_objects/always_true_schema_item.h5
-rw-r--r--src/components/smart_objects/include/smart_objects/array_schema_item.h4
-rw-r--r--src/components/smart_objects/include/smart_objects/default_shema_item.h24
-rw-r--r--src/components/smart_objects/include/smart_objects/enum_schema_item.h39
-rw-r--r--src/components/smart_objects/include/smart_objects/number_schema_item.h33
-rw-r--r--src/components/smart_objects/include/smart_objects/object_schema_item.h5
-rw-r--r--src/components/smart_objects/include/smart_objects/schema_item.h5
-rw-r--r--src/components/smart_objects/include/smart_objects/smart_object.h27
-rw-r--r--src/components/smart_objects/include/smart_objects/smart_schema.h5
-rw-r--r--src/components/smart_objects/include/smart_objects/string_schema_item.h5
-rw-r--r--src/components/smart_objects/src/always_false_schema_item.cc10
-rw-r--r--src/components/smart_objects/src/always_true_schema_item.cc2
-rw-r--r--src/components/smart_objects/src/array_schema_item.cc35
-rw-r--r--src/components/smart_objects/src/object_schema_item.cc26
-rw-r--r--src/components/smart_objects/src/schema_item.cc2
-rw-r--r--src/components/smart_objects/src/smart_object.cc57
-rw-r--r--src/components/smart_objects/src/smart_schema.cc8
-rw-r--r--src/components/smart_objects/src/string_schema_item.cc29
-rw-r--r--src/components/smart_objects/test/AlwaysFalseSchemaItem_test.cc20
-rw-r--r--src/components/smart_objects/test/AlwaysTrueSchemaItem_test.cc20
-rw-r--r--src/components/smart_objects/test/ArraySchemaItem_test.cc96
-rw-r--r--src/components/smart_objects/test/BoolSchemaItem_test.cc42
-rw-r--r--src/components/smart_objects/test/CObjectSchemaItem_test.cc174
-rw-r--r--src/components/smart_objects/test/EnumSchemaItem_test.cc36
-rw-r--r--src/components/smart_objects/test/NumberSchemaItem_test.cc220
-rw-r--r--src/components/smart_objects/test/StringSchemaItem_test.cc78
-rw-r--r--tools/intergen/test/generated_interface_json_tests.cc6
47 files changed, 653 insertions, 735 deletions
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 616a538f5a..5feb29e51d 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -2069,11 +2069,11 @@ bool ApplicationManagerImpl::ConvertMessageToSO(
message.type(),
message.correlation_id());
- std::string errorMessage = "";
+ rpc::ValidationReport report("RPC");
if (!conversion_result ||
!mobile_so_factory().attachSchema(output, true) ||
- ((output.validate(errorMessage) != smart_objects::Errors::OK))) {
+ ((output.validate(&report) != smart_objects::Errors::OK))) {
LOG4CXX_WARN(logger_,
"Failed to parse string to smart object :"
<< message.json_message());
@@ -2084,7 +2084,8 @@ bool ApplicationManagerImpl::ConvertMessageToSO(
message.correlation_id(),
mobile_apis::Result::INVALID_DATA));
- (*response)[strings::msg_params][strings::info] = errorMessage;
+ (*response)[strings::msg_params][strings::info] =
+ rpc::PrettyFormat(report);
ManageMobileCommand(response, commands::Command::ORIGIN_SDL);
return false;
}
@@ -2133,15 +2134,17 @@ bool ApplicationManagerImpl::ConvertMessageToSO(
return false;
}
- std::string errorMessage = "";
+ rpc::ValidationReport report("RPC");
- if (output.validate(errorMessage) != smart_objects::Errors::OK) {
- LOG4CXX_ERROR(logger_, "Incorrect parameter from HMI");
+ if (output.validate(&report) != smart_objects::Errors::OK) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrect parameter from HMI"
+ << rpc::PrettyFormat(report));
output.erase(strings::msg_params);
output[strings::params][hmi_response::code] =
hmi_apis::Common_Result::INVALID_DATA;
- output[strings::msg_params][strings::info] = errorMessage;
+ output[strings::msg_params][strings::info] = rpc::PrettyFormat(report);
return false;
}
break;
@@ -2317,10 +2320,11 @@ MessageValidationResult ApplicationManagerImpl::ValidateMessageBySchema(
if (!mobile_so_factory().attachSchema(so, true)) {
return INVALID_METADATA;
}
- std::string errorMessage("");
- if (so.validate(errorMessage) != smart_objects::Errors::OK) {
+ rpc::ValidationReport report("RPC");
+ if (so.validate(&report) != smart_objects::Errors::OK) {
LOG4CXX_WARN(logger_,
- "validate() failed for Mobile message - " << errorMessage);
+ "validate() failed for Mobile message - "
+ << rpc::PrettyFormat(report));
return SCHEMA_MISMATCH;
}
break;
@@ -2339,10 +2343,11 @@ MessageValidationResult ApplicationManagerImpl::ValidateMessageBySchema(
return INVALID_METADATA;
}
- std::string errorMessage("");
- if (so.validate(errorMessage) != smart_objects::Errors::OK) {
+ rpc::ValidationReport report("RPC");
+ if (so.validate(&report) != smart_objects::Errors::OK) {
LOG4CXX_WARN(logger_,
- "validate() failed for HMI message - " << errorMessage);
+ "validate() failed for HMI message - "
+ << rpc::PrettyFormat(report));
return SCHEMA_MISMATCH;
}
break;
diff --git a/src/components/application_manager/src/commands/mobile/system_request.cc b/src/components/application_manager/src/commands/mobile/system_request.cc
index 46e6fbefa2..e4706441ef 100644
--- a/src/components/application_manager/src/commands/mobile/system_request.cc
+++ b/src/components/application_manager/src/commands/mobile/system_request.cc
@@ -574,7 +574,7 @@ void SystemRequest::Run() {
return;
}
- CFormatterJsonBase::jsonValueToObj(root, sm_object, "");
+ CFormatterJsonBase::jsonValueToObj(root, sm_object);
if (!ValidateQueryAppData(sm_object)) {
SendResponse(false, mobile_apis::Result::GENERIC_ERROR);
return;
diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc
index 17e9acc81a..28049f8e35 100644
--- a/src/components/application_manager/src/hmi_capabilities_impl.cc
+++ b/src/components/application_manager/src/hmi_capabilities_impl.cc
@@ -866,8 +866,7 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() {
smart_objects::SmartObject display_capabilities_so;
Json::Value display_capabilities = ui.get("displayCapabilities", "");
Formatters::CFormatterJsonBase::jsonValueToObj(display_capabilities,
- display_capabilities_so,
- "displayCapabilities");
+ display_capabilities_so);
if (display_capabilities_so.keyExists(hmi_response::display_type)) {
std::map<std::string,
@@ -1064,9 +1063,7 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() {
ui.get("softButtonCapabilities", "");
smart_objects::SmartObject soft_button_capabilities_so;
Formatters::CFormatterJsonBase::jsonValueToObj(
- soft_button_capabilities,
- soft_button_capabilities_so,
- "softButtonCapabilities");
+ soft_button_capabilities, soft_button_capabilities_so);
set_soft_button_capabilities(soft_button_capabilities_so);
}
if (check_existing_json_member(ui, "systemCapabilities")) {
@@ -1077,9 +1074,7 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() {
system_capabilities.get("navigationCapability", "");
smart_objects::SmartObject navigation_capability_so;
Formatters::CFormatterJsonBase::jsonValueToObj(
- navigation_capability,
- navigation_capability_so,
- "navigationCapability");
+ navigation_capability, navigation_capability_so);
set_navigation_capability(navigation_capability_so);
if (!navigation_capability_so.empty()) {
set_navigation_supported(true);
@@ -1090,8 +1085,8 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() {
Json::Value phone_capability =
system_capabilities.get("phoneCapability", "");
smart_objects::SmartObject phone_capability_so;
- Formatters::CFormatterJsonBase::jsonValueToObj(
- phone_capability, phone_capability_so, "phoneCapability");
+ Formatters::CFormatterJsonBase::jsonValueToObj(phone_capability,
+ phone_capability_so);
set_phone_capability(phone_capability_so);
if (!phone_capability_so.empty()) {
set_phone_call_supported(true);
@@ -1102,8 +1097,8 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() {
Json::Value vs_capability =
system_capabilities.get("videoStreamingCapability", "");
smart_objects::SmartObject vs_capability_so;
- Formatters::CFormatterJsonBase::jsonValueToObj(
- vs_capability, vs_capability_so, "videoStreamingCapability");
+ Formatters::CFormatterJsonBase::jsonValueToObj(vs_capability,
+ vs_capability_so);
if (vs_capability_so.keyExists("supportedFormats")) {
smart_objects::SmartObject& supported_format_array =
@@ -1152,8 +1147,8 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() {
Json::Value rc_capability =
system_capabilities.get("remoteControlCapability", "");
smart_objects::SmartObject rc_capability_so;
- Formatters::CFormatterJsonBase::jsonValueToObj(
- rc_capability, rc_capability_so, "remoteControlCapability");
+ Formatters::CFormatterJsonBase::jsonValueToObj(rc_capability,
+ rc_capability_so);
set_rc_capability(rc_capability_so);
}
}
@@ -1228,8 +1223,8 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() {
if (check_existing_json_member(buttons, "capabilities")) {
Json::Value bt_capabilities = buttons.get("capabilities", "");
smart_objects::SmartObject buttons_capabilities_so;
- Formatters::CFormatterJsonBase::jsonValueToObj(
- bt_capabilities, buttons_capabilities_so, "Buttons.capabilities");
+ Formatters::CFormatterJsonBase::jsonValueToObj(bt_capabilities,
+ buttons_capabilities_so);
for (uint32_t i = 0; i < buttons_capabilities_so.length(); ++i) {
if ((buttons_capabilities_so[i]).keyExists(strings::name)) {
@@ -1248,8 +1243,8 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() {
if (check_existing_json_member(buttons, "presetBankCapabilities")) {
Json::Value presetBank = buttons.get("presetBankCapabilities", "");
smart_objects::SmartObject preset_bank_so;
- Formatters::CFormatterJsonBase::jsonValueToObj(
- presetBank, preset_bank_so, "presetBankCapabilities");
+ Formatters::CFormatterJsonBase::jsonValueToObj(presetBank,
+ preset_bank_so);
set_preset_bank_capabilities(preset_bank_so);
}
} // Buttons end
@@ -1258,8 +1253,8 @@ bool HMICapabilitiesImpl::load_capabilities_from_file() {
if (check_existing_json_member(root_json, "VehicleInfo")) {
Json::Value vehicle_info = root_json.get("VehicleInfo", "");
smart_objects::SmartObject vehicle_type_so;
- Formatters::CFormatterJsonBase::jsonValueToObj(
- vehicle_info, vehicle_type_so, "VehicleInfo");
+ Formatters::CFormatterJsonBase::jsonValueToObj(vehicle_info,
+ vehicle_type_so);
set_vehicle_type(vehicle_type_so);
} // VehicleType end
} catch (...) {
diff --git a/src/components/application_manager/src/resumption/resumption_data_json.cc b/src/components/application_manager/src/resumption/resumption_data_json.cc
index c5b26d7e75..7866fc4de1 100644
--- a/src/components/application_manager/src/resumption/resumption_data_json.cc
+++ b/src/components/application_manager/src/resumption/resumption_data_json.cc
@@ -225,7 +225,7 @@ bool ResumptionDataJson::GetSavedApplication(
return false;
}
const Json::Value& json_saved_app = GetSavedApplications()[idx];
- Formatters::CFormatterJsonBase::jsonValueToObj(json_saved_app, saved_app, "");
+ Formatters::CFormatterJsonBase::jsonValueToObj(json_saved_app, saved_app);
return true;
}
diff --git a/src/components/application_manager/test/resumption/resumption_data_json_test.cc b/src/components/application_manager/test/resumption/resumption_data_json_test.cc
index 60135f3453..834637fa62 100644
--- a/src/components/application_manager/test/resumption/resumption_data_json_test.cc
+++ b/src/components/application_manager/test/resumption/resumption_data_json_test.cc
@@ -90,8 +90,8 @@ class ResumptionDataJsonTest : public ResumptionDataTest {
dictionary[am::strings::resumption][am::strings::resume_app_list];
sm::SmartObject res_app_list;
for (uint32_t i = 0; i < resume_app_list.size(); i++) {
- Formatters::CFormatterJsonBase::jsonValueToObj(
- resume_app_list[i], res_app_list, "");
+ Formatters::CFormatterJsonBase::jsonValueToObj(resume_app_list[i],
+ res_app_list);
CheckSavedApp(res_app_list);
}
}
diff --git a/src/components/formatters/include/formatters/CFormatterJsonBase.h b/src/components/formatters/include/formatters/CFormatterJsonBase.h
index 43e65e1500..1df706839f 100644
--- a/src/components/formatters/include/formatters/CFormatterJsonBase.h
+++ b/src/components/formatters/include/formatters/CFormatterJsonBase.h
@@ -99,8 +99,7 @@ class CFormatterJsonBase {
*/
static void jsonValueToObj(
const Json::Value& value,
- NsSmartDeviceLink::NsSmartObjects::SmartObject& obj,
- const std::string& key);
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& obj);
/**
* @brief The method constructs a JSON object from the input SmartObject
diff --git a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h
index 0f2033a71b..f22b1216ab 100644
--- a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h
+++ b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv1.h
@@ -209,8 +209,7 @@ int32_t Formatters::CFormatterJsonSDLRPCv1::fromString(
namespace S = NsSmartDeviceLink::NsJSONHandler::strings;
if (!(result & kMessageTypeNotFound)) {
- jsonValueToObj(
- root[type][S_PARAMETERS], out[S::S_MSG_PARAMS], "parameters");
+ jsonValueToObj(root[type][S_PARAMETERS], out[S::S_MSG_PARAMS]);
out[S::S_PARAMS][S::S_MESSAGE_TYPE] = messageType;
out[S::S_PARAMS][S::S_FUNCTION_ID] = functionId;
diff --git a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h
index f9f1386226..8260a35959 100644
--- a/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h
+++ b/src/components/formatters/include/formatters/CFormatterJsonSDLRPCv2.h
@@ -155,7 +155,7 @@ inline bool CFormatterJsonSDLRPCv2::fromString(
out[strings::S_PARAMS][strings::S_PROTOCOL_TYPE] = 0;
out[strings::S_PARAMS][strings::S_PROTOCOL_VERSION] = 2;
- jsonValueToObj(root, out[strings::S_MSG_PARAMS], "parameters");
+ jsonValueToObj(root, out[strings::S_MSG_PARAMS]);
}
} catch (...) {
result = false;
diff --git a/src/components/formatters/include/formatters/formatter_json_rpc.h b/src/components/formatters/include/formatters/formatter_json_rpc.h
index 7055aab1de..3d921ea901 100644
--- a/src/components/formatters/include/formatters/formatter_json_rpc.h
+++ b/src/components/formatters/include/formatters/formatter_json_rpc.h
@@ -396,8 +396,7 @@ int32_t FormatterJsonRpc::FromString(const std::string& str,
if (false == params_value.isObject()) {
result |= kInvalidFormat;
} else {
- jsonValueToObj(
- root[kParams], out[strings::S_MSG_PARAMS], strings::S_MSG_PARAMS);
+ jsonValueToObj(root[kParams], out[strings::S_MSG_PARAMS]);
}
} else if (true == root.isMember(kResult)) {
const Json::Value& result_value = root[kResult];
@@ -405,13 +404,10 @@ int32_t FormatterJsonRpc::FromString(const std::string& str,
if (false == result_value.isObject()) {
result |= kInvalidFormat;
} else {
- jsonValueToObj(
- root[kResult], out[strings::S_MSG_PARAMS], strings::S_MSG_PARAMS);
+ jsonValueToObj(root[kResult], out[strings::S_MSG_PARAMS]);
}
} else if (true == is_error_response) {
- jsonValueToObj(response_value[kData],
- out[strings::S_PARAMS][kData],
- strings::S_PARAMS + "." + kData);
+ jsonValueToObj(response_value[kData], out[strings::S_PARAMS][kData]);
}
if ((kResponse == message_type_string) ||
diff --git a/src/components/formatters/src/CFormatterJsonBase.cc b/src/components/formatters/src/CFormatterJsonBase.cc
index f39569ee0c..0a85a93d21 100644
--- a/src/components/formatters/src/CFormatterJsonBase.cc
+++ b/src/components/formatters/src/CFormatterJsonBase.cc
@@ -37,8 +37,7 @@
void NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonBase::
jsonValueToObj(const Json::Value& value,
- NsSmartDeviceLink::NsSmartObjects::SmartObject& obj,
- const std::string& key) {
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& obj) {
try {
if (value.type() == Json::objectValue) {
obj = NsSmartDeviceLink::NsSmartObjects::SmartObject(
@@ -47,17 +46,14 @@ void NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonBase::
Json::Value::Members members = value.getMemberNames();
for (uint32_t i = 0; i < members.size(); i++) {
- std::string newKey(key + "." + members[i]);
- jsonValueToObj(value[members[i]], obj[members[i]], newKey);
+ jsonValueToObj(value[members[i]], obj[members[i]]);
}
} else if (value.type() == Json::arrayValue) {
obj = NsSmartDeviceLink::NsSmartObjects::SmartObject(
NsSmartDeviceLink::NsSmartObjects::SmartType_Array);
for (uint32_t i = 0; i < value.size(); i++) {
- std::stringstream newKey;
- newKey << key << "." << i;
- jsonValueToObj(value[i], obj[i], newKey.str());
+ jsonValueToObj(value[i], obj[i]);
}
} else if (value.type() == Json::intValue) {
obj = utils::ConvertLongLongIntToInt64(value.asInt64());
@@ -70,7 +66,6 @@ void NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonBase::
} else if (value.type() == Json::stringValue) {
obj = value.asString();
}
- obj.setKey(key);
} catch (...) {
}
}
diff --git a/src/components/formatters/src/generic_json_formatter.cc b/src/components/formatters/src/generic_json_formatter.cc
index 8f576f1348..7789a915c2 100644
--- a/src/components/formatters/src/generic_json_formatter.cc
+++ b/src/components/formatters/src/generic_json_formatter.cc
@@ -52,7 +52,7 @@ bool GenericJsonFormatter::FromString(const std::string& str,
bool result = reader.parse(str, json_root);
if (true == result) {
- jsonValueToObj(json_root, out, "");
+ jsonValueToObj(json_root, out);
}
return result;
diff --git a/src/components/formatters/test/CFormatterJsonBase_test.cc b/src/components/formatters/test/CFormatterJsonBase_test.cc
index 26cc4035dd..ff1f60b8df 100644
--- a/src/components/formatters/test/CFormatterJsonBase_test.cc
+++ b/src/components/formatters/test/CFormatterJsonBase_test.cc
@@ -51,7 +51,7 @@ TEST(CFormatterJsonBaseTest, JSonStringValueToSmartObj_ExpectSuccessful) {
Json::Value json_value(string_val); // Json value from string
SmartObject object;
// Convert json to smart object
- CFormatterJsonBase::jsonValueToObj(json_value, object, "");
+ CFormatterJsonBase::jsonValueToObj(json_value, object);
// Check conversion was successful
EXPECT_EQ(string_val, object.asString());
}
@@ -62,7 +62,7 @@ TEST(CFormatterJsonBaseTest, JSonDoubleValueToSmartObj_ExpectSuccessful) {
Json::Value json_value(dval); // Json value from double
SmartObject object;
// Convert json to smart object
- CFormatterJsonBase::jsonValueToObj(json_value, object, "");
+ CFormatterJsonBase::jsonValueToObj(json_value, object);
// Check conversion was successful
EXPECT_DOUBLE_EQ(dval, object.asDouble());
}
@@ -73,7 +73,7 @@ TEST(CFormatterJsonBaseTest, JSonMinIntValueToSmartObj_ExpectSuccessful) {
Json::Value json_value(ival); // Json value from possible minimum signed int
SmartObject object;
// Convert json to smart object
- CFormatterJsonBase::jsonValueToObj(json_value, object, "");
+ CFormatterJsonBase::jsonValueToObj(json_value, object);
// Check conversion was successful
EXPECT_EQ(ival, object.asInt());
}
@@ -84,7 +84,7 @@ TEST(CFormatterJsonBaseTest, JSonNullIntValueToSmartObj_ExpectSuccessful) {
Json::Value json_value(ival); // Json value from null int value
SmartObject object;
// Convert json to smart object
- CFormatterJsonBase::jsonValueToObj(json_value, object, "");
+ CFormatterJsonBase::jsonValueToObj(json_value, object);
// Check conversion was successful
EXPECT_EQ(ival, object.asInt());
}
@@ -95,7 +95,7 @@ TEST(CFormatterJsonBaseTest, JSonSignedMaxIntValueToSmartObj_ExpectSuccessful) {
Json::Value json_value(ival); // Json value from maximum possible signed int
SmartObject object;
// Convert json to smart object
- CFormatterJsonBase::jsonValueToObj(json_value, object, "");
+ CFormatterJsonBase::jsonValueToObj(json_value, object);
// Check conversion was successful
EXPECT_EQ(ival, object.asInt());
}
@@ -108,7 +108,7 @@ TEST(CFormatterJsonBaseTest,
ui_val); // Json value from maximum possible unsigned int
SmartObject object;
// Convert json to smart object
- CFormatterJsonBase::jsonValueToObj(json_value, object, "");
+ CFormatterJsonBase::jsonValueToObj(json_value, object);
// Check conversion was successful
EXPECT_EQ(ui_val, object.asUInt());
}
@@ -119,7 +119,7 @@ TEST(CFormatterJsonBaseTest, JSonSignedMaxInt64ValueToSmartObj_ExpectSuccess) {
Json::Value json_value(ival); // Json value from maximum possible signed int
SmartObject object;
// Convert json to smart object
- CFormatterJsonBase::jsonValueToObj(json_value, object, "");
+ CFormatterJsonBase::jsonValueToObj(json_value, object);
// Check conversion was successful
EXPECT_EQ(ival, object.asInt());
}
@@ -130,7 +130,7 @@ TEST(CFormatterJsonBaseTest, JSonUnsignedMaxInt64ValueToSmartObj_ExpectFailed) {
Json::Value json_value(ival); // Json value from max possible unsigned int
SmartObject object;
// Convert json to smart object
- CFormatterJsonBase::jsonValueToObj(json_value, object, "");
+ CFormatterJsonBase::jsonValueToObj(json_value, object);
// Check conversion was not successful as there is no such conversion
EXPECT_EQ(invalid_int64_value, object.asInt());
}
@@ -144,8 +144,8 @@ TEST(CFormatterJsonBaseTest, JSonBoolValueToSmartObj_ExpectSuccessful) {
SmartObject object1;
SmartObject object2;
// Convert json to smart object
- CFormatterJsonBase::jsonValueToObj(json_value1, object1, "");
- CFormatterJsonBase::jsonValueToObj(json_value2, object2, "");
+ CFormatterJsonBase::jsonValueToObj(json_value1, object1);
+ CFormatterJsonBase::jsonValueToObj(json_value2, object2);
// Check conversion was successful
EXPECT_TRUE(object1.asBool());
EXPECT_FALSE(object2.asBool());
@@ -157,7 +157,7 @@ TEST(CFormatterJsonBaseTest, JSonCStringValueToSmartObj_ExpectSuccessful) {
Json::Value json_value(cstr_val); // Json value from const char*
SmartObject object;
// Convert json to smart object
- CFormatterJsonBase::jsonValueToObj(json_value, object, "");
+ CFormatterJsonBase::jsonValueToObj(json_value, object);
// Check conversion was successful
EXPECT_STREQ(cstr_val, object.asCharArray());
}
@@ -172,7 +172,7 @@ TEST(CFormatterJsonBaseTest, JSonArrayValueToSmartObj_ExpectSuccessful) {
// Parse array to json value
ASSERT_TRUE(reader.parse(json_array, json_value));
// Convert json array to SmartObject
- CFormatterJsonBase::jsonValueToObj(json_value, object, "");
+ CFormatterJsonBase::jsonValueToObj(json_value, object);
// Check conversion was successful
EXPECT_TRUE(json_value.isArray());
EXPECT_EQ(3u, object.asArray()->size());
@@ -191,7 +191,7 @@ TEST(CFormatterJsonBaseTest, JSonObjectValueToSmartObj_ExpectSuccessful) {
ASSERT_TRUE(reader.parse(
json_object,
json_value)); // If parsing not successful - no sense to continue
- CFormatterJsonBase::jsonValueToObj(json_value, object, "");
+ CFormatterJsonBase::jsonValueToObj(json_value, object);
// Check conversion was successful
EXPECT_TRUE(json_value.isObject());
EXPECT_TRUE(json_value.type() == Json::objectValue);
@@ -307,7 +307,7 @@ TEST(CFormatterJsonBaseTest, ArraySmartObjectToJSon_ExpectSuccessful) {
ASSERT_TRUE(reader.parse(json_array,
json_value)); // Convert json array to SmartObject
// Convert json array to SmartObject
- CFormatterJsonBase::jsonValueToObj(json_value, object, "");
+ CFormatterJsonBase::jsonValueToObj(json_value, object);
// Convert SmartObject to JSon
CFormatterJsonBase::objToJsonValue(object, result);
// Check conversion was successful
@@ -331,7 +331,7 @@ TEST(CFormatterJsonBaseTest, JSonObjectValueToObj_ExpectSuccessful) {
json_object,
json_value)); // If parsing not successful - no sense to continue
// Convert json array to SmartObject
- CFormatterJsonBase::jsonValueToObj(json_value, object, "");
+ CFormatterJsonBase::jsonValueToObj(json_value, object);
// Convert SmartObject to JSon
CFormatterJsonBase::objToJsonValue(object, result);
// Check conversion was successful
diff --git a/src/components/formatters/test/CSmartFactory_test.cc b/src/components/formatters/test/CSmartFactory_test.cc
index f1df40d218..3713d076e2 100644
--- a/src/components/formatters/test/CSmartFactory_test.cc
+++ b/src/components/formatters/test/CSmartFactory_test.cc
@@ -67,9 +67,9 @@ TEST(CSmartFactoryTest,
obj[S_MSG_PARAMS] = SmartObject(SmartType::SmartType_Map);
std::set<std::string> keys = obj.enumerate();
EXPECT_EQ(2u, keys.size());
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::OK, obj.validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::OK, obj.validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
EXPECT_TRUE(obj.isValid());
}
@@ -81,9 +81,9 @@ TEST(CSmartFactoryTest,
FunctionIdTest::Function1, MessageTypeTest::INVALID_ENUM);
EXPECT_FALSE(SmartType::SmartType_Map == obj.getType());
EXPECT_TRUE(SmartType::SmartType_Null == obj.getType());
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::OK, obj.validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::OK, obj.validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
EXPECT_TRUE(obj.isValid());
}
@@ -103,10 +103,9 @@ TEST(
obj[S_MSG_PARAMS] = SmartObject(SmartType::SmartType_Map);
std::set<std::string> keys = obj.enumerate();
EXPECT_EQ(2u, keys.size());
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::MISSING_MANDATORY_PARAMETER,
- obj.validate(errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::MISSING_MANDATORY_PARAMETER, obj.validate(&report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
EXPECT_FALSE(obj.isValid());
}
@@ -127,9 +126,9 @@ TEST(
obj[S_MSG_PARAMS] = SmartObject(SmartType::SmartType_Map);
std::set<std::string> keys = obj.enumerate();
EXPECT_EQ(2u, keys.size());
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::OUT_OF_RANGE, obj.validate(errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::OUT_OF_RANGE, obj.validate(&report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
EXPECT_FALSE(obj.isValid());
}
@@ -150,9 +149,9 @@ TEST(
obj[S_MSG_PARAMS] = SmartObject(SmartType::SmartType_Map);
std::set<std::string> keys = obj.enumerate();
EXPECT_EQ(2u, keys.size());
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::INVALID_VALUE, obj.validate(errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::INVALID_VALUE, obj.validate(&report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
EXPECT_FALSE(obj.isValid());
}
@@ -174,9 +173,9 @@ TEST(CSmartFactoryTest,
obj[S_MSG_PARAMS] = SmartObject(SmartType::SmartType_Map);
std::set<std::string> keys = obj.enumerate();
EXPECT_EQ(2u, keys.size());
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::OK, obj.validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::OK, obj.validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
EXPECT_TRUE(obj.isValid());
}
@@ -198,10 +197,9 @@ TEST(
obj[S_MSG_PARAMS] = SmartObject(SmartType::SmartType_Map);
std::set<std::string> keys = obj.enumerate();
EXPECT_EQ(2u, keys.size());
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::MISSING_MANDATORY_PARAMETER,
- obj.validate(errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::MISSING_MANDATORY_PARAMETER, obj.validate(&report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
EXPECT_FALSE(obj.isValid());
}
@@ -237,9 +235,9 @@ TEST(
obj[S_MSG_PARAMS] = SmartObject(SmartType::SmartType_Map);
std::set<std::string> keys = obj.enumerate();
EXPECT_EQ(2u, keys.size());
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::INVALID_VALUE, obj.validate(errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::INVALID_VALUE, obj.validate(&report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
EXPECT_FALSE(obj.isValid());
}
@@ -254,9 +252,9 @@ TEST(CSmartFactoryTest,
obj["position"] = 200;
std::set<std::string> keys = obj.enumerate();
EXPECT_EQ(2u, keys.size());
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::OK, obj.validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::OK, obj.validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
EXPECT_TRUE(obj.isValid());
}
@@ -271,10 +269,9 @@ TEST(
obj["text"] = "test";
std::set<std::string> keys = obj.enumerate();
EXPECT_EQ(1u, keys.size());
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::MISSING_MANDATORY_PARAMETER,
- obj.validate(errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::MISSING_MANDATORY_PARAMETER, obj.validate(&report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
EXPECT_FALSE(obj.isValid());
}
@@ -289,9 +286,9 @@ TEST(CSmartFactoryTest,
obj["position"] = 200;
std::set<std::string> keys = obj.enumerate();
EXPECT_EQ(2u, keys.size());
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::OK, obj.validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::OK, obj.validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
EXPECT_TRUE(obj.isValid());
}
@@ -306,14 +303,14 @@ TEST(CSmartFactoryTest,
obj["position"] = 200;
obj["image"]["text"] = "test2";
obj["image"]["position"] = 100;
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::OK, obj["image"].validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::OK, obj["image"].validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
std::set<std::string> keys = obj.enumerate();
EXPECT_EQ(3u, keys.size());
- errorMessage = "";
- EXPECT_EQ(Errors::eType::OK, obj.validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::eType::OK, obj.validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
EXPECT_TRUE(obj.isValid());
}
@@ -330,15 +327,15 @@ TEST(
obj["image"]["text"] = "test2";
obj["image"]["position"] = 100;
// Check object "image"
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::OK, obj["image"].validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::OK, obj["image"].validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
std::set<std::string> keys = obj.enumerate();
EXPECT_EQ(3u, keys.size());
// Check global object
- errorMessage = "";
- EXPECT_EQ(Errors::eType::OK, obj.validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::eType::OK, obj.validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
EXPECT_TRUE(obj.isValid());
}
@@ -354,16 +351,15 @@ TEST(
obj["image"]["text"] = "test2";
obj["image"]["position"] = 100;
// Check object "image"
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::OK, obj["image"].validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::OK, obj["image"].validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
std::set<std::string> keys = obj.enumerate();
EXPECT_EQ(2u, keys.size());
// Check global object
- errorMessage = "";
- EXPECT_EQ(Errors::eType::MISSING_MANDATORY_PARAMETER,
- obj.validate(errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::eType::MISSING_MANDATORY_PARAMETER, obj.validate(&report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
EXPECT_FALSE(obj.isValid());
}
@@ -380,15 +376,15 @@ TEST(
obj["image"]["text"] = "test2";
obj["image"]["position"] = 100;
// Check object "image"
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::OK, obj["image"].validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::OK, obj["image"].validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
std::set<std::string> keys = obj.enumerate();
EXPECT_EQ(3u, keys.size());
// Check global object
- errorMessage = "";
- EXPECT_EQ(Errors::eType::OK, obj.validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::eType::OK, obj.validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
EXPECT_TRUE(obj.isValid());
}
@@ -405,10 +401,9 @@ TEST(
std::set<std::string> keys = obj.enumerate();
EXPECT_EQ(2u, keys.size());
// Check global object
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::MISSING_MANDATORY_PARAMETER,
- obj.validate(errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::MISSING_MANDATORY_PARAMETER, obj.validate(&report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
EXPECT_FALSE(obj.isValid());
}
@@ -426,9 +421,9 @@ TEST(
std::set<std::string> keys = obj.enumerate();
EXPECT_EQ(3u, keys.size());
// Check global object
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::INVALID_VALUE, obj.validate(errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::INVALID_VALUE, obj.validate(&report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
EXPECT_FALSE(obj.isValid());
}
diff --git a/src/components/formatters/test/cFormatterJsonSDLRPCv1_test.cc b/src/components/formatters/test/cFormatterJsonSDLRPCv1_test.cc
index 591accecd8..a4d40b4478 100644
--- a/src/components/formatters/test/cFormatterJsonSDLRPCv1_test.cc
+++ b/src/components/formatters/test/cFormatterJsonSDLRPCv1_test.cc
@@ -42,9 +42,9 @@ namespace formatters {
TEST(CFormatterJsonSDLRPCv1Test, EmptySmartObjectToString) {
SmartObject srcObj;
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::OK, srcObj.validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::OK, srcObj.validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
std::string jsonString;
bool result = CFormatterJsonSDLRPCv1::toString(srcObj, jsonString);
@@ -73,10 +73,10 @@ TEST(CFormatterJsonSDLRPCv1Test, SmObjWithRequestWithoutMsgNotValid_ToString) {
srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
- std::string errorMessage;
+ rpc::ValidationReport report("RPC");
EXPECT_EQ(Errors::eType::MISSING_MANDATORY_PARAMETER,
- srcObj.validate(errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ srcObj.validate(&report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
std::string jsonString;
bool result = CFormatterJsonSDLRPCv1::toString(srcObj, jsonString);
@@ -107,9 +107,9 @@ TEST(CFormatterJsonSDLRPCv1Test,
srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
srcObj[S_MSG_PARAMS][""] = "";
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::OK, srcObj.validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::OK, srcObj.validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
std::string jsonString;
@@ -340,9 +340,9 @@ TEST(CFormatterJsonSDLRPCv1Test, StringRequestToSmObj) {
inputJsonString, obj);
EXPECT_EQ(CFormatterJsonSDLRPCv1::kSuccess, result);
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::OK, obj.validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::OK, obj.validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
EXPECT_EQ(obj[S_PARAMS][S_MESSAGE_TYPE], MessageTypeTest::request);
EXPECT_EQ(obj[S_PARAMS][S_FUNCTION_ID], FunctionIDTest::RegisterAppInterface);
EXPECT_EQ(obj[S_PARAMS][S_CORRELATION_ID], 5);
@@ -486,9 +486,9 @@ TEST(CFormatterJsonSDLRPCv1Test, StringNotificationToSmartObject) {
MessageTypeTest::eType>(
inputJsonString, obj);
EXPECT_EQ(CFormatterJsonSDLRPCv1::kSuccess, result);
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::OK, obj.validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::OK, obj.validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
EXPECT_EQ(obj[S_PARAMS][S_MESSAGE_TYPE], MessageTypeTest::notification);
EXPECT_EQ(obj[S_PARAMS][S_FUNCTION_ID], FunctionIDTest::SetGlobalProperties);
EXPECT_EQ(obj[S_PARAMS][S_CORRELATION_ID], 13);
diff --git a/src/components/formatters/test/cFormatterJsonSDLRPCv2_test.cc b/src/components/formatters/test/cFormatterJsonSDLRPCv2_test.cc
index 1c5b616180..c7e6f61674 100644
--- a/src/components/formatters/test/cFormatterJsonSDLRPCv2_test.cc
+++ b/src/components/formatters/test/cFormatterJsonSDLRPCv2_test.cc
@@ -41,9 +41,9 @@ namespace formatters {
TEST(CFormatterJsonSDLRPCv2Test, EmptySmartObjectToString) {
SmartObject srcObj;
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::OK, srcObj.validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::OK, srcObj.validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
std::string jsonString;
bool result = CFormatterJsonSDLRPCv2::toString(srcObj, jsonString);
@@ -66,10 +66,10 @@ TEST(CFormatterJsonSDLRPCv2Test, SmObjWithRequestWithoutMsgNotValid_ToString) {
srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
- std::string errorMessage;
+ rpc::ValidationReport report("RPC");
EXPECT_EQ(Errors::eType::MISSING_MANDATORY_PARAMETER,
- srcObj.validate(errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ srcObj.validate(&report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
std::string jsonString;
bool result = CFormatterJsonSDLRPCv2::toString(srcObj, jsonString);
@@ -93,9 +93,9 @@ TEST(CFormatterJsonSDLRPCv2Test,
srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
srcObj[S_MSG_PARAMS][""] = "";
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::OK, srcObj.validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::OK, srcObj.validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
std::string jsonString;
@@ -269,10 +269,9 @@ TEST(CFormatterJsonSDLRPCv2Test, StringRequestWithoutCorIdToSmObj) {
MessageTypeTest::request);
EXPECT_EQ(true, result);
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::MISSING_MANDATORY_PARAMETER,
- obj.validate(errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::MISSING_MANDATORY_PARAMETER, obj.validate(&report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
EXPECT_EQ(obj[S_PARAMS][S_MESSAGE_TYPE], MessageTypeTest::request);
EXPECT_EQ(obj[S_PARAMS][S_FUNCTION_ID], FunctionIDTest::RegisterAppInterface);
EXPECT_EQ(obj[S_PARAMS][S_PROTOCOL_TYPE], 0);
@@ -317,9 +316,9 @@ TEST(CFormatterJsonSDLRPCv2Test, StringRequestWithCorIdToSmObj) {
corId);
EXPECT_EQ(true, result);
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::OK, obj.validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::OK, obj.validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
EXPECT_EQ(obj[S_PARAMS][S_MESSAGE_TYPE], MessageTypeTest::request);
EXPECT_EQ(obj[S_PARAMS][S_FUNCTION_ID], FunctionIDTest::RegisterAppInterface);
EXPECT_EQ(obj[S_PARAMS][S_CORRELATION_ID], corId);
@@ -384,9 +383,9 @@ TEST(CFormatterJsonSDLRPCv2Test, StringNotificationToSmartObject) {
MessageTypeTest::notification,
corId);
EXPECT_EQ(true, result);
- std::string errorMessage;
- EXPECT_EQ(Errors::eType::OK, obj.validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::eType::OK, obj.validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
EXPECT_EQ(obj[S_PARAMS][S_MESSAGE_TYPE], MessageTypeTest::notification);
EXPECT_EQ(obj[S_PARAMS][S_FUNCTION_ID], FunctionIDTest::SetGlobalProperties);
EXPECT_EQ(obj[S_PARAMS][S_CORRELATION_ID], corId);
diff --git a/src/components/formatters/test/formatter_json_rpc_test.cc b/src/components/formatters/test/formatter_json_rpc_test.cc
index f3164311cd..e882bed618 100644
--- a/src/components/formatters/test/formatter_json_rpc_test.cc
+++ b/src/components/formatters/test/formatter_json_rpc_test.cc
@@ -149,9 +149,9 @@ TEST(FormatterJsonRPCTest, UpperBoundValuesInSystemRequest_ToString_Success) {
hmi_apis::HMI_API factory;
EXPECT_TRUE(factory.attachSchema(obj, false));
- std::string errorMessage;
- EXPECT_EQ(Errors::OK, obj.validate(errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::OK, obj.validate(&report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
std::string result;
// Convert SmartObject to Json string
EXPECT_TRUE(FormatterJsonRpc::ToString(obj, result));
diff --git a/src/components/rpc_base/include/rpc_base/validation_report.h b/src/components/include/rpc_base/validation_report.h
index 4397112d54..82f265e594 100644
--- a/src/components/rpc_base/include/rpc_base/validation_report.h
+++ b/src/components/include/rpc_base/validation_report.h
@@ -68,14 +68,17 @@ inline void PrettyFormat(const ValidationReport& report,
if (!object_path.empty() && report.object_name()[0] != '[') {
object_path.append(".");
}
+ const ValidationReports& subreports = report.subobject_reports();
object_path.append(report.object_name());
if (!report.validation_info().empty()) {
+ // Insert newline between entries
+ if (!result->empty()) {
+ result->append("\n");
+ }
result->append(object_path);
result->append(": ");
result->append(report.validation_info());
- result->append("\n");
}
- const ValidationReports& subreports = report.subobject_reports();
for (ValidationReports::const_iterator i = subreports.begin(),
end = subreports.end();
i != end;
diff --git a/src/components/rpc_base/test/rpc_base_test.cc b/src/components/rpc_base/test/rpc_base_test.cc
index c4ffbc321e..d81e01db6c 100644
--- a/src/components/rpc_base/test/rpc_base_test.cc
+++ b/src/components/rpc_base/test/rpc_base_test.cc
@@ -320,7 +320,7 @@ TEST(ValidatedTypes, ReportUninitializedIntType) {
ASSERT_FALSE(val.is_valid());
ValidationReport report("val");
val.ReportErrors(&report);
- ASSERT_EQ("val: value is not initialized\n", PrettyFormat(report));
+ ASSERT_EQ("val: value is not initialized", PrettyFormat(report));
}
TEST(ValidatedTypes, ReportIncorrectInitializedIntType) {
@@ -328,7 +328,7 @@ TEST(ValidatedTypes, ReportIncorrectInitializedIntType) {
ASSERT_FALSE(val.is_valid());
ValidationReport report("val");
val.ReportErrors(&report);
- ASSERT_EQ("val: value initialized incorrectly\n", PrettyFormat(report));
+ ASSERT_EQ("val: value initialized incorrectly", PrettyFormat(report));
}
TEST(ValidatedTypes, ReportUninitializedOptionalType) {
@@ -344,7 +344,7 @@ TEST(ValidatedTypes, ReportIncorrectInitializedOptionalType) {
ASSERT_FALSE(val.is_valid());
ValidationReport report("val");
val.ReportErrors(&report);
- ASSERT_EQ("val: value initialized incorrectly\n", PrettyFormat(report));
+ ASSERT_EQ("val: value initialized incorrectly", PrettyFormat(report));
}
TEST(ValidatedTypes, ReportUninitializedNullableIntType) {
@@ -352,7 +352,7 @@ TEST(ValidatedTypes, ReportUninitializedNullableIntType) {
ASSERT_FALSE(val.is_valid());
ValidationReport report("val");
val.ReportErrors(&report);
- ASSERT_EQ("val: value is not initialized\n", PrettyFormat(report));
+ ASSERT_EQ("val: value is not initialized", PrettyFormat(report));
}
TEST(ValidatedTypes, ReportNullInitializedNullableIntType) {
@@ -369,7 +369,7 @@ TEST(ValidatedTypes, ReportNoninitializedIntArray) {
ASSERT_FALSE(array.is_valid());
ValidationReport report("array");
array.ReportErrors(&report);
- ASSERT_EQ("array: object is not initialized\n", PrettyFormat(report));
+ ASSERT_EQ("array: object is not initialized", PrettyFormat(report));
}
TEST(ValidatedTypes, ReportIncorrectlyInitializedIntArray1) {
@@ -378,7 +378,7 @@ TEST(ValidatedTypes, ReportIncorrectlyInitializedIntArray1) {
ASSERT_FALSE(array.is_valid());
ValidationReport report("array");
array.ReportErrors(&report);
- ASSERT_EQ("array[0]: value initialized incorrectly\n", PrettyFormat(report));
+ ASSERT_EQ("array[0]: value initialized incorrectly", PrettyFormat(report));
}
TEST(ValidatedTypes, ReportIncorrectlyInitializedIntArray2) {
@@ -390,7 +390,7 @@ TEST(ValidatedTypes, ReportIncorrectlyInitializedIntArray2) {
ASSERT_FALSE(array.is_valid());
ValidationReport report("array");
array.ReportErrors(&report);
- ASSERT_EQ("array: array has invalid size\n", PrettyFormat(report));
+ ASSERT_EQ("array: array has invalid size", PrettyFormat(report));
}
TEST(ValidatedTypes, ReportIncorrectlyInitializedArray3) {
@@ -403,7 +403,7 @@ TEST(ValidatedTypes, ReportIncorrectlyInitializedArray3) {
array.ReportErrors(&report);
ASSERT_EQ(
"array: array has invalid size\n"
- "array[2]: value initialized incorrectly\n",
+ "array[2]: value initialized incorrectly",
PrettyFormat(report));
}
@@ -411,7 +411,7 @@ TEST(ValidatedTypes, ReportUninitializedMap) {
Map<Integer<int8_t, 1, 10>, 1, 3> map;
ValidationReport report("map");
map.ReportErrors(&report);
- ASSERT_EQ("map: object is not initialized\n", PrettyFormat(report));
+ ASSERT_EQ("map: object is not initialized", PrettyFormat(report));
}
TEST(ValidatedTypes, ReportIncorrectlyInitializedMap1) {
@@ -419,7 +419,7 @@ TEST(ValidatedTypes, ReportIncorrectlyInitializedMap1) {
map["aha"] = 42;
ValidationReport report("map");
map.ReportErrors(&report);
- ASSERT_EQ("map[\"aha\"]: value initialized incorrectly\n",
+ ASSERT_EQ("map[\"aha\"]: value initialized incorrectly",
PrettyFormat(report));
}
@@ -433,7 +433,7 @@ TEST(ValidatedTypes, ReportIncorrectlyInitializedMap2) {
map.ReportErrors(&report);
ASSERT_EQ(
"map[\"haha\"]: value initialized incorrectly\n"
- "map[\"muhahaha\"]: value initialized incorrectly\n",
+ "map[\"muhahaha\"]: value initialized incorrectly",
PrettyFormat(report));
}
diff --git a/src/components/rpc_base/test/validation_report_test.cc b/src/components/rpc_base/test/validation_report_test.cc
index 596bfdb20d..10effe7dd2 100644
--- a/src/components/rpc_base/test/validation_report_test.cc
+++ b/src/components/rpc_base/test/validation_report_test.cc
@@ -75,7 +75,7 @@ class ValidationReportTest : public testing::Test {
} else {
temp = "";
}
- result = parent_name + temp + obj_name + ":" + " " + val_info + "\n";
+ result = parent_name + temp + obj_name + ":" + " " + val_info;
}
void ClearValidationInfo() {
diff --git a/src/components/smart_objects/include/smart_objects/always_false_schema_item.h b/src/components/smart_objects/include/smart_objects/always_false_schema_item.h
index ea0ce33bd0..c4ebf21b51 100644
--- a/src/components/smart_objects/include/smart_objects/always_false_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/always_false_schema_item.h
@@ -59,12 +59,11 @@ class CAlwaysFalseSchemaItem : public ISchemaItem {
/**
* @brief Validate smart object.
* @param Object Object to validate.
- * @param errorMessage string reference to be filled with an appropriate error
- *message if an error occurs
+ * @param report__ object for reporting errors during validation
* @return Errors::ERROR
**/
Errors::eType validate(const SmartObject& Object,
- std::string& errorMessage) OVERRIDE;
+ rpc::ValidationReport* report__) OVERRIDE;
private:
CAlwaysFalseSchemaItem();
diff --git a/src/components/smart_objects/include/smart_objects/always_true_schema_item.h b/src/components/smart_objects/include/smart_objects/always_true_schema_item.h
index 0141e12ecb..8589a512b1 100644
--- a/src/components/smart_objects/include/smart_objects/always_true_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/always_true_schema_item.h
@@ -59,12 +59,11 @@ class CAlwaysTrueSchemaItem : public ISchemaItem {
/**
* @brief Validate smart object.
* @param Object Object to validate.
- * @param errorMessage string reference to be filled with an appropriate error
- *message if an error occurs
+ * @param report__ object for reporting errors during validation
* @return NsSmartObjects::Errors::eType
**/
Errors::eType validate(const SmartObject& Object,
- std::string& errorMessage) OVERRIDE;
+ rpc::ValidationReport* report__) OVERRIDE;
private:
CAlwaysTrueSchemaItem();
diff --git a/src/components/smart_objects/include/smart_objects/array_schema_item.h b/src/components/smart_objects/include/smart_objects/array_schema_item.h
index 455d50bf4b..37ad6cd5f5 100644
--- a/src/components/smart_objects/include/smart_objects/array_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/array_schema_item.h
@@ -78,13 +78,13 @@ class CArraySchemaItem : public ISchemaItem {
* @brief Validate smart object.
*
* @param Object Object to validate.
- * @param errorMessage string reference to be filled with an appropriate error
+ * @param report__ object for reporting errors during validation
* message if an error occurs
*
* @return NsSmartObjects::Errors::eType
**/
Errors::eType validate(const SmartObject& Object,
- std::string& errorMessage) OVERRIDE;
+ rpc::ValidationReport* report__) OVERRIDE;
/**
* @brief Apply schema.
diff --git a/src/components/smart_objects/include/smart_objects/default_shema_item.h b/src/components/smart_objects/include/smart_objects/default_shema_item.h
index 0cd5f42ac8..7702362b52 100644
--- a/src/components/smart_objects/include/smart_objects/default_shema_item.h
+++ b/src/components/smart_objects/include/smart_objects/default_shema_item.h
@@ -60,12 +60,11 @@ class CDefaultSchemaItem : public ISchemaItem {
/**
* @brief Validate smart object.
* @param Object Object to validate.
- * @param errorMessage string reference to be filled with an appropriate error
- *message if an error occurs
+ * @param report__ object for reporting errors during validation
* @return Errors::ERROR
**/
Errors::eType validate(const SmartObject& Object,
- std::string& errorMessage) OVERRIDE;
+ rpc::ValidationReport* report__) OVERRIDE;
/**
* @brief Set default value to an object.
@@ -110,20 +109,19 @@ CDefaultSchemaItem<Type>::CDefaultSchemaItem(const ParameterType& DefaultValue)
template <typename Type>
Errors::eType CDefaultSchemaItem<Type>::validate(const SmartObject& Object) {
- std::string errorMessage;
- return validate(Object, errorMessage);
+ rpc::ValidationReport report("RPC");
+ return validate(Object, &report);
}
template <typename Type>
-Errors::eType CDefaultSchemaItem<Type>::validate(const SmartObject& Object,
- std::string& errorMessage) {
+Errors::eType CDefaultSchemaItem<Type>::validate(
+ const SmartObject& Object, rpc::ValidationReport* report__) {
if (getSmartType() != Object.getType()) {
- if (!Object.getKey().empty()) {
- errorMessage.assign("Validation failed for " + Object.getKey() + ". ");
- }
- errorMessage += "Incorrect type, expected: " +
- SmartObject::typeToString(getSmartType()) + ", got: " +
- SmartObject::typeToString(Object.getType());
+ std::string validation_info = "Incorrect type, expected: " +
+ SmartObject::typeToString(getSmartType()) +
+ ", got: " +
+ SmartObject::typeToString(Object.getType());
+ report__->set_validation_info(validation_info);
return Errors::INVALID_VALUE;
} else {
return Errors::OK;
diff --git a/src/components/smart_objects/include/smart_objects/enum_schema_item.h b/src/components/smart_objects/include/smart_objects/enum_schema_item.h
index 2c0ae53aed..dbc40b9131 100644
--- a/src/components/smart_objects/include/smart_objects/enum_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/enum_schema_item.h
@@ -68,19 +68,18 @@ class TEnumSchemaItem : public CDefaultSchemaItem<EnumType> {
* @deprecated
* @brief Validate smart object.
* @param Object Object to validate.
- * @return Errors::ERROR
+ * @return NsSmartObjects::Errors::eType
**/
// DEPRECATED
Errors::eType validate(const SmartObject& Object) OVERRIDE;
/**
* @brief Validate smart object.
* @param Object Object to validate.
- * @param errorMessage string reference to be filled with an appropriate error
- *message if an error occurs
- * @return Errors::ERROR
+ * @param report__ object for reporting errors during validation
+ * @return NsSmartObjects::Errors::eType
**/
Errors::eType validate(const SmartObject& Object,
- std::string& errorMessage) OVERRIDE;
+ rpc::ValidationReport* report__) OVERRIDE;
/**
* @brief Apply schema.
* This implementation checks if enumeration is represented as string
@@ -218,36 +217,32 @@ utils::SharedPtr<TEnumSchemaItem<EnumType> > TEnumSchemaItem<EnumType>::create(
template <typename EnumType>
Errors::eType TEnumSchemaItem<EnumType>::validate(const SmartObject& Object) {
- std::string errorMessage;
- return validate(Object, errorMessage);
+ rpc::ValidationReport report("RPC");
+ return validate(Object, &report);
}
template <typename EnumType>
-Errors::eType TEnumSchemaItem<EnumType>::validate(const SmartObject& Object,
- std::string& errorMessage) {
+Errors::eType TEnumSchemaItem<EnumType>::validate(
+ const SmartObject& Object, rpc::ValidationReport* report__) {
if (SmartType_Integer != Object.getType()) {
- if (!Object.getKey().empty()) {
- errorMessage.assign("Validation failed for " + Object.getKey() + ". ");
- }
-
+ std::string validation_info;
if (SmartType_String == Object.getType()) {
- errorMessage += "Invalid enum value: " + Object.asString();
+ validation_info = "Invalid enum value: " + Object.asString();
} else {
- errorMessage += "Incorrect type, expected: " +
- SmartObject::typeToString(SmartType_Integer) +
- " (enum), got: " +
- SmartObject::typeToString(Object.getType());
+ validation_info = "Incorrect type, expected: " +
+ SmartObject::typeToString(SmartType_Integer) +
+ " (enum), got: " +
+ SmartObject::typeToString(Object.getType());
}
+ report__->set_validation_info(validation_info);
return Errors::INVALID_VALUE;
}
if (mAllowedElements.find(static_cast<EnumType>(Object.asInt())) ==
mAllowedElements.end()) {
- if (!Object.getKey().empty()) {
- errorMessage.assign("Validation failed for " + Object.getKey() + ". ");
- }
std::stringstream stream;
stream << "Invalid enum value: " << Object.asInt();
- errorMessage += stream.str();
+ std::string validation_info = stream.str();
+ report__->set_validation_info(validation_info);
return Errors::OUT_OF_RANGE;
}
return Errors::OK;
diff --git a/src/components/smart_objects/include/smart_objects/number_schema_item.h b/src/components/smart_objects/include/smart_objects/number_schema_item.h
index dddb7c3b02..eba64693b2 100644
--- a/src/components/smart_objects/include/smart_objects/number_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/number_schema_item.h
@@ -75,12 +75,11 @@ class TNumberSchemaItem : public CDefaultSchemaItem<NumberType> {
/**
* @brief Validate smart object.
* @param Object Object to validate.
- * @param errorMessage string reference to be filled with an appropriate error
- *message if an error occurs
+ * @param report__ object for reporting errors during validation
* @return Errors::ERROR
**/
Errors::eType validate(const SmartObject& Object,
- std::string& errorMessage) OVERRIDE;
+ rpc::ValidationReport* report__) OVERRIDE;
private:
/**
@@ -139,23 +138,21 @@ bool TNumberSchemaItem<NumberType>::isValidNumberType(SmartType type) {
template <typename NumberType>
Errors::eType TNumberSchemaItem<NumberType>::validate(
const SmartObject& Object) {
- std::string errorMessage;
- return validate(Object, errorMessage);
+ rpc::ValidationReport report("RPC");
+ return validate(Object, &report);
}
template <typename NumberType>
Errors::eType TNumberSchemaItem<NumberType>::validate(
- const SmartObject& Object, std::string& errorMessage) {
+ const SmartObject& Object, rpc::ValidationReport* report__) {
if (!isValidNumberType(Object.getType())) {
- if (!Object.getKey().empty()) {
- errorMessage.assign("Validation failed for " + Object.getKey() + ". ");
- }
SmartType expectedType = (typeid(double) == typeid(Object.getType()))
? SmartType_Double
: SmartType_Integer;
- errorMessage += "Incorrect type, expected: " +
- SmartObject::typeToString(expectedType) + ", got: " +
- SmartObject::typeToString(Object.getType());
+ std::string validation_info =
+ "Incorrect type, expected: " + SmartObject::typeToString(expectedType) +
+ ", got: " + SmartObject::typeToString(Object.getType());
+ report__->set_validation_info(validation_info);
return Errors::INVALID_VALUE;
}
NumberType value(0);
@@ -175,24 +172,20 @@ Errors::eType TNumberSchemaItem<NumberType>::validate(
NumberType rangeLimit;
if (mMinValue.getValue(rangeLimit) && (value < rangeLimit)) {
- if (!Object.getKey().empty()) {
- errorMessage.assign("Validation failed for " + Object.getKey() + ". ");
- }
std::stringstream stream;
stream << "Value too small, got: " << value
<< ", minimum allowed: " << rangeLimit;
- errorMessage += stream.str();
+ std::string validation_info = stream.str();
+ report__->set_validation_info(validation_info);
return Errors::OUT_OF_RANGE;
}
if (mMaxValue.getValue(rangeLimit) && (value > rangeLimit)) {
- if (!Object.getKey().empty()) {
- errorMessage.assign("Validation failed for " + Object.getKey() + ". ");
- }
std::stringstream stream;
stream << "Value too large, got: " << value
<< ", maximum allowed: " << rangeLimit;
- errorMessage += stream.str();
+ std::string validation_info = stream.str();
+ report__->set_validation_info(validation_info);
return Errors::OUT_OF_RANGE;
}
return Errors::OK;
diff --git a/src/components/smart_objects/include/smart_objects/object_schema_item.h b/src/components/smart_objects/include/smart_objects/object_schema_item.h
index 92e2936722..fcd84dbece 100644
--- a/src/components/smart_objects/include/smart_objects/object_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/object_schema_item.h
@@ -94,12 +94,11 @@ class CObjectSchemaItem : public ISchemaItem {
/**
* @brief Validate smart object.
* @param Object Object to validate.
- * @param errorMessage string reference to be filled with an appropriate error
- *message if an error occurs
+ * @param report__ object for reporting errors during validation
* @return NsSmartObjects::Errors::eType
**/
Errors::eType validate(const SmartObject& Object,
- std::string& errorMessage) OVERRIDE;
+ rpc::ValidationReport* report__) OVERRIDE;
/**
* @brief Apply schema.
* @param Object Object to apply schema.
diff --git a/src/components/smart_objects/include/smart_objects/schema_item.h b/src/components/smart_objects/include/smart_objects/schema_item.h
index 9cee326fdd..807443d5e1 100644
--- a/src/components/smart_objects/include/smart_objects/schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/schema_item.h
@@ -34,6 +34,7 @@
#include <stdlib.h>
#include "utils/shared_ptr.h"
+#include "rpc_base/validation_report.h"
#include "smart_objects/errors.h"
@@ -62,13 +63,13 @@ class ISchemaItem {
* @brief Validate smart object.
*
* @param Object Object to validate.
- * @param errorMessage string reference to be filled with an appropriate error
+ * @param report__ object for reporting errors during validation
* message if an error occurs
*
* @return NsSmartObjects::Errors::eType
**/
virtual Errors::eType validate(const SmartObject& Object,
- std::string& errorMessage);
+ rpc::ValidationReport* report__);
/**
* @brief Set default value to an object.
diff --git a/src/components/smart_objects/include/smart_objects/smart_object.h b/src/components/smart_objects/include/smart_objects/smart_object.h
index ef3775e098..de058164bf 100644
--- a/src/components/smart_objects/include/smart_objects/smart_object.h
+++ b/src/components/smart_objects/include/smart_objects/smart_object.h
@@ -40,6 +40,7 @@
#include "smart_objects/smart_schema.h"
#include "utils/custom_string.h"
+#include "rpc_base/validation_report.h"
namespace NsSmartDeviceLink {
namespace NsSmartObjects {
@@ -681,11 +682,10 @@ class SmartObject FINAL {
/**
* @brief Validates object according to attached schema.
*
- * @param errorMessage string reference to be filled with an appropriate error
- *message if an error occurs
+ * @param report__ object for reporting errors during validation
* @return Result of validation.
*/
- Errors::eType validate(std::string& errorMessage);
+ Errors::eType validate(rpc::ValidationReport* report__);
/**
* @brief Sets new schema
@@ -710,21 +710,6 @@ class SmartObject FINAL {
SmartType getType() const;
/**
- * @brief Sets new key for this object
- *
- * @param std::string New key sequesnce
- * @return void
- **/
- void setKey(const std::string& NewKey);
-
- /**
- * @brief Returns current object type
- *
- * @return std::string
- **/
- std::string getKey() const;
-
- /**
* @brief Returns length of object
*
* If object has type string, array or map then method returns corresponded
@@ -1031,12 +1016,6 @@ class SmartObject FINAL {
* @brief Validation schema, attached to the object
**/
CSmartSchema m_schema;
-
- /**
- * @brief Key sequence that describes where the current object is within an
- *object structure, for debugging purposes
- **/
- std::string* m_key;
};
/**
diff --git a/src/components/smart_objects/include/smart_objects/smart_schema.h b/src/components/smart_objects/include/smart_objects/smart_schema.h
index e9aaf2e97c..87a7d4e9a0 100644
--- a/src/components/smart_objects/include/smart_objects/smart_schema.h
+++ b/src/components/smart_objects/include/smart_objects/smart_schema.h
@@ -76,13 +76,12 @@ class CSmartSchema FINAL {
* @brief Validate smart object.
*
* @param Object Object to validate.
- * @param errorMessage string reference to be filled with an appropriate error
- *message if an error occurs
+ * @param report__ object for reporting errors during validation
*
* @return NsSmartObjects::Errors::eType
**/
Errors::eType validate(const SmartObject& Object,
- std::string& errorMessage) const;
+ rpc::ValidationReport* report__) const;
/**
* @brief Set new root schema item.
diff --git a/src/components/smart_objects/include/smart_objects/string_schema_item.h b/src/components/smart_objects/include/smart_objects/string_schema_item.h
index 755e2f7258..abe9c9d1f1 100644
--- a/src/components/smart_objects/include/smart_objects/string_schema_item.h
+++ b/src/components/smart_objects/include/smart_objects/string_schema_item.h
@@ -72,12 +72,11 @@ class CStringSchemaItem : public CDefaultSchemaItem<std::string> {
/**
* @brief Validate smart object.
* @param Object Object to validate.
- * @param errorMessage string reference to be filled with an appropriate error
- *message if an error occurs
+ * @param report__ object for reporting errors during validation
* @return NsSmartObjects::Errors::eType
**/
Errors::eType validate(const SmartObject& Object,
- std::string& errorMessage) OVERRIDE;
+ rpc::ValidationReport* report__) OVERRIDE;
private:
/**
diff --git a/src/components/smart_objects/src/always_false_schema_item.cc b/src/components/smart_objects/src/always_false_schema_item.cc
index d6e2db3900..1893ed24d1 100644
--- a/src/components/smart_objects/src/always_false_schema_item.cc
+++ b/src/components/smart_objects/src/always_false_schema_item.cc
@@ -42,13 +42,13 @@ utils::SharedPtr<CAlwaysFalseSchemaItem> CAlwaysFalseSchemaItem::create() {
}
Errors::eType CAlwaysFalseSchemaItem::validate(const SmartObject& object) {
- std::string errorMessage;
- return validate(object, errorMessage);
+ rpc::ValidationReport report("RPC");
+ return validate(object, &report);
}
-Errors::eType CAlwaysFalseSchemaItem::validate(const SmartObject& object,
- std::string& errorMessage) {
- errorMessage.assign("Generic error");
+Errors::eType CAlwaysFalseSchemaItem::validate(
+ const SmartObject& object, rpc::ValidationReport* report__) {
+ report__->set_validation_info("Generic error");
return Errors::ERROR;
}
} // namespace NsSmartObjects
diff --git a/src/components/smart_objects/src/always_true_schema_item.cc b/src/components/smart_objects/src/always_true_schema_item.cc
index 2521dbc2d4..1e7115316d 100644
--- a/src/components/smart_objects/src/always_true_schema_item.cc
+++ b/src/components/smart_objects/src/always_true_schema_item.cc
@@ -44,7 +44,7 @@ Errors::eType CAlwaysTrueSchemaItem::validate(const SmartObject& object) {
}
Errors::eType CAlwaysTrueSchemaItem::validate(const SmartObject& object,
- std::string& errorMessage) {
+ rpc::ValidationReport* report__) {
return Errors::OK;
}
diff --git a/src/components/smart_objects/src/array_schema_item.cc b/src/components/smart_objects/src/array_schema_item.cc
index 99d0a89252..dca0a815e0 100644
--- a/src/components/smart_objects/src/array_schema_item.cc
+++ b/src/components/smart_objects/src/array_schema_item.cc
@@ -42,48 +42,45 @@ utils::SharedPtr<CArraySchemaItem> CArraySchemaItem::create(
}
Errors::eType CArraySchemaItem::validate(const SmartObject& Object) {
- std::string errorMessage;
- return validate(Object, errorMessage);
+ rpc::ValidationReport report("RPC");
+ return validate(Object, &report);
}
Errors::eType CArraySchemaItem::validate(const SmartObject& Object,
- std::string& errorMessage) {
+ rpc::ValidationReport* report__) {
if (SmartType_Array != Object.getType()) {
- if (!Object.getKey().empty()) {
- errorMessage.assign("Validation failed for " + Object.getKey() + ". ");
- }
- errorMessage += "Incorrect type, expected: " +
- SmartObject::typeToString(SmartType_Array) + ", got: " +
- SmartObject::typeToString(Object.getType());
+ std::string validation_info = "Incorrect type, expected: " +
+ SmartObject::typeToString(SmartType_Array) +
+ ", got: " +
+ SmartObject::typeToString(Object.getType());
+ report__->set_validation_info(validation_info);
return Errors::INVALID_VALUE;
}
size_t sizeLimit;
const size_t array_len = Object.length();
if (mMinSize.getValue(sizeLimit) && (array_len < sizeLimit)) {
- if (!Object.getKey().empty()) {
- errorMessage.assign("Validation failed for " + Object.getKey() + ". ");
- }
std::stringstream stream;
stream << "Got array of size: " << array_len
<< ", minimum allowed: " << sizeLimit;
- errorMessage += stream.str();
+ std::string validation_info = stream.str();
+ report__->set_validation_info(validation_info);
return Errors::OUT_OF_RANGE;
}
if (mMaxSize.getValue(sizeLimit) && (array_len > sizeLimit)) {
- if (!Object.getKey().empty()) {
- errorMessage.assign("Validation failed for " + Object.getKey() + ". ");
- }
std::stringstream stream;
stream << "Got array of size: " << array_len
<< ", maximum allowed: " << sizeLimit;
- errorMessage += stream.str();
+ std::string validation_info = stream.str();
+ report__->set_validation_info(validation_info);
return Errors::OUT_OF_RANGE;
}
for (size_t i = 0u; i < array_len; ++i) {
- const Errors::eType result =
- mElementSchemaItem->validate(Object.getElement(i), errorMessage);
+ std::stringstream strVal;
+ strVal << i;
+ const Errors::eType result = mElementSchemaItem->validate(
+ Object.getElement(i), &report__->ReportSubobject(strVal.str()));
if (Errors::OK != result) {
return result;
}
diff --git a/src/components/smart_objects/src/object_schema_item.cc b/src/components/smart_objects/src/object_schema_item.cc
index 1a699e9fdd..2bed3d9a26 100644
--- a/src/components/smart_objects/src/object_schema_item.cc
+++ b/src/components/smart_objects/src/object_schema_item.cc
@@ -57,19 +57,18 @@ utils::SharedPtr<CObjectSchemaItem> CObjectSchemaItem::create(
}
Errors::eType CObjectSchemaItem::validate(const SmartObject& object) {
- std::string errorMessage;
- return validate(object, errorMessage);
+ rpc::ValidationReport report("RPC");
+ return validate(object, &report);
}
Errors::eType CObjectSchemaItem::validate(const SmartObject& object,
- std::string& errorMessage) {
+ rpc::ValidationReport* report__) {
if (SmartType_Map != object.getType()) {
- if (!object.getKey().empty()) {
- errorMessage.assign("Validation failed for " + object.getKey() + ". ");
- }
- errorMessage += "Incorrect type, expected: " +
- SmartObject::typeToString(SmartType_Map) + ", got: " +
- SmartObject::typeToString(object.getType());
+ std::string validation_info = "Incorrect type, expected: " +
+ SmartObject::typeToString(SmartType_Map) +
+ ", got: " +
+ SmartObject::typeToString(object.getType());
+ report__->set_validation_info(validation_info);
return Errors::INVALID_VALUE;
}
@@ -83,18 +82,15 @@ Errors::eType CObjectSchemaItem::validate(const SmartObject& object,
std::set<std::string>::const_iterator key_it = object_keys.find(key);
if (object_keys.end() == key_it) {
if (member.mIsMandatory) {
- if (!object.getKey().empty()) {
- errorMessage.assign("Validation failed for " + object.getKey() +
- ". ");
- }
- errorMessage += "Missing mandatory parameter: " + key;
+ std::string validation_info = "Missing mandatory parameter: " + key;
+ report__->set_validation_info(validation_info);
return Errors::MISSING_MANDATORY_PARAMETER;
}
continue;
}
const SmartObject& field = object.getElement(key);
const Errors::eType result =
- member.mSchemaItem->validate(field, errorMessage);
+ member.mSchemaItem->validate(field, &report__->ReportSubobject(key));
if (Errors::OK != result) {
return result;
}
diff --git a/src/components/smart_objects/src/schema_item.cc b/src/components/smart_objects/src/schema_item.cc
index 27e2b04c73..22735d40d5 100644
--- a/src/components/smart_objects/src/schema_item.cc
+++ b/src/components/smart_objects/src/schema_item.cc
@@ -40,7 +40,7 @@ Errors::eType ISchemaItem::validate(const SmartObject& Object) {
}
Errors::eType ISchemaItem::validate(const SmartObject& object,
- std::string& errorMessage) {
+ rpc::ValidationReport* report__) {
return Errors::ERROR;
}
diff --git a/src/components/smart_objects/src/smart_object.cc b/src/components/smart_objects/src/smart_object.cc
index 0e3070e524..a0925eef05 100644
--- a/src/components/smart_objects/src/smart_object.cc
+++ b/src/components/smart_objects/src/smart_object.cc
@@ -50,18 +50,17 @@ namespace NsSmartObjects {
**/
static const char* invalid_cstr_value = "";
-SmartObject::SmartObject() : m_type(SmartType_Null), m_schema(), m_key(NULL) {
+SmartObject::SmartObject() : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
}
SmartObject::SmartObject(const SmartObject& Other)
- : m_type(SmartType_Null), m_schema(), m_key(NULL) {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
duplicate(Other);
}
-SmartObject::SmartObject(SmartType Type)
- : m_type(SmartType_Null), m_schema(), m_key(NULL) {
+SmartObject::SmartObject(SmartType Type) : m_type(SmartType_Null), m_schema() {
switch (Type) {
case SmartType_Null:
break;
@@ -105,8 +104,6 @@ SmartObject::SmartObject(SmartType Type)
SmartObject::~SmartObject() {
cleanup_data();
- delete m_key;
- m_key = NULL;
}
SmartObject& SmartObject::operator=(const SmartObject& Other) {
@@ -116,7 +113,7 @@ SmartObject& SmartObject::operator=(const SmartObject& Other) {
}
bool SmartObject::operator==(const SmartObject& Other) const {
- if (m_type != Other.m_type || m_key != Other.m_key)
+ if (m_type != Other.m_type)
return false;
switch (m_type) {
@@ -171,7 +168,7 @@ bool SmartObject::operator==(const SmartObject& Other) const {
}
SmartObject::SmartObject(int32_t InitialValue)
- : m_type(SmartType_Null), m_schema(), m_key(NULL) {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
set_value_integer(InitialValue);
}
@@ -228,7 +225,7 @@ int64_t SmartObject::convert_int() const {
}
SmartObject::SmartObject(uint32_t InitialValue)
- : m_type(SmartType_Null), m_schema(), m_key(NULL) {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
set_value_integer(InitialValue);
}
@@ -257,7 +254,7 @@ bool SmartObject::operator==(const uint32_t Value) const {
}
SmartObject::SmartObject(int64_t InitialValue)
- : m_type(SmartType_Null), m_schema(), m_key(NULL) {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
set_value_integer(InitialValue);
}
@@ -285,7 +282,7 @@ SmartObject& SmartObject::operator=(const uint64_t NewValue) {
}
SmartObject::SmartObject(double InitialValue)
- : m_type(SmartType_Null), m_schema(), m_key(NULL) {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
set_value_double(InitialValue);
}
@@ -331,7 +328,7 @@ double SmartObject::convert_double() const {
}
SmartObject::SmartObject(bool InitialValue)
- : m_type(SmartType_Null), m_schema(), m_key(NULL) {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
set_value_bool(InitialValue);
}
@@ -376,7 +373,7 @@ bool SmartObject::convert_bool() const {
}
SmartObject::SmartObject(char InitialValue)
- : m_type(SmartType_Null), m_schema(), m_key(NULL) {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
set_value_char(InitialValue);
}
@@ -425,13 +422,13 @@ char SmartObject::convert_char() const {
// =============================================================
SmartObject::SmartObject(const custom_str::CustomString& InitialValue)
- : m_type(SmartType_Null), m_schema(), m_key(NULL) {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
set_value_string(InitialValue);
}
SmartObject::SmartObject(const std::string& InitialValue)
- : m_type(SmartType_Null), m_schema(), m_key(NULL) {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
set_value_string(custom_str::CustomString(InitialValue));
}
@@ -511,7 +508,7 @@ custom_str::CustomString SmartObject::convert_custom_string() const {
// =============================================================
SmartObject::SmartObject(const char* const InitialValue)
- : m_type(SmartType_Null), m_schema(), m_key(NULL) {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
set_value_cstr(InitialValue);
return;
@@ -541,7 +538,7 @@ void SmartObject::set_value_cstr(const char* NewValue) {
// BINARY TYPE SUPPORT
// =============================================================
SmartObject::SmartObject(const SmartBinary& InitialValue)
- : m_type(SmartType_Null), m_schema(), m_key(NULL) {
+ : m_type(SmartType_Null), m_schema() {
m_data.str_value = NULL;
set_value_binary(InitialValue);
}
@@ -726,10 +723,6 @@ void SmartObject::duplicate(const SmartObject& OtherObject) {
}
m_schema = OtherObject.m_schema;
- if (OtherObject.m_key) {
- setKey(*OtherObject.m_key);
- }
-
cleanup_data();
m_type = newType;
@@ -845,15 +838,6 @@ SmartType SmartObject::getType() const {
return m_type;
}
-void SmartObject::setKey(const std::string& NewKey) {
- delete m_key;
- m_key = new std::string(NewKey);
-}
-
-std::string SmartObject::getKey() const {
- return (m_key == NULL) ? "" : *m_key;
-}
-
std::string SmartObject::OperatorToTransform(const SmartMap::value_type& pair) {
return pair.first;
}
@@ -885,18 +869,17 @@ bool SmartObject::erase(const std::string& Key) {
}
bool SmartObject::isValid() const {
- std::string errorMessage;
-
- return (Errors::OK == m_schema.validate(*this, errorMessage));
+ rpc::ValidationReport report("RPC");
+ return (Errors::OK == m_schema.validate(*this, &report));
}
Errors::eType SmartObject::validate() {
- std::string errorMessage;
- return validate(errorMessage);
+ rpc::ValidationReport report("RPC");
+ return validate(&report);
}
-Errors::eType SmartObject::validate(std::string& errorMessage) {
- return m_schema.validate(*this, errorMessage);
+Errors::eType SmartObject::validate(rpc::ValidationReport* report__) {
+ return m_schema.validate(*this, report__);
}
void SmartObject::setSchema(const CSmartSchema& schema) {
diff --git a/src/components/smart_objects/src/smart_schema.cc b/src/components/smart_objects/src/smart_schema.cc
index 2c99244b76..7509ea80f1 100644
--- a/src/components/smart_objects/src/smart_schema.cc
+++ b/src/components/smart_objects/src/smart_schema.cc
@@ -41,13 +41,13 @@ CSmartSchema::CSmartSchema(const ISchemaItemPtr SchemaItem)
: mSchemaItem(SchemaItem) {}
Errors::eType CSmartSchema::validate(const SmartObject& Object) const {
- std::string errorMessage;
- return validate(Object, errorMessage);
+ rpc::ValidationReport report("RPC");
+ return validate(Object, &report);
}
Errors::eType CSmartSchema::validate(const SmartObject& object,
- std::string& errorMessage) const {
- return mSchemaItem->validate(object, errorMessage);
+ rpc::ValidationReport* report__) const {
+ return mSchemaItem->validate(object, report__);
}
void CSmartSchema::setSchemaItem(const ISchemaItemPtr schemaItem) {
diff --git a/src/components/smart_objects/src/string_schema_item.cc b/src/components/smart_objects/src/string_schema_item.cc
index f82ce9378c..1e4c8372f0 100644
--- a/src/components/smart_objects/src/string_schema_item.cc
+++ b/src/components/smart_objects/src/string_schema_item.cc
@@ -46,19 +46,18 @@ utils::SharedPtr<CStringSchemaItem> CStringSchemaItem::create(
}
Errors::eType CStringSchemaItem::validate(const SmartObject& Object) {
- std::string errorMessage;
- return validate(Object, errorMessage);
+ rpc::ValidationReport report("RPC");
+ return validate(Object, &report);
}
Errors::eType CStringSchemaItem::validate(const SmartObject& Object,
- std::string& errorMessage) {
+ rpc::ValidationReport* report__) {
if (SmartType_String != Object.getType()) {
- if (!Object.getKey().empty()) {
- errorMessage.assign("Validation failed for " + Object.getKey() + ". ");
- }
- errorMessage += "Incorrect type, expected: " +
- SmartObject::typeToString(SmartType_String) + ", got: " +
- SmartObject::typeToString(Object.getType());
+ std::string validation_info = "Incorrect type, expected: " +
+ SmartObject::typeToString(SmartType_String) +
+ ", got: " +
+ SmartObject::typeToString(Object.getType());
+ report__->set_validation_info(validation_info);
return Errors::INVALID_VALUE;
}
@@ -66,23 +65,19 @@ Errors::eType CStringSchemaItem::validate(const SmartObject& Object,
size_t length;
if (mMinLength.getValue(length) && (value.size() < length)) {
- if (!Object.getKey().empty()) {
- errorMessage.assign("Validation failed for " + Object.getKey() + ". ");
- }
std::stringstream stream;
stream << "Got string of size: " << value.size()
<< ", minimum allowed: " << length;
- errorMessage += stream.str();
+ std::string validation_info = stream.str();
+ report__->set_validation_info(validation_info);
return Errors::OUT_OF_RANGE;
}
if (mMaxLength.getValue(length) && (value.size() > length)) {
- if (!Object.getKey().empty()) {
- errorMessage.assign("Validation failed for " + Object.getKey() + ". ");
- }
std::stringstream stream;
stream << "Got string of size: " << value.size()
<< ", maximum allowed: " << length;
- errorMessage += stream.str();
+ std::string validation_info = stream.str();
+ report__->set_validation_info(validation_info);
return Errors::OUT_OF_RANGE;
}
return Errors::OK;
diff --git a/src/components/smart_objects/test/AlwaysFalseSchemaItem_test.cc b/src/components/smart_objects/test/AlwaysFalseSchemaItem_test.cc
index 71891f45d8..9d88178598 100644
--- a/src/components/smart_objects/test/AlwaysFalseSchemaItem_test.cc
+++ b/src/components/smart_objects/test/AlwaysFalseSchemaItem_test.cc
@@ -52,39 +52,39 @@ TEST(test_AlwaysFalseSchemaItemTest, simple_test) {
ISchemaItemPtr item = CAlwaysFalseSchemaItem::create();
obj = 5;
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::ERROR, resultType);
EXPECT_EQ(5, obj.asInt());
obj = true;
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::ERROR, resultType);
EXPECT_TRUE(obj.asBool());
obj = "Test";
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::ERROR, resultType);
EXPECT_EQ(std::string("Test"), obj.asString());
obj["First"] = "Some string";
obj["Second"] = 555;
- resultType = item->validate(obj["First"], errorMessage);
+ resultType = item->validate(obj["First"], &report);
EXPECT_EQ(Errors::ERROR, resultType);
- resultType = item->validate(obj["Second"], errorMessage);
+ resultType = item->validate(obj["Second"], &report);
EXPECT_EQ(Errors::ERROR, resultType);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::ERROR, resultType);
EXPECT_EQ(std::string("Some string"), obj["First"].asString());
EXPECT_EQ(555, obj["Second"].asInt());
obj[0] = true;
obj[1] = false;
- resultType = item->validate(obj[0], errorMessage);
+ resultType = item->validate(obj[0], &report);
EXPECT_EQ(Errors::ERROR, resultType);
- resultType = item->validate(obj[1], errorMessage);
+ resultType = item->validate(obj[1], &report);
EXPECT_EQ(Errors::ERROR, resultType);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::ERROR, resultType);
EXPECT_TRUE(obj[0].asBool());
EXPECT_FALSE(obj[1].asBool());
diff --git a/src/components/smart_objects/test/AlwaysTrueSchemaItem_test.cc b/src/components/smart_objects/test/AlwaysTrueSchemaItem_test.cc
index 57b40440b8..40c827e17b 100644
--- a/src/components/smart_objects/test/AlwaysTrueSchemaItem_test.cc
+++ b/src/components/smart_objects/test/AlwaysTrueSchemaItem_test.cc
@@ -52,39 +52,39 @@ TEST(test_AlwaysTrueSchemaItemTest, simple_test) {
ISchemaItemPtr item = CAlwaysTrueSchemaItem::create();
obj = 5;
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
EXPECT_EQ(5, obj.asInt());
obj = true;
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
EXPECT_TRUE(obj.asBool());
obj = "Test";
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
EXPECT_EQ(std::string("Test"), obj.asString());
obj["First"] = "Some string";
obj["Second"] = 555;
- resultType = item->validate(obj["First"], errorMessage);
+ resultType = item->validate(obj["First"], &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj["Second"], errorMessage);
+ resultType = item->validate(obj["Second"], &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
EXPECT_EQ(std::string("Some string"), obj["First"].asString());
EXPECT_EQ(555, obj["Second"].asInt());
obj[0] = true;
obj[1] = false;
- resultType = item->validate(obj[0], errorMessage);
+ resultType = item->validate(obj[0], &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj[1], errorMessage);
+ resultType = item->validate(obj[1], &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
EXPECT_TRUE(obj[0].asBool());
EXPECT_FALSE(obj[1].asBool());
diff --git a/src/components/smart_objects/test/ArraySchemaItem_test.cc b/src/components/smart_objects/test/ArraySchemaItem_test.cc
index 1bb66b0132..9831f08442 100644
--- a/src/components/smart_objects/test/ArraySchemaItem_test.cc
+++ b/src/components/smart_objects/test/ArraySchemaItem_test.cc
@@ -66,29 +66,29 @@ TEST(test_no_default_value, test_ArraySchemaItemTest) {
EXPECT_FALSE(obj[3][1].asBool());
EXPECT_EQ(std::string("Another String"), obj[3][2].asString());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj[0], errorMessage);
+ resultType = item->validate(obj[0], &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[1], errorMessage);
+ resultType = item->validate(obj[1], &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[2], errorMessage);
+ resultType = item->validate(obj[2], &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[3], errorMessage);
+ resultType = item->validate(obj[3], &report);
EXPECT_EQ(Errors::OK, resultType);
item->applySchema(obj, false);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj[0], errorMessage);
+ resultType = item->validate(obj[0], &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[1], errorMessage);
+ resultType = item->validate(obj[1], &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[2], errorMessage);
+ resultType = item->validate(obj[2], &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[3], errorMessage);
+ resultType = item->validate(obj[3], &report);
EXPECT_EQ(Errors::OK, resultType);
EXPECT_EQ(38, obj[0].asInt());
@@ -102,19 +102,19 @@ TEST(test_no_default_value, test_ArraySchemaItemTest) {
obj = "New valid string";
ASSERT_EQ(std::string("New valid string"), obj.asString());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
// Obj - bool
obj = true;
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
// Object - number
obj = 3.1415926;
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
}
@@ -138,25 +138,25 @@ TEST(test_item_with_default_value, test_ArraySchemaItemTest) {
EXPECT_EQ(std::string("true"), obj[1].asString());
EXPECT_EQ(std::string("New String"), obj[2].asString());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj[0], errorMessage);
+ resultType = item->validate(obj[0], &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[1], errorMessage);
+ resultType = item->validate(obj[1], &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[2], errorMessage);
+ resultType = item->validate(obj[2], &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
item->applySchema(obj, false);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj[0], errorMessage);
+ resultType = item->validate(obj[0], &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[1], errorMessage);
+ resultType = item->validate(obj[1], &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[2], errorMessage);
+ resultType = item->validate(obj[2], &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
EXPECT_EQ(std::string("Some String"), obj[0].asString());
@@ -171,14 +171,14 @@ TEST(test_item_with_default_value, test_ArraySchemaItemTest) {
EXPECT_EQ(std::string("false"), obj[3][1].asString());
EXPECT_EQ(std::string("Another String"), obj[3][2].asString());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj[3], errorMessage);
+ resultType = item->validate(obj[3], &report);
EXPECT_EQ(Errors::OK, resultType);
obj[3][3] = "Another very very loooooong String";
- resultType = item->validate(obj[3], errorMessage);
+ resultType = item->validate(obj[3], &report);
EXPECT_EQ(Errors::OK, resultType);
}
@@ -195,18 +195,18 @@ TEST(test_array_with_min_size, test_ArraySchemaItemTest) {
obj[0] = "Some String";
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
obj[1] = "true";
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
obj[2] = "New String";
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
EXPECT_EQ(std::string("Some String"), obj[0].asString());
@@ -229,23 +229,23 @@ TEST(test_array_with_max_size, test_ArraySchemaItemTest) {
obj[0] = "Some String";
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
obj[1] = "true";
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
obj[2] = "New String";
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
obj[3] = "Another String";
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
EXPECT_EQ(std::string("Some String"), obj[0].asString());
@@ -269,28 +269,28 @@ TEST(test_array_with_min_and_max_size, test_ArraySchemaItemTest) {
obj[0] = "Some String";
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
obj[1] = "true";
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
obj[2] = "New String";
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
obj[3] = "Another String";
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
obj[4] = "Out of array";
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
EXPECT_EQ(std::string("Some String"), obj[0].asString());
@@ -312,30 +312,30 @@ TEST(test_map_validate, test_ArraySchemaItemTest) {
obj["array"][0] = "Some String";
- std::string errorMessage;
- int resultType = item->validate(obj["array"], errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj["array"], &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
obj["array"][1] = "true";
- resultType = item->validate(obj["array"], errorMessage);
+ resultType = item->validate(obj["array"], &report);
EXPECT_EQ(Errors::OK, resultType);
obj["array"][2] = "New String";
- resultType = item->validate(obj["array"], errorMessage);
+ resultType = item->validate(obj["array"], &report);
EXPECT_EQ(Errors::OK, resultType);
obj["array"][3] = "Another String";
- resultType = item->validate(obj["array"], errorMessage);
+ resultType = item->validate(obj["array"], &report);
EXPECT_EQ(Errors::OK, resultType);
obj["array"][4] = "Out of array";
- resultType = item->validate(obj["array"], errorMessage);
+ resultType = item->validate(obj["array"], &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
EXPECT_EQ(std::string("Some String"), obj["array"][0].asString());
diff --git a/src/components/smart_objects/test/BoolSchemaItem_test.cc b/src/components/smart_objects/test/BoolSchemaItem_test.cc
index dd6939443c..8d67aa59b2 100644
--- a/src/components/smart_objects/test/BoolSchemaItem_test.cc
+++ b/src/components/smart_objects/test/BoolSchemaItem_test.cc
@@ -63,15 +63,15 @@ TEST(test_no_default_value, test_BoolSchemaItemTest) {
obj = 5;
ASSERT_EQ(5, obj.asInt());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE,
resultType);
obj = true;
ASSERT_TRUE(obj.asBool());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
bool resDefault = item->setDefaultValue(obj);
EXPECT_FALSE(resDefault);
@@ -80,12 +80,12 @@ TEST(test_no_default_value, test_BoolSchemaItemTest) {
obj = "Test";
ASSERT_EQ(std::string("Test"), obj.asString());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE,
resultType);
resDefault = item->setDefaultValue(obj);
EXPECT_FALSE(resDefault);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE,
resultType);
}
@@ -110,15 +110,15 @@ TEST(test_item_with_default_value, test_BoolSchemaItemTest) {
obj = 5;
ASSERT_EQ(5, obj.asInt());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE,
resultType);
obj = true;
ASSERT_TRUE(obj.asBool());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
bool resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
@@ -127,14 +127,14 @@ TEST(test_item_with_default_value, test_BoolSchemaItemTest) {
obj = "Test";
ASSERT_EQ(std::string("Test"), obj.asString());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE,
resultType);
resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
EXPECT_FALSE(obj.asBool());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
EXPECT_FALSE(obj.asBool());
}
@@ -149,11 +149,11 @@ TEST(test_map_validate, test_BoolSchemaItemTest) {
obj["aa"] = true;
ASSERT_TRUE(obj["aa"].asBool());
- std::string errorMessage;
- int resultType = item->validate(obj["aa"], errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj["aa"], &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE,
resultType);
@@ -165,11 +165,11 @@ TEST(test_map_validate, test_BoolSchemaItemTest) {
EXPECT_TRUE(resDefault);
EXPECT_FALSE(obj.asBool());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
obj["ind"] = true;
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE,
resultType);
}
@@ -185,14 +185,14 @@ TEST(test_array_validate, test_BoolSchemaItemTest) {
ASSERT_TRUE(obj[0].asBool());
ASSERT_FALSE(obj[1].asBool());
- std::string errorMessage;
- int resultType = item->validate(obj[0], errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj[0], &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
- resultType = item->validate(obj[1], errorMessage);
+ resultType = item->validate(obj[1], &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE,
resultType);
@@ -204,13 +204,13 @@ TEST(test_array_validate, test_BoolSchemaItemTest) {
EXPECT_FALSE(resDefault);
EXPECT_FALSE(obj[1].asBool());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE,
resultType);
obj = false;
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
}
diff --git a/src/components/smart_objects/test/CObjectSchemaItem_test.cc b/src/components/smart_objects/test/CObjectSchemaItem_test.cc
index 0f6b979a16..523b25a8d8 100644
--- a/src/components/smart_objects/test/CObjectSchemaItem_test.cc
+++ b/src/components/smart_objects/test/CObjectSchemaItem_test.cc
@@ -155,9 +155,9 @@ TEST_F(ObjectSchemaItemTest, validation_correct) {
obj[S_MSG_PARAMS][Keys::INFO] = "0123456789";
obj[S_MSG_PARAMS][Keys::SUCCESS] = true;
- std::string errorMessage;
- EXPECT_EQ(Errors::OK, schema_item->validate(obj, errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::OK, schema_item->validate(obj, &report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
}
TEST_F(ObjectSchemaItemTest, validation_correct_skip_not_mandatory) {
@@ -169,9 +169,9 @@ TEST_F(ObjectSchemaItemTest, validation_correct_skip_not_mandatory) {
// skip non-mandatory obj[S_MSG_PARAMS][Keys::INFO]
obj[S_MSG_PARAMS][Keys::SUCCESS] = false;
- std::string errorMessage;
- EXPECT_EQ(Errors::OK, schema_item->validate(obj, errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::OK, schema_item->validate(obj, &report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
}
TEST_F(ObjectSchemaItemTest, validation_invalid_param) {
@@ -179,9 +179,9 @@ TEST_F(ObjectSchemaItemTest, validation_invalid_param) {
obj[S_PARAMS] = "some parameters";
obj[S_MSG_PARAMS] = "some message parameters";
- std::string errorMessage;
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
obj[S_PARAMS][S_FUNCTION_ID] = "some function";
obj[S_PARAMS][S_CORRELATION_ID] = "some correlation id";
@@ -189,35 +189,35 @@ TEST_F(ObjectSchemaItemTest, validation_invalid_param) {
obj[S_MSG_PARAMS][Keys::RESULT_CODE] = "some result";
obj[S_MSG_PARAMS][Keys::SUCCESS] = 0xABC;
- errorMessage = "";
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
obj[S_PARAMS][S_FUNCTION_ID] = 1;
- errorMessage = "";
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
obj[S_PARAMS][S_CORRELATION_ID] = -0xFF1;
- errorMessage = "";
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
obj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
- errorMessage = "";
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
obj[S_MSG_PARAMS][Keys::RESULT_CODE] = 1;
- errorMessage = "";
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
obj[S_MSG_PARAMS][Keys::SUCCESS] = false;
- errorMessage = "";
- EXPECT_EQ(Errors::OK, schema_item->validate(obj, errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::OK, schema_item->validate(obj, &report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
}
TEST_F(ObjectSchemaItemTest, validation_invalid_not_mandatory_param) {
SmartObject obj;
@@ -229,26 +229,26 @@ TEST_F(ObjectSchemaItemTest, validation_invalid_not_mandatory_param) {
// invalid non-mandatory obj[S_MSG_PARAMS][Keys::INFO]
obj[S_MSG_PARAMS][Keys::INFO] = 0x10;
- std::string errorMessage;
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
// invalid non-mandatory obj[S_MSG_PARAMS][Keys::INFO]
obj[S_MSG_PARAMS][Keys::INFO] = true;
- errorMessage = "";
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
// invalid non-mandatory obj[S_MSG_PARAMS][Keys::INFO]
obj[S_MSG_PARAMS][Keys::INFO] = SmartObject();
- errorMessage = "";
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
obj[S_MSG_PARAMS][Keys::INFO] = "info";
- errorMessage = "";
- EXPECT_EQ(Errors::OK, schema_item->validate(obj, errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::OK, schema_item->validate(obj, &report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
}
TEST_F(ObjectSchemaItemTest, validation_missing_mandatory) {
@@ -260,29 +260,29 @@ TEST_F(ObjectSchemaItemTest, validation_missing_mandatory) {
obj[S_MSG_PARAMS][Keys::INFO] = "123";
obj[S_MSG_PARAMS][Keys::SUCCESS] = false;
- std::string errorMessage;
+ rpc::ValidationReport report("RPC");
EXPECT_EQ(Errors::MISSING_MANDATORY_PARAMETER,
- schema_item->validate(obj, errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ schema_item->validate(obj, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
obj[S_PARAMS][S_FUNCTION_ID] = 2;
// S_CORRELATION_ID and S_PROTOCOL_VERSION is still missed
- errorMessage = "";
+ report = rpc::ValidationReport("RPC");
EXPECT_EQ(Errors::MISSING_MANDATORY_PARAMETER,
- schema_item->validate(obj, errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ schema_item->validate(obj, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
obj[S_PARAMS][S_CORRELATION_ID] = 0XFF2;
// S_PROTOCOL_VERSION is still missed
- errorMessage = "";
+ report = rpc::ValidationReport("RPC");
EXPECT_EQ(Errors::MISSING_MANDATORY_PARAMETER,
- schema_item->validate(obj, errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ schema_item->validate(obj, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
obj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
- errorMessage = "";
- EXPECT_EQ(Errors::OK, schema_item->validate(obj, errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::OK, schema_item->validate(obj, &report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
}
TEST_F(ObjectSchemaItemTest, validation_unexpected_param) {
@@ -300,21 +300,21 @@ TEST_F(ObjectSchemaItemTest, validation_unexpected_param) {
obj[fake1] = SmartObject(static_cast<int64_t>(0));
// any fake parameter is OK
- std::string errorMessage;
- EXPECT_EQ(Errors::OK, schema_item->validate(obj, errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::OK, schema_item->validate(obj, &report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
obj[S_PARAMS][fake2] = SmartObject("123");
// any fake parameters are OK
- errorMessage = "";
- EXPECT_EQ(Errors::OK, schema_item->validate(obj, errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::OK, schema_item->validate(obj, &report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
obj[S_MSG_PARAMS][fake3] = true;
// any fake parameters are OK
- errorMessage = "";
- EXPECT_EQ(Errors::OK, schema_item->validate(obj, errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::OK, schema_item->validate(obj, &report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
}
TEST_F(ObjectSchemaItemTest, validation_unexpected_param_remove) {
@@ -340,9 +340,9 @@ TEST_F(ObjectSchemaItemTest, validation_unexpected_param_remove) {
EXPECT_TRUE(obj.keyExists(fake1));
EXPECT_TRUE(obj[S_PARAMS].keyExists(fake2));
EXPECT_TRUE(obj[S_MSG_PARAMS].keyExists(fake3));
- std::string errorMessage;
- EXPECT_EQ(Errors::OK, schema_item->validate(obj, errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::OK, schema_item->validate(obj, &report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
// Check apply schema, remove fake parameter
schema_item->applySchema(obj, true);
@@ -355,9 +355,9 @@ TEST_F(ObjectSchemaItemTest, validation_unexpected_param_remove) {
EXPECT_TRUE(obj[S_MSG_PARAMS].keyExists(Keys::RESULT_CODE));
EXPECT_TRUE(obj[S_MSG_PARAMS].keyExists(Keys::INFO));
EXPECT_TRUE(obj[S_MSG_PARAMS].keyExists(Keys::SUCCESS));
- errorMessage = "";
- EXPECT_EQ(Errors::OK, schema_item->validate(obj, errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::OK, schema_item->validate(obj, &report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
obj[fake1] = SmartObject(static_cast<int64_t>(0));
obj[S_PARAMS][fake2] = SmartObject("123");
@@ -371,9 +371,9 @@ TEST_F(ObjectSchemaItemTest, validation_unexpected_param_remove) {
EXPECT_FALSE(obj[S_PARAMS].keyExists(fake2));
EXPECT_FALSE(obj[S_MSG_PARAMS].keyExists(fake3));
// Invalide state after enum convertion
- errorMessage = "";
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
}
TEST_F(ObjectSchemaItemTest, validation_empty_params) {
@@ -387,20 +387,20 @@ TEST_F(ObjectSchemaItemTest, validation_empty_params) {
obj[S_MSG_PARAMS]["FAKE_PARAM2"] = SmartObject(0x1);
obj[S_MSG_PARAMS]["FAKE_PARAM3"] = SmartObject("2");
- std::string errorMessage;
- EXPECT_EQ(Errors::OK, schema_item->validate(obj, errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_EQ(Errors::OK, schema_item->validate(obj, &report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
schema_item->applySchema(obj, false);
- errorMessage = "";
- EXPECT_EQ(Errors::OK, schema_item->validate(obj, errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::OK, schema_item->validate(obj, &report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
schema_item->unapplySchema(obj);
// Invalide state after enum convertion
- errorMessage = "";
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
}
TEST_F(ObjectSchemaItemTest, test_strings_to_enum_conversion) {
@@ -435,14 +435,14 @@ TEST_F(ObjectSchemaItemTest, test_strings_to_enum_conversion) {
object[S_MSG_PARAMS][Keys::RESULT_CODE] = result_type_str;
// S_FUNCTION_ID and RESULT_CODE are not converted to int
- std::string errorMessage;
- EXPECT_NE(Errors::OK, schema_item->validate(object, errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ rpc::ValidationReport report("RPC");
+ EXPECT_NE(Errors::OK, schema_item->validate(object, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
schema_item->applySchema(object, false);
- errorMessage = "";
- EXPECT_EQ(Errors::OK, schema_item->validate(object, errorMessage));
- EXPECT_EQ(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_EQ(Errors::OK, schema_item->validate(object, &report));
+ EXPECT_EQ(std::string(""), rpc::PrettyFormat(report));
// check conversion result
EXPECT_EQ(function_type, object[S_PARAMS][S_FUNCTION_ID].asInt());
@@ -450,9 +450,9 @@ TEST_F(ObjectSchemaItemTest, test_strings_to_enum_conversion) {
schema_item->unapplySchema(object);
// S_FUNCTION_ID and RESULT_CODE are string
- errorMessage = "";
- EXPECT_NE(Errors::OK, schema_item->validate(object, errorMessage));
- EXPECT_NE(std::string(""), errorMessage);
+ report = rpc::ValidationReport("RPC");
+ EXPECT_NE(Errors::OK, schema_item->validate(object, &report));
+ EXPECT_NE(std::string(""), rpc::PrettyFormat(report));
// check conversion result
EXPECT_EQ(function_str, object[S_PARAMS][S_FUNCTION_ID].asString());
diff --git a/src/components/smart_objects/test/EnumSchemaItem_test.cc b/src/components/smart_objects/test/EnumSchemaItem_test.cc
index 49a286024d..9914167e5a 100644
--- a/src/components/smart_objects/test/EnumSchemaItem_test.cc
+++ b/src/components/smart_objects/test/EnumSchemaItem_test.cc
@@ -92,8 +92,8 @@ TEST_F(EnumSchemaItemTest, test_item_with_default_value) {
// Object - valid enum
obj = TestType::BLUETOOTH_OFF;
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
bool resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
@@ -102,7 +102,7 @@ TEST_F(EnumSchemaItemTest, test_item_with_default_value) {
// Obj - bool
obj = true;
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
@@ -111,7 +111,7 @@ TEST_F(EnumSchemaItemTest, test_item_with_default_value) {
// Object - number
obj = 3.1415926;
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
resDefault = item->setDefaultValue(obj);
@@ -120,7 +120,7 @@ TEST_F(EnumSchemaItemTest, test_item_with_default_value) {
// Object - string
obj = "Some string";
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
resDefault = item->setDefaultValue(obj);
@@ -143,8 +143,8 @@ TEST_F(EnumSchemaItemTest, test_item_without_default_value) {
// Object - valid enum
obj = TestType::BLUETOOTH_OFF;
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
bool resDefault = item->setDefaultValue(obj);
EXPECT_FALSE(resDefault);
@@ -153,7 +153,7 @@ TEST_F(EnumSchemaItemTest, test_item_without_default_value) {
// Obj - bool
obj = true;
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
resDefault = item->setDefaultValue(obj);
EXPECT_FALSE(resDefault);
@@ -162,7 +162,7 @@ TEST_F(EnumSchemaItemTest, test_item_without_default_value) {
// Object - number
obj = 3.1415926;
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
resDefault = item->setDefaultValue(obj);
@@ -171,7 +171,7 @@ TEST_F(EnumSchemaItemTest, test_item_without_default_value) {
// Object - string
obj = "Some string";
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
resDefault = item->setDefaultValue(obj);
@@ -180,12 +180,12 @@ TEST_F(EnumSchemaItemTest, test_item_without_default_value) {
// Object - int in range of enum
obj = 6;
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
// Object - int out of enum range
obj = 15;
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
}
@@ -201,32 +201,32 @@ TEST_F(EnumSchemaItemTest, test_apply_unapply_schema) {
// Object - valid enum
obj = TestType::BLUETOOTH_OFF;
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
bool resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
EXPECT_EQ(TestType::FACTORY_DEFAULTS, obj.asInt());
item->unapplySchema(obj);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
EXPECT_EQ(std::string("FACTORY_DEFAULTS"), obj.asString());
item->applySchema(obj, false);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
EXPECT_EQ(TestType::FACTORY_DEFAULTS, obj.asInt());
obj = "TOO_MANY_REQUESTS";
item->applySchema(obj, false);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
EXPECT_EQ(TestType::TOO_MANY_REQUESTS, obj.asInt());
obj = "ENOUGH_REQUESTS";
item->applySchema(obj, false);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
EXPECT_EQ(std::string("ENOUGH_REQUESTS"), obj.asString());
}
diff --git a/src/components/smart_objects/test/NumberSchemaItem_test.cc b/src/components/smart_objects/test/NumberSchemaItem_test.cc
index de4de09972..0315bcedb3 100644
--- a/src/components/smart_objects/test/NumberSchemaItem_test.cc
+++ b/src/components/smart_objects/test/NumberSchemaItem_test.cc
@@ -61,21 +61,21 @@ TEST(test_int_no_default_value, test_NumberSchemaItemTest) {
obj = 5;
ASSERT_EQ(5, obj.asInt());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
// Obj bool
obj = true;
ASSERT_TRUE(obj.asBool());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
// Set default value
bool resDefault = item->setDefaultValue(obj);
EXPECT_FALSE(resDefault);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
EXPECT_TRUE(obj.asBool());
@@ -83,11 +83,11 @@ TEST(test_int_no_default_value, test_NumberSchemaItemTest) {
obj = "Test";
ASSERT_EQ(std::string("Test"), obj.asString());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
resDefault = item->setDefaultValue(obj);
EXPECT_FALSE(resDefault);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
}
@@ -106,22 +106,22 @@ TEST(test_int_min_value, test_NumberSchemaItemTest) {
obj = 15;
ASSERT_EQ(15, obj.asInt());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
// Object int incorrect
obj = 9;
ASSERT_EQ(9, obj.asInt());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
// Object int correct
obj = 10;
ASSERT_EQ(10, obj.asInt());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
}
@@ -141,22 +141,22 @@ TEST(test_int_max_value, test_NumberSchemaItemTest) {
obj = 749;
ASSERT_EQ(749, obj.asInt());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
// Object int incorrect
obj = 750;
ASSERT_EQ(750, obj.asInt());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
// Object int correct
obj = -750;
ASSERT_EQ(-750, obj.asInt());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
}
@@ -176,29 +176,29 @@ TEST(test_int_min_max_value, test_NumberSchemaItemTest) {
obj = 749;
ASSERT_EQ(749, obj.asInt());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
// Object int incorrect
obj = 750;
ASSERT_EQ(750, obj.asInt());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
// Object int correct
obj = -949;
ASSERT_EQ(-949, obj.asInt());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
// Object int incorrect
obj = -950;
ASSERT_EQ(-950, obj.asInt());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
}
@@ -219,45 +219,45 @@ TEST(test_int_correct_default_value, test_NumberSchemaItemTest) {
obj = -12000;
ASSERT_EQ(-12000, obj.asInt());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
// Object int incorrect
obj = -12001;
ASSERT_EQ(-12001, obj.asInt());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
// Object int correct
obj = 100;
ASSERT_EQ(100, obj.asInt());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
// Object int incorrect
obj = 101;
ASSERT_EQ(101, obj.asInt());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
// Set default value
bool resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
EXPECT_EQ(-38, obj.asInt());
// Object string
obj = "string";
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
EXPECT_EQ(-38, obj.asInt());
}
@@ -279,45 +279,45 @@ TEST(test_int_default_value_out_of_range, test_NumberSchemaItemTest) {
obj = 90;
ASSERT_EQ(90, obj.asInt());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
// Object int incorrect
obj = 89;
ASSERT_EQ(89, obj.asInt());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
// Object int correct
obj = 100;
ASSERT_EQ(100, obj.asInt());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
// Object int incorrect
obj = 101;
ASSERT_EQ(101, obj.asInt());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
// Set default value
bool resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
EXPECT_EQ(50, obj.asInt());
// Object string
obj = "string";
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
EXPECT_EQ(50, obj.asInt());
}
@@ -337,16 +337,16 @@ TEST(test_int_map_validate, test_NumberSchemaItemTest) {
obj["max"] = 100;
obj["out_of_max"] = 101;
- std::string errorMessage;
- int resultType = item->validate(obj["min"], errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj["min"], &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj["max"], errorMessage);
+ resultType = item->validate(obj["max"], &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj["out_of_min"], errorMessage);
+ resultType = item->validate(obj["out_of_min"], &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- resultType = item->validate(obj["out_of_max"], errorMessage);
+ resultType = item->validate(obj["out_of_max"], &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
// Set default value
@@ -358,13 +358,13 @@ TEST(test_int_map_validate, test_NumberSchemaItemTest) {
EXPECT_TRUE(resDefault);
EXPECT_EQ(-38, obj.asInt());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj["min"], errorMessage);
+ resultType = item->validate(obj["min"], &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
}
@@ -383,22 +383,22 @@ TEST(test_int_array_validate, test_NumberSchemaItemTest) {
obj[2] = 100;
obj[3] = 101;
- std::string errorMessage;
- int resultType = item->validate(obj[0], errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj[0], &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OUT_OF_RANGE,
resultType);
- resultType = item->validate(obj[1], errorMessage);
+ resultType = item->validate(obj[1], &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
- resultType = item->validate(obj[2], errorMessage);
+ resultType = item->validate(obj[2], &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
- resultType = item->validate(obj[3], errorMessage);
+ resultType = item->validate(obj[3], &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OUT_OF_RANGE,
resultType);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE,
resultType);
@@ -410,14 +410,14 @@ TEST(test_int_array_validate, test_NumberSchemaItemTest) {
EXPECT_TRUE(resDefault);
EXPECT_EQ(-38, obj.asInt());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
- resultType = item->validate(obj[0], errorMessage);
+ resultType = item->validate(obj[0], &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE,
resultType);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE,
resultType);
}
@@ -441,21 +441,21 @@ TEST(test_double_no_default_value, test_NumberSchemaItemTest) {
obj = 5.79;
ASSERT_EQ(5.79, obj.asDouble());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
// Obj bool
obj = true;
ASSERT_TRUE(obj.asBool());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
// Set default value
bool resDefault = item->setDefaultValue(obj);
EXPECT_FALSE(resDefault);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
EXPECT_TRUE(obj.asBool());
@@ -463,13 +463,13 @@ TEST(test_double_no_default_value, test_NumberSchemaItemTest) {
obj = "Test";
ASSERT_EQ(std::string("Test"), obj.asString());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
// Set default value
resDefault = item->setDefaultValue(obj);
EXPECT_FALSE(resDefault);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
}
@@ -488,22 +488,22 @@ TEST(test_double_min_value, test_NumberSchemaItemTest) {
obj = 10.000001;
ASSERT_EQ(10.000001, obj.asDouble());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
// Object double incorrect
obj = 9.999999;
ASSERT_EQ(9.999999, obj.asDouble());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
/*
//Object int
obj = 10;
ASSERT_EQ(10, obj.asInt());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);*/
}
@@ -523,22 +523,22 @@ TEST(test_double_max_value, test_NumberSchemaItemTest) {
obj = 749.0;
ASSERT_EQ(749.0, obj.asDouble());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
// Object double incorrect
obj = 749.0001;
ASSERT_EQ(749.0001, obj.asDouble());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
// Object double correct
obj = -750.0;
ASSERT_EQ(-750.0, obj.asDouble());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
}
@@ -558,29 +558,29 @@ TEST(test_double_min_max_value, test_NumberSchemaItemTest) {
obj = 749.0;
ASSERT_EQ(749.0, obj.asDouble());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
// Object double incorrect
obj = 749.001;
ASSERT_EQ(749.001, obj.asDouble());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
// Object double correct
obj = -949.0;
ASSERT_EQ(-949.0, obj.asDouble());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
// Object double incorrect
obj = -949.00001;
ASSERT_EQ(-949.00001, obj.asDouble());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
}
@@ -601,45 +601,45 @@ TEST(test_double_correct_default_value, test_NumberSchemaItemTest) {
obj = -12000.0;
ASSERT_EQ(-12000.0, obj.asDouble());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
// Object double incorrect
obj = -12000.01;
ASSERT_EQ(-12000.01, obj.asDouble());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
// Object double correct
obj = 100.0;
ASSERT_EQ(100.0, obj.asDouble());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
// Object double incorrect
obj = 100.001;
ASSERT_EQ(100.001, obj.asDouble());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
// Set default value
bool resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
EXPECT_EQ(-38.0, obj.asDouble());
// Object string
obj = "string";
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
EXPECT_EQ(-38.0, obj.asDouble());
}
@@ -661,45 +661,45 @@ TEST(test_double_default_value_out_of_range, test_NumberSchemaItemTest) {
obj = 90.0;
ASSERT_EQ(90.0, obj.asDouble());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
// Object double incorrect
obj = 89.999;
ASSERT_EQ(89.999, obj.asDouble());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
// Object double correct
obj = 100.0;
ASSERT_EQ(100.0, obj.asDouble());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
// Object double incorrect
obj = 100.001;
ASSERT_EQ(100.001, obj.asDouble());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
// Set default value
bool resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
EXPECT_EQ(50.0, obj.asDouble());
// Object string
obj = "string";
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
EXPECT_EQ(50.0, obj.asDouble());
}
@@ -719,16 +719,16 @@ TEST(test_double_map_validate, test_NumberSchemaItemTest) {
obj["max"] = 100.0;
obj["out_of_max"] = 100.001;
- std::string errorMessage;
- int resultType = item->validate(obj["min"], errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj["min"], &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj["max"], errorMessage);
+ resultType = item->validate(obj["max"], &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj["out_of_min"], errorMessage);
+ resultType = item->validate(obj["out_of_min"], &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- resultType = item->validate(obj["out_of_max"], errorMessage);
+ resultType = item->validate(obj["out_of_max"], &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
bool resDefault = item->setDefaultValue(obj["aa"]);
@@ -739,13 +739,13 @@ TEST(test_double_map_validate, test_NumberSchemaItemTest) {
EXPECT_TRUE(resDefault);
EXPECT_EQ(-38.0, obj.asDouble());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj["min"], errorMessage);
+ resultType = item->validate(obj["min"], &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
}
@@ -764,22 +764,22 @@ TEST(test_double_array_validate, test_NumberSchemaItemTest) {
obj[2] = 100.0;
obj[3] = 100.000001;
- std::string errorMessage;
- int resultType = item->validate(obj[0], errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj[0], &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OUT_OF_RANGE,
resultType);
- resultType = item->validate(obj[1], errorMessage);
+ resultType = item->validate(obj[1], &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
- resultType = item->validate(obj[2], errorMessage);
+ resultType = item->validate(obj[2], &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
- resultType = item->validate(obj[3], errorMessage);
+ resultType = item->validate(obj[3], &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OUT_OF_RANGE,
resultType);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE,
resultType);
@@ -791,14 +791,14 @@ TEST(test_double_array_validate, test_NumberSchemaItemTest) {
EXPECT_TRUE(resDefault);
EXPECT_EQ(-38.0, obj.asDouble());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
- resultType = item->validate(obj[0], errorMessage);
+ resultType = item->validate(obj[0], &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE,
resultType);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE,
resultType);
}
@@ -815,8 +815,8 @@ TEST(test_int_double_value, test_NumberSchemaItemTest) {
obj = value;
ASSERT_EQ(value, obj.asDouble());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
}
@@ -832,8 +832,8 @@ TEST(test_double_int_value, test_NumberSchemaItemTest) {
obj = value;
ASSERT_EQ(value, obj.asInt());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
}
diff --git a/src/components/smart_objects/test/StringSchemaItem_test.cc b/src/components/smart_objects/test/StringSchemaItem_test.cc
index 915231f357..4e4688d354 100644
--- a/src/components/smart_objects/test/StringSchemaItem_test.cc
+++ b/src/components/smart_objects/test/StringSchemaItem_test.cc
@@ -59,8 +59,8 @@ TEST(test_no_default_value, test_StringSchemaItemTest) {
obj = "New valid string";
ASSERT_EQ(std::string("New valid string"), obj.asString());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
bool resDefault = item->setDefaultValue(obj);
EXPECT_FALSE(resDefault);
@@ -69,7 +69,7 @@ TEST(test_no_default_value, test_StringSchemaItemTest) {
// Obj - bool
obj = true;
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
resDefault = item->setDefaultValue(obj);
EXPECT_FALSE(resDefault);
@@ -78,12 +78,12 @@ TEST(test_no_default_value, test_StringSchemaItemTest) {
// Object - number
obj = 3.1415926;
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
resDefault = item->setDefaultValue(obj);
EXPECT_FALSE(resDefault);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
EXPECT_EQ(3.1415926, obj.asDouble());
}
@@ -111,8 +111,8 @@ TEST(test_item_with_default_value, test_StringSchemaItemTest) {
obj = "New valid string";
ASSERT_EQ(std::string("New valid string"), obj.asString());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
bool resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
@@ -121,7 +121,7 @@ TEST(test_item_with_default_value, test_StringSchemaItemTest) {
// Obj - bool
obj = true;
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
@@ -130,12 +130,12 @@ TEST(test_item_with_default_value, test_StringSchemaItemTest) {
// Object - number
obj = 3.1415926;
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
EXPECT_EQ(std::string("Default string"), obj.asString());
}
@@ -156,8 +156,8 @@ TEST(test_item_with_max_length, test_StringSchemaItemTest) {
obj = "New valid string";
ASSERT_EQ(std::string("New valid string"), obj.asString());
- std::string errorMessage;
- int resultType = item->validate(obj, errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
bool resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
@@ -167,13 +167,13 @@ TEST(test_item_with_max_length, test_StringSchemaItemTest) {
obj = "New very very loooooong string";
ASSERT_EQ(std::string("New very very loooooong string"), obj.asString());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
EXPECT_EQ(std::string("Default string"), obj.asString());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
}
@@ -191,20 +191,20 @@ TEST(test_map_validate, test_StringSchemaItemTest) {
obj["bool"] = true;
obj["num"] = 3.14;
- std::string errorMessage;
- int resultType = item->validate(obj["str"], errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj["str"], &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj["long"], errorMessage);
+ resultType = item->validate(obj["long"], &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- resultType = item->validate(obj["bool"], errorMessage);
+ resultType = item->validate(obj["bool"], &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj["num"], errorMessage);
+ resultType = item->validate(obj["num"], &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
bool resDefault = item->setDefaultValue(obj["str"]);
@@ -219,23 +219,23 @@ TEST(test_map_validate, test_StringSchemaItemTest) {
EXPECT_TRUE(resDefault);
EXPECT_EQ(std::string("Default string"), obj["num"].asString());
- resultType = item->validate(obj["str"], errorMessage);
+ resultType = item->validate(obj["str"], &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj["long"], errorMessage);
+ resultType = item->validate(obj["long"], &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- resultType = item->validate(obj["bool"], errorMessage);
+ resultType = item->validate(obj["bool"], &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj["num"], errorMessage);
+ resultType = item->validate(obj["num"], &report);
EXPECT_EQ(Errors::OK, resultType);
resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
EXPECT_EQ(std::string("Default string"), obj.asString());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
}
@@ -254,23 +254,23 @@ TEST(test_array_validate, test_StringSchemaItemTest) {
obj[3] = 3.14;
obj[4] = "New valid string";
- std::string errorMessage;
- int resultType = item->validate(obj[0], errorMessage);
+ rpc::ValidationReport report("RPC");
+ int resultType = item->validate(obj[0], &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj[1], errorMessage);
+ resultType = item->validate(obj[1], &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- resultType = item->validate(obj[2], errorMessage);
+ resultType = item->validate(obj[2], &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[3], errorMessage);
+ resultType = item->validate(obj[3], &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[4], errorMessage);
+ resultType = item->validate(obj[4], &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
bool resDefault = item->setDefaultValue(obj[0]);
@@ -289,24 +289,24 @@ TEST(test_array_validate, test_StringSchemaItemTest) {
EXPECT_EQ(std::string("Default string"), obj[4].asString());
EXPECT_EQ(std::string("Default string"), obj[5].asString());
- resultType = item->validate(obj[0], errorMessage);
+ resultType = item->validate(obj[0], &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj[1], errorMessage);
+ resultType = item->validate(obj[1], &report);
EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- resultType = item->validate(obj[2], errorMessage);
+ resultType = item->validate(obj[2], &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj[3], errorMessage);
+ resultType = item->validate(obj[3], &report);
EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[4], errorMessage);
+ resultType = item->validate(obj[4], &report);
EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj[5], errorMessage);
+ resultType = item->validate(obj[5], &report);
EXPECT_EQ(Errors::OK, resultType);
resDefault = item->setDefaultValue(obj);
EXPECT_TRUE(resDefault);
EXPECT_EQ(std::string("Default string"), obj.asString());
- resultType = item->validate(obj, errorMessage);
+ resultType = item->validate(obj, &report);
EXPECT_EQ(Errors::OK, resultType);
}
diff --git a/tools/intergen/test/generated_interface_json_tests.cc b/tools/intergen/test/generated_interface_json_tests.cc
index 995ff17e8b..ee1db2167b 100644
--- a/tools/intergen/test/generated_interface_json_tests.cc
+++ b/tools/intergen/test/generated_interface_json_tests.cc
@@ -545,7 +545,7 @@ TEST_F(GeneratedInterfaceTests, ReportIncorrectlyInitializedMap1) {
ASSERT_FALSE(smim.is_valid());
rpc::ValidationReport report("smim");
smim.ReportErrors(&report);
- ASSERT_EQ("smim.mandatoryIntMap: object is not initialized\n", PrettyFormat(report));
+ ASSERT_EQ("smim.mandatoryIntMap: object is not initialized", PrettyFormat(report));
}
TEST_F(GeneratedInterfaceTests, ReportIncorrectlyInitializedMap2) {
@@ -556,7 +556,7 @@ TEST_F(GeneratedInterfaceTests, ReportIncorrectlyInitializedMap2) {
ASSERT_EQ("c: object is not initialized\n"
"c.choiceID: value is not initialized\n"
"c.menuName: value is not initialized\n"
- "c.vrCommands: object is not initialized\n", PrettyFormat(report));
+ "c.vrCommands: object is not initialized", PrettyFormat(report));
}
TEST_F(GeneratedInterfaceTests, TestFrankenstructCreation) {
@@ -621,7 +621,7 @@ TEST_F(GeneratedInterfaceTests, FrankenstructFromInvalidJson) {
ASSERT_EQ(2, fbmi.mandatoryInt);
rpc::ValidationReport report("fbmi");
fbmi.ReportErrors(&report);
- ASSERT_EQ("fbmi[\"hello\"]: value initialized incorrectly\n", PrettyFormat(report));
+ ASSERT_EQ("fbmi[\"hello\"]: value initialized incorrectly", PrettyFormat(report));
}
} // namespace test