From 2ce08e1d84c16e62af6914d4bb750586dc80058a Mon Sep 17 00:00:00 2001 From: Lewis Cheng Date: Thu, 19 Mar 2015 10:33:08 +0800 Subject: [PATCH] Fix GitHub Issue #2 --- include/odata/edm/edm_operation_import.h | 5 +++++ src/edm/edm_model_utility.cpp | 2 +- .../edm_test/edm_model_utility_test.cpp | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/include/odata/edm/edm_operation_import.h b/include/odata/edm/edm_operation_import.h index d4935bc..67956c5 100644 --- a/include/odata/edm/edm_operation_import.h +++ b/include/odata/edm/edm_operation_import.h @@ -40,6 +40,11 @@ class edm_operation_import return m_name; } + const ::odata::utility::string_t get_operation_name() const + { + return m_operation_name; + } + const std::shared_ptr get_operation_type() const { return m_operation_type; diff --git a/src/edm/edm_model_utility.cpp b/src/edm/edm_model_utility.cpp index b91d6d2..6296278 100644 --- a/src/edm/edm_model_utility.cpp +++ b/src/edm/edm_model_utility.cpp @@ -459,7 +459,7 @@ void edm_model_utility::resolve_type_under_entity_container(const std::shared_pt auto op = operation_import_iter->second; if (op) { - ::odata::utility::string_t operation_name = op->get_name(); + ::odata::utility::string_t operation_name = op->get_operation_name(); op->set_operation_type(model->find_operation_type(operation_name)); } } diff --git a/tests/functional/edm_test/edm_model_utility_test.cpp b/tests/functional/edm_test/edm_model_utility_test.cpp index 68a5e3d..d19cad2 100644 --- a/tests/functional/edm_test/edm_model_utility_test.cpp +++ b/tests/functional/edm_test/edm_model_utility_test.cpp @@ -211,6 +211,24 @@ TEST(resolve_edm_types_after_parsing_type_in_operation) VERIFY_ARE_EQUAL(verify_param->get_param_type()->get_type_kind(), edm_type_kind_t::Complex); } +TEST(resolve_correct_operation_after_parsing_type_in_operation_import) +{ + ::odata::utility::string_t name_space = U("odata.functional.test"); + auto model = std::make_shared(); + auto schema = model->add_schema(U("schema"), name_space); + std::shared_ptr operation; + operation.reset(new edm_operation_type(U("operation"), name_space, false, U(""), EdmOperationKind::Function, false)); + schema->add_operation_type(operation); + std::shared_ptr operation_import; + operation_import.reset(new edm_operation_import(U("operation_import"), U("operation"), U("dummy"), true, OperationImportKind::FunctionImport)); + std::shared_ptr container; + container.reset(new edm_entity_container(U("container"), true)); + container->add_operation_import(operation_import); + schema->add_container(container); + edm_model_utility::resolve_edm_types_after_parsing(model); + VERIFY_ARE_EQUAL(operation, operation_import->get_operation_type()); +} + } }}} \ No newline at end of file