diff options
author | Andrei Pavel <andrei@isc.org> | 2022-11-08 09:20:06 +0100 |
---|---|---|
committer | Razvan Becheriu <razvan@isc.org> | 2022-11-25 17:15:33 +0100 |
commit | 9c62adc690dc561c81e066a1ef19a5ccd5637029 (patch) | |
tree | b35c06201dd972faaee05eacace6e9e48619b467 /src | |
parent | [#2601] make Translator aware of all leaf base types (diff) | |
download | kea-9c62adc690dc561c81e066a1ef19a5ccd5637029.tar.xz kea-9c62adc690dc561c81e066a1ef19a5ccd5637029.zip |
[#2601] remove schema node checking from translator
Diffstat (limited to 'src')
73 files changed, 679 insertions, 600 deletions
diff --git a/src/bin/netconf/control_socket.h b/src/bin/netconf/control_socket.h index 50192a3523..5c9b05e4d5 100644 --- a/src/bin/netconf/control_socket.h +++ b/src/bin/netconf/control_socket.h @@ -126,4 +126,4 @@ controlSocketFactory(CfgControlSocketPtr ctrl_sock); } // namespace netconf } // namespace isc -#endif // CONTROL_SOCKET_H +#endif // CONTROL_SOCKET_H diff --git a/src/bin/netconf/http_control_socket.h b/src/bin/netconf/http_control_socket.h index 86f62cda61..b63022c7e0 100644 --- a/src/bin/netconf/http_control_socket.h +++ b/src/bin/netconf/http_control_socket.h @@ -85,4 +85,4 @@ createControlSocket<CfgControlSocket::Type::HTTP>(CfgControlSocketPtr ctrl_sock) } // namespace netconf } // namespace isc -#endif // HTTP_CONTROL_SOCKET_H +#endif // HTTP_CONTROL_SOCKET_H diff --git a/src/bin/netconf/main.cc b/src/bin/netconf/main.cc index 4abb4414db..a6ac2a14af 100644 --- a/src/bin/netconf/main.cc +++ b/src/bin/netconf/main.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/bin/netconf/netconf.h b/src/bin/netconf/netconf.h index 54ee61adb6..bb37ea5308 100644 --- a/src/bin/netconf/netconf.h +++ b/src/bin/netconf/netconf.h @@ -177,4 +177,4 @@ protected: } // namespace netconf } // namespace isc -#endif // NETCONF_H +#endif // NETCONF_H diff --git a/src/bin/netconf/netconf_cfg_mgr.h b/src/bin/netconf/netconf_cfg_mgr.h index a8d37f53fe..c7568d4094 100644 --- a/src/bin/netconf/netconf_cfg_mgr.h +++ b/src/bin/netconf/netconf_cfg_mgr.h @@ -181,4 +181,4 @@ using NetconfCfgMgrPtr = boost::shared_ptr<NetconfCfgMgr>; } // namespace netconf } // namespace isc -#endif // NETCONF_CFG_MGR_H +#endif // NETCONF_CFG_MGR_H diff --git a/src/bin/netconf/netconf_config.h b/src/bin/netconf/netconf_config.h index 3f7a40d01a..8671c07503 100644 --- a/src/bin/netconf/netconf_config.h +++ b/src/bin/netconf/netconf_config.h @@ -325,4 +325,4 @@ public: } // namespace netconf } // namespace isc -#endif // NETCONF_CONFIG_H +#endif // NETCONF_CONFIG_H diff --git a/src/bin/netconf/netconf_controller.h b/src/bin/netconf/netconf_controller.h index 97207fe858..02d4f3f776 100644 --- a/src/bin/netconf/netconf_controller.h +++ b/src/bin/netconf/netconf_controller.h @@ -82,4 +82,4 @@ using NetconfControllerPtr = std::shared_ptr<NetconfController>; } // namespace netconf } // namespace isc -#endif // NETCONF_CONTROLLER_H +#endif // NETCONF_CONTROLLER_H diff --git a/src/bin/netconf/netconf_log.h b/src/bin/netconf/netconf_log.h index 6d36e3f466..69619f5850 100644 --- a/src/bin/netconf/netconf_log.h +++ b/src/bin/netconf/netconf_log.h @@ -51,4 +51,4 @@ extern isc::log::Logger netconf_logger; } // namespace netconf } // namespace isc -#endif // NETCONF_LOG_H +#endif // NETCONF_LOG_H diff --git a/src/bin/netconf/netconf_messages.mes b/src/bin/netconf/netconf_messages.mes index 178e1a2432..18b9a58e51 100644 --- a/src/bin/netconf/netconf_messages.mes +++ b/src/bin/netconf/netconf_messages.mes @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2021 Internet Systems Consortium, Inc. ("ISC") +# Copyright (C) 2012-2022 Internet Systems Consortium, Inc. ("ISC") # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/bin/netconf/netconf_parser.yy b/src/bin/netconf/netconf_parser.yy index 1bfe87e52d..8aefcb9f70 100644 --- a/src/bin/netconf/netconf_parser.yy +++ b/src/bin/netconf/netconf_parser.yy @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +/* Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/bin/netconf/netconf_process.h b/src/bin/netconf/netconf_process.h index ccc768ea91..302f33c1a9 100644 --- a/src/bin/netconf/netconf_process.h +++ b/src/bin/netconf/netconf_process.h @@ -103,4 +103,4 @@ using NetconfProcessPtr = boost::shared_ptr<NetconfProcess>; } // namespace netconf } // namespace isc -#endif // NETCONF_PROCESS_H +#endif // NETCONF_PROCESS_H diff --git a/src/bin/netconf/parser_context.cc b/src/bin/netconf/parser_context.cc index f52675f8e5..d0e20fc111 100644 --- a/src/bin/netconf/parser_context.cc +++ b/src/bin/netconf/parser_context.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/bin/netconf/simple_parser.cc b/src/bin/netconf/simple_parser.cc index 791ce5d459..37e28717e4 100644 --- a/src/bin/netconf/simple_parser.cc +++ b/src/bin/netconf/simple_parser.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/bin/netconf/stdout_control_socket.h b/src/bin/netconf/stdout_control_socket.h index a241a9ed5d..79a8a45fad 100644 --- a/src/bin/netconf/stdout_control_socket.h +++ b/src/bin/netconf/stdout_control_socket.h @@ -86,4 +86,4 @@ createControlSocket<CfgControlSocket::Type::STDOUT>(CfgControlSocketPtr ctrl_soc } // namespace netconf } // namespace isc -#endif // STDOUT_CONTROL_SOCKET_H +#endif // STDOUT_CONTROL_SOCKET_H diff --git a/src/bin/netconf/tests/basic_library.cc b/src/bin/netconf/tests/basic_library.cc index cd0be6896a..0838586611 100644 --- a/src/bin/netconf/tests/basic_library.cc +++ b/src/bin/netconf/tests/basic_library.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/bin/netconf/tests/run_unittests.cc b/src/bin/netconf/tests/run_unittests.cc index 0065ec6519..15391d2f7d 100644 --- a/src/bin/netconf/tests/run_unittests.cc +++ b/src/bin/netconf/tests/run_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/bin/netconf/tests/test_libraries.h.in b/src/bin/netconf/tests/test_libraries.h.in index f402b1c3bd..2bf269aedd 100644 --- a/src/bin/netconf/tests/test_libraries.h.in +++ b/src/bin/netconf/tests/test_libraries.h.in @@ -21,4 +21,4 @@ static const char* BASIC_CALLOUT_LIBRARY = "@abs_builddir@/.libs/libbasic.so"; } // anonymous namespace -#endif // TEST_LIBRARIES_H +#endif // TEST_LIBRARIES_H diff --git a/src/bin/netconf/unix_control_socket.h b/src/bin/netconf/unix_control_socket.h index 1595ddba8d..a05c5091e5 100644 --- a/src/bin/netconf/unix_control_socket.h +++ b/src/bin/netconf/unix_control_socket.h @@ -85,4 +85,4 @@ createControlSocket<CfgControlSocket::Type::UNIX>(CfgControlSocketPtr ctrl_sock) } // namespace netconf } // namespace isc -#endif // UNIX_CONTROL_SOCKET_H +#endif // UNIX_CONTROL_SOCKET_H diff --git a/src/lib/yang/adaptor.h b/src/lib/yang/adaptor.h index 1018847282..d4909fbd32 100644 --- a/src/lib/yang/adaptor.h +++ b/src/lib/yang/adaptor.h @@ -118,4 +118,4 @@ public: } // namespace yang } // namespace isc -#endif // ISC_ADAPTOR_H +#endif // ISC_ADAPTOR_H diff --git a/src/lib/yang/adaptor_config.h b/src/lib/yang/adaptor_config.h index 6f644a3c60..459ea9ac20 100644 --- a/src/lib/yang/adaptor_config.h +++ b/src/lib/yang/adaptor_config.h @@ -281,4 +281,4 @@ protected: } //namespace yang } // namespace isc -#endif // ISC_ADAPTOR_CONFIG_H +#endif // ISC_ADAPTOR_CONFIG_H diff --git a/src/lib/yang/adaptor_host.h b/src/lib/yang/adaptor_host.h index bc9aff4952..bbd96642b2 100644 --- a/src/lib/yang/adaptor_host.h +++ b/src/lib/yang/adaptor_host.h @@ -41,4 +41,4 @@ public: } //namespace yang } // namespace isc -#endif // ISC_ADAPTOR_HOST_H +#endif // ISC_ADAPTOR_HOST_H diff --git a/src/lib/yang/adaptor_option.h b/src/lib/yang/adaptor_option.h index a07fe7836e..1dedf19873 100644 --- a/src/lib/yang/adaptor_option.h +++ b/src/lib/yang/adaptor_option.h @@ -99,4 +99,4 @@ protected: } //namespace yang } // namespace isc -#endif // ISC_ADAPTOR_OPTION_H +#endif // ISC_ADAPTOR_OPTION_H diff --git a/src/lib/yang/adaptor_pool.h b/src/lib/yang/adaptor_pool.h index f1262be628..b82458bc3a 100644 --- a/src/lib/yang/adaptor_pool.h +++ b/src/lib/yang/adaptor_pool.h @@ -90,4 +90,4 @@ protected: } // namespace yang } // namespace isc -#endif // ISC_ADAPTOR_POOL_H +#endif // ISC_ADAPTOR_POOL_H diff --git a/src/lib/yang/adaptor_subnet.h b/src/lib/yang/adaptor_subnet.h index 270792f2a7..214708e541 100644 --- a/src/lib/yang/adaptor_subnet.h +++ b/src/lib/yang/adaptor_subnet.h @@ -60,4 +60,4 @@ public: } // namespace yang } // namespace isc -#endif // ISC_ADAPTOR_SUBNET_H +#endif // ISC_ADAPTOR_SUBNET_H diff --git a/src/lib/yang/netconf_error.h b/src/lib/yang/netconf_error.h index 6cf4796289..17aed1be6c 100644 --- a/src/lib/yang/netconf_error.h +++ b/src/lib/yang/netconf_error.h @@ -36,4 +36,4 @@ struct NetconfError : public Exception { } // namespace yang } // namespace isc -#endif // ISC_SYSREPO_ERROR_H +#endif // ISC_SYSREPO_ERROR_H diff --git a/src/lib/yang/tests/json_configs.h b/src/lib/yang/tests/json_configs.h index 1f7e4a40e7..f580865d27 100644 --- a/src/lib/yang/tests/json_configs.h +++ b/src/lib/yang/tests/json_configs.h @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -171,4 +171,4 @@ const std::string designExampleJson = } // namespace yang } // namespace isc -#endif // ISC_JSON_CONFIGS_H +#endif // ISC_JSON_CONFIGS_H diff --git a/src/lib/yang/tests/run_unittests.cc b/src/lib/yang/tests/run_unittests.cc index dee9346bda..24870d1f9a 100644 --- a/src/lib/yang/tests/run_unittests.cc +++ b/src/lib/yang/tests/run_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/lib/yang/tests/sysrepo_setup.h b/src/lib/yang/tests/sysrepo_setup.h index c46fad57da..4e315dd402 100644 --- a/src/lib/yang/tests/sysrepo_setup.h +++ b/src/lib/yang/tests/sysrepo_setup.h @@ -63,13 +63,13 @@ public: SysrepoSetup::cleanSharedMemory(); sess_ = sysrepo::Connection{}.sessionStart(); sess_->switchDatastore(sysrepo::Datastore::Candidate); - t_obj_.reset(new translator_t(*sess_, model_)); + translator_.reset(new translator_t(*sess_, model_)); cleanModelData(); } void TearDown() override { cleanModelData(); - t_obj_.reset(); + translator_.reset(); SysrepoSetup::cleanSharedMemory(); } @@ -78,14 +78,14 @@ public: if (model_ == IETF_DHCPV6_SERVER) { toplevel_node = "server"; } - t_obj_->deleteItem("/" + model_ + ":" + toplevel_node); + translator_->deleteItem("/" + model_ + ":" + toplevel_node); } /// @brief Sysrepo session. std::optional<sysrepo::Session> sess_; /// @brief Shared pointer to the transaction object. - std::shared_ptr<translator_t> t_obj_; + std::shared_ptr<translator_t> translator_; std::string model_; }; // GenericTranslatorTest @@ -93,4 +93,4 @@ public: } // namespace yang } // namespace isc -#endif // SYSREPO_SETUP_H +#endif // SYSREPO_SETUP_H diff --git a/src/lib/yang/tests/translator_class_unittests.cc b/src/lib/yang/tests/translator_class_unittests.cc index f38b39c4f7..02405c5313 100644 --- a/src/lib/yang/tests/translator_class_unittests.cc +++ b/src/lib/yang/tests/translator_class_unittests.cc @@ -51,7 +51,7 @@ TEST_F(TranslatorClassesTestv4, getEmpty) { // Get the client class list and check if it is empty. const string& xpath = "/kea-dhcp4-server:config"; ConstElementPtr classes; - EXPECT_NO_THROW_LOG(classes = t_obj_->getClassesFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(classes = translator_->getClassesFromAbsoluteXpath(xpath)); EXPECT_FALSE(classes); } @@ -68,16 +68,16 @@ TEST_F(TranslatorClassesTestv6, get) { // Get the client class. ConstElementPtr cclass; - EXPECT_NO_THROW_LOG(cclass = t_obj_->getClassFromAbsoluteXpath(xclass)); + EXPECT_NO_THROW_LOG(cclass = translator_->getClassFromAbsoluteXpath(xclass)); ASSERT_TRUE(cclass); ElementPtr expected = Element::createMap(); - expected->set("name", Element::create(string("foo"))); - expected->set("test", Element::create(string("not member('ALL')"))); + expected->set("name", Element::create("foo")); + expected->set("test", Element::create("not member('ALL')")); EXPECT_TRUE(expected->equals(*cclass)); // Get the client class list and check if the client class is in it. ConstElementPtr classes; - EXPECT_NO_THROW_LOG(classes = t_obj_->getClassesFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(classes = translator_->getClassesFromAbsoluteXpath(xpath)); ASSERT_TRUE(classes); ASSERT_EQ(Element::list, classes->getType()); ASSERT_EQ(1, classes->size()); @@ -90,11 +90,11 @@ TEST_F(TranslatorClassesTestv4, setEmpty) { // Set empty list. const string& xpath = "/kea-dhcp4-server:config"; ConstElementPtr classes = Element::createList(); - EXPECT_NO_THROW_LOG(t_obj_->setClasses(xpath, classes)); + EXPECT_NO_THROW_LOG(translator_->setClasses(xpath, classes)); // Get it back. classes.reset(); - EXPECT_NO_THROW_LOG(classes = t_obj_->getClassesFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(classes = translator_->getClassesFromAbsoluteXpath(xpath)); EXPECT_FALSE(classes); } @@ -105,15 +105,15 @@ TEST_F(TranslatorClassesTestv6, set) { const string& xpath = "/kea-dhcp6-server:config"; ElementPtr classes = Element::createList(); ElementPtr cclass = Element::createMap(); - cclass->set("name", Element::create(string("foo"))); - cclass->set("test", Element::create(string("''==''"))); + cclass->set("name", Element::create("foo")); + cclass->set("test", Element::create("''==''")); cclass->set("only-if-required", Element::create(false)); classes->add(cclass); - EXPECT_NO_THROW_LOG(t_obj_->setClasses(xpath, classes)); + EXPECT_NO_THROW_LOG(translator_->setClasses(xpath, classes)); // Get it back. ConstElementPtr got; - EXPECT_NO_THROW_LOG(got = t_obj_->getClassesFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(got = translator_->getClassesFromAbsoluteXpath(xpath)); ASSERT_TRUE(got); ASSERT_EQ(Element::list, got->getType()); ASSERT_EQ(1, got->size()); diff --git a/src/lib/yang/tests/translator_control_socket_unittests.cc b/src/lib/yang/tests/translator_control_socket_unittests.cc index 5f10a920d8..8390004158 100644 --- a/src/lib/yang/tests/translator_control_socket_unittests.cc +++ b/src/lib/yang/tests/translator_control_socket_unittests.cc @@ -65,7 +65,7 @@ TEST_F(TranslatorControlSocketTestv4, getEmpty) { // Get empty. const string& xpath = "/kea-dhcp4-server:config/control-socket"; ConstElementPtr sock; - EXPECT_NO_THROW_LOG(sock = t_obj_->getControlSocketFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(sock = translator_->getControlSocketFromAbsoluteXpath(xpath)); EXPECT_FALSE(sock); } @@ -87,7 +87,7 @@ TEST_F(TranslatorControlSocketTestv6, get) { // Get it. ConstElementPtr sock; - EXPECT_NO_THROW_LOG(sock = t_obj_->getControlSocketFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(sock = translator_->getControlSocketFromAbsoluteXpath(xpath)); ASSERT_TRUE(sock); ASSERT_EQ(Element::map, sock->getType()); EXPECT_EQ(3, sock->size()); @@ -111,19 +111,19 @@ TEST_F(TranslatorControlSocketTestCtrlAgent, set) { const string& xpath = "/kea-ctrl-agent:config/control-sockets/socket[server-type='dhcp4']/control-socket"; ElementPtr sock = Element::createMap(); - sock->set("socket-name", Element::create(string("/tmp/kea.sock"))); - sock->set("socket-type", Element::create(string("unix"))); - sock->set("comment", Element::create(string("a comment"))); + sock->set("socket-name", Element::create("/tmp/kea.sock")); + sock->set("socket-type", Element::create("unix")); + sock->set("comment", Element::create("a comment")); try { - t_obj_->setControlSocket(xpath, sock); + translator_->setControlSocket(xpath, sock); } catch (const std::exception& ex) { cerr << "setControlSocket fail with " << ex.what() << endl; } - ASSERT_NO_THROW_LOG(t_obj_->setControlSocket(xpath, sock)); + ASSERT_NO_THROW_LOG(translator_->setControlSocket(xpath, sock)); // Get it back. ConstElementPtr got; - EXPECT_NO_THROW_LOG(got = t_obj_->getControlSocketFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(got = translator_->getControlSocketFromAbsoluteXpath(xpath)); ASSERT_TRUE(got); ASSERT_EQ(Element::map, got->getType()); EXPECT_EQ(3, got->size()); @@ -158,16 +158,16 @@ TEST_F(TranslatorControlSocketTestv4, setEmpty) { // Get it back. ConstElementPtr sock; - EXPECT_NO_THROW_LOG(sock = t_obj_->getControlSocketFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(sock = translator_->getControlSocketFromAbsoluteXpath(xpath)); ASSERT_TRUE(sock); EXPECT_EQ(sock->str(), R"({ "socket-name": "/tmp/kea.sock", "socket-type": "unix", "user-context": { "foo": 1 } })"); // Reset to empty. - EXPECT_NO_THROW_LOG(t_obj_->setControlSocket(xpath, ConstElementPtr())); + EXPECT_NO_THROW_LOG(translator_->setControlSocket(xpath, ConstElementPtr())); // Get it back. - EXPECT_NO_THROW_LOG(sock = t_obj_->getControlSocketFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(sock = translator_->getControlSocketFromAbsoluteXpath(xpath)); EXPECT_FALSE(sock); } diff --git a/src/lib/yang/tests/translator_database_unittests.cc b/src/lib/yang/tests/translator_database_unittests.cc index ccd22f9de3..4203bcb56d 100644 --- a/src/lib/yang/tests/translator_database_unittests.cc +++ b/src/lib/yang/tests/translator_database_unittests.cc @@ -51,7 +51,7 @@ TEST_F(TranslatorDatabaseTestv4, getEmpty) { // Get empty. const string& xpath = "/kea-dhcp4-server:config/lease-database"; ConstElementPtr database; - EXPECT_NO_THROW_LOG(database = t_obj_->getDatabaseFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(database = translator_->getDatabaseFromAbsoluteXpath(xpath)); EXPECT_FALSE(database); } @@ -71,7 +71,7 @@ TEST_F(TranslatorDatabaseTestv4, get) { // Get empty. ConstElementPtr database; - EXPECT_NO_THROW_LOG(database = t_obj_->getDatabaseFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(database = translator_->getDatabaseFromAbsoluteXpath(xpath)); ASSERT_TRUE(database); EXPECT_EQ(2, database->size()); ConstElementPtr type = database->get("type"); @@ -90,13 +90,13 @@ TEST_F(TranslatorDatabaseTestv4, set) { // Set a value. const string& xpath = "/kea-dhcp4-server:config/lease-database"; ElementPtr database = Element::createMap(); - database->set("type", Element::create(string("memfile"))); + database->set("type", Element::create("memfile")); database->set("lfc-interval", Element::create(3600)); - ASSERT_NO_THROW_LOG(t_obj_->setDatabase(xpath, database)); + ASSERT_NO_THROW_LOG(translator_->setDatabase(xpath, database)); // Get it back. ConstElementPtr got; - EXPECT_NO_THROW_LOG(got = t_obj_->getDatabaseFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(got = translator_->getDatabaseFromAbsoluteXpath(xpath)); ASSERT_TRUE(got); ASSERT_EQ(Element::map, got->getType()); EXPECT_EQ(2, got->size()); @@ -125,11 +125,11 @@ TEST_F(TranslatorDatabaseTestv4, setEmpty) { sess_->applyChanges(); // Reset to empty. - ASSERT_NO_THROW_LOG(t_obj_->setDatabase(xpath, ConstElementPtr())); + ASSERT_NO_THROW_LOG(translator_->setDatabase(xpath, ConstElementPtr())); // Get it back. ConstElementPtr database; - EXPECT_NO_THROW_LOG(database = t_obj_->getDatabaseFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(database = translator_->getDatabaseFromAbsoluteXpath(xpath)); EXPECT_FALSE(database); } @@ -161,7 +161,7 @@ TEST_F(TranslatorDatabasesTestv6, getEmpty) { // Get empty. const string& xpath = "/kea-dhcp6-server:config/hosts-database"; ConstElementPtr databases; - EXPECT_NO_THROW_LOG(databases = t_obj_->getDatabasesFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(databases = translator_->getDatabasesFromAbsoluteXpath(xpath)); EXPECT_FALSE(databases); } @@ -191,7 +191,7 @@ TEST_F(TranslatorDatabasesTestv4, get) { // Get empty. ConstElementPtr databases; - EXPECT_NO_THROW_LOG(databases = t_obj_->getDatabasesFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(databases = translator_->getDatabasesFromAbsoluteXpath(xpath)); ASSERT_TRUE(databases); ASSERT_EQ(1, databases->size()); ConstElementPtr database = databases->get(0); @@ -229,15 +229,15 @@ TEST_F(TranslatorDatabasesTestv6, set) { // Set a value. const string& xpath = "/kea-dhcp6-server:config/hosts-database"; ElementPtr database = Element::createMap(); - database->set("type", Element::create(string("memfile"))); + database->set("type", Element::create("memfile")); database->set("lfc-interval", Element::create(3600)); ElementPtr databases = Element::createList(); databases->add(database); - ASSERT_NO_THROW_LOG(t_obj_->setDatabases(xpath, databases)); + ASSERT_NO_THROW_LOG(translator_->setDatabases(xpath, databases)); // Get it back. ConstElementPtr gots; - EXPECT_NO_THROW_LOG(gots = t_obj_->getDatabasesFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(gots = translator_->getDatabasesFromAbsoluteXpath(xpath)); ASSERT_TRUE(gots); ASSERT_EQ(Element::list, gots->getType()); ASSERT_EQ(1, gots->size()); @@ -280,11 +280,11 @@ TEST_F(TranslatorDatabasesTestv4, setEmpty) { sess_->applyChanges(); // Reset to empty. - EXPECT_NO_THROW_LOG(t_obj_->setDatabase(xdatabase, ConstElementPtr())); + EXPECT_NO_THROW_LOG(translator_->setDatabase(xdatabase, ConstElementPtr())); // Get empty. ConstElementPtr databases; - EXPECT_NO_THROW_LOG(databases = t_obj_->getDatabasesFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(databases = translator_->getDatabasesFromAbsoluteXpath(xpath)); EXPECT_FALSE(databases); } @@ -313,11 +313,11 @@ TEST_F(TranslatorDatabasesTestv4, setEmpties) { sess_->applyChanges(); // Reset to empty. - EXPECT_NO_THROW_LOG(t_obj_->setDatabases(xdatabase, ConstElementPtr())); + EXPECT_NO_THROW_LOG(translator_->setDatabases(xdatabase, ConstElementPtr())); // Get empty. ConstElementPtr databases; - EXPECT_NO_THROW_LOG(databases = t_obj_->getDatabasesFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(databases = translator_->getDatabasesFromAbsoluteXpath(xpath)); EXPECT_FALSE(databases); } diff --git a/src/lib/yang/tests/translator_host_unittests.cc b/src/lib/yang/tests/translator_host_unittests.cc index e4a97d5b01..d51c235ee9 100644 --- a/src/lib/yang/tests/translator_host_unittests.cc +++ b/src/lib/yang/tests/translator_host_unittests.cc @@ -53,7 +53,7 @@ TEST_F(TranslatorHostsTestv6, getEmpty) { const string& xpath = "/kea-dhcp6-server:config/subnet6[id='111']"; ConstElementPtr hosts; - EXPECT_NO_THROW_LOG(hosts = t_obj_->getHostsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(hosts = translator_->getHostsFromAbsoluteXpath(xpath)); ASSERT_FALSE(hosts); } @@ -79,19 +79,19 @@ TEST_F(TranslatorHostsTestv6, get) { // Get the host. ConstElementPtr host; - EXPECT_NO_THROW_LOG(host = t_obj_->getHostFromAbsoluteXpath(shost.str())); + EXPECT_NO_THROW_LOG(host = translator_->getHostFromAbsoluteXpath(shost.str())); ASSERT_TRUE(host); ElementPtr expected = Element::createMap(); ElementPtr addresses = Element::createList(); - addresses->add(Element::create(string("2001:db8::1"))); - expected->set("hw-address", Element::create(string("00:01:02:03:04:05"))); + addresses->add(Element::create("2001:db8::1")); + expected->set("hw-address", Element::create("00:01:02:03:04:05")); expected->set("ip-addresses", addresses); EXPECT_TRUE(expected->equals(*host)); // Get the host reservation list and check if the host reservation // is in it. ConstElementPtr hosts; - EXPECT_NO_THROW_LOG(hosts = t_obj_->getHostsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(hosts = translator_->getHostsFromAbsoluteXpath(xpath)); ASSERT_TRUE(hosts); ASSERT_EQ(Element::list, hosts->getType()); ASSERT_EQ(1, hosts->size()); @@ -111,11 +111,11 @@ TEST_F(TranslatorHostsTestv6, setEmpty) { // Set empty list. ConstElementPtr hosts = Element::createList(); - EXPECT_NO_THROW_LOG(t_obj_->setHosts(xpath, hosts)); + EXPECT_NO_THROW_LOG(translator_->setHosts(xpath, hosts)); // Get it back. hosts.reset(); - EXPECT_NO_THROW_LOG(hosts = t_obj_->getHostsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(hosts = translator_->getHostsFromAbsoluteXpath(xpath)); ASSERT_FALSE(hosts); } @@ -133,15 +133,15 @@ TEST_F(TranslatorHostsTestv4, set) { // Set one host. ElementPtr hosts = Element::createList(); ElementPtr host = Element::createMap(); - host->set("flex-id", Element::create(string("00:ff"))); - host->set("ip-address", Element::create(string("10.0.0.1"))); - host->set("hostname", Element::create(string("foo"))); + host->set("flex-id", Element::create("00:ff")); + host->set("ip-address", Element::create("10.0.0.1")); + host->set("hostname", Element::create("foo")); hosts->add(host); - EXPECT_NO_THROW_LOG(t_obj_->setHosts(xpath, hosts)); + EXPECT_NO_THROW_LOG(translator_->setHosts(xpath, hosts)); // Get it back. hosts.reset(); - EXPECT_NO_THROW_LOG(hosts = t_obj_->getHostsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(hosts = translator_->getHostsFromAbsoluteXpath(xpath)); ASSERT_TRUE(hosts); ASSERT_EQ(Element::list, hosts->getType()); ASSERT_EQ(1, hosts->size()); @@ -179,7 +179,7 @@ TEST_F(TranslatorHostsTestv6, getMany) { // Get the host. ConstElementPtr hosts; - EXPECT_NO_THROW_LOG(hosts = t_obj_->getHostsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(hosts = translator_->getHostsFromAbsoluteXpath(xpath)); ASSERT_TRUE(hosts); EXPECT_EQ(hosts->str(), diff --git a/src/lib/yang/tests/translator_logger_unittests.cc b/src/lib/yang/tests/translator_logger_unittests.cc index ae29a42b2e..365e4bd474 100644 --- a/src/lib/yang/tests/translator_logger_unittests.cc +++ b/src/lib/yang/tests/translator_logger_unittests.cc @@ -49,7 +49,7 @@ TEST_F(TranslatorLoggersTestv4, getEmpty) { // Get empty. const string& xpath = "/kea-dhcp4-server:config"; ConstElementPtr loggers; - EXPECT_NO_THROW_LOG(loggers = t_obj_->getLoggersFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(loggers = translator_->getLoggersFromAbsoluteXpath(xpath)); ASSERT_FALSE(loggers); } @@ -71,7 +71,7 @@ TEST_F(TranslatorLoggersTestv6, get) { // Get empty. ConstElementPtr loggers; - EXPECT_NO_THROW_LOG(loggers = t_obj_->getLoggersFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(loggers = translator_->getLoggersFromAbsoluteXpath(xpath)); ASSERT_TRUE(loggers); ASSERT_EQ(1, loggers->size()); ConstElementPtr logger = loggers->get(0); @@ -107,21 +107,21 @@ TEST_F(TranslatorLoggersTestv4, set) { // Set a value. const string& xpath = "/kea-dhcp4-server:config"; ElementPtr option = Element::createMap(); - option->set("output", Element::create(string("/bar"))); + option->set("output", Element::create("/bar")); option->set("maxver", Element::create(10)); ElementPtr options = Element::createList(); options->add(option); ElementPtr logger = Element::createMap(); - logger->set("name", Element::create(string("foo"))); - logger->set("severity", Element::create(string("WARN"))); + logger->set("name", Element::create("foo")); + logger->set("severity", Element::create("WARN")); logger->set("output_options", options); ElementPtr loggers = Element::createList(); loggers->add(logger); - ASSERT_NO_THROW_LOG(t_obj_->setLoggers(xpath, loggers)); + ASSERT_NO_THROW_LOG(translator_->setLoggers(xpath, loggers)); // Get it back. ConstElementPtr gots; - EXPECT_NO_THROW_LOG(gots = t_obj_->getLoggersFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(gots = translator_->getLoggersFromAbsoluteXpath(xpath)); ASSERT_TRUE(gots); ASSERT_EQ(1, gots->size()); ConstElementPtr got = gots->get(0); diff --git a/src/lib/yang/tests/translator_option_data_unittests.cc b/src/lib/yang/tests/translator_option_data_unittests.cc index 8830d42084..9b415c7ff6 100644 --- a/src/lib/yang/tests/translator_option_data_unittests.cc +++ b/src/lib/yang/tests/translator_option_data_unittests.cc @@ -49,7 +49,7 @@ TEST_F(TranslatorOptionDataListTestv4, getEmpty) { // Get the option data list and check if it is empty. const string& xpath = "/kea-dhcp4-server:config"; ConstElementPtr options; - EXPECT_NO_THROW_LOG(options = t_obj_->getOptionDataListFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(options = translator_->getOptionDataListFromAbsoluteXpath(xpath)); ASSERT_FALSE(options); } @@ -71,7 +71,7 @@ TEST_F(TranslatorOptionDataListTestv6, get) { // Get the option data. ConstElementPtr option; - EXPECT_NO_THROW_LOG(option = t_obj_->getOptionDataFromAbsoluteXpath(xoption)); + EXPECT_NO_THROW_LOG(option = translator_->getOptionDataFromAbsoluteXpath(xoption)); ASSERT_TRUE(option); EXPECT_EQ("{" " \"always-send\": false," @@ -84,7 +84,7 @@ TEST_F(TranslatorOptionDataListTestv6, get) { // Get the option data list. ConstElementPtr options; - EXPECT_NO_THROW_LOG(options = t_obj_->getOptionDataListFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(options = translator_->getOptionDataListFromAbsoluteXpath(xpath)); ASSERT_TRUE(options); ASSERT_EQ(Element::list, options->getType()); EXPECT_EQ(1, options->size()); @@ -97,11 +97,11 @@ TEST_F(TranslatorOptionDataListTestv4, setEmpty) { // Set empty list. const string& xpath = "/kea-dhcp4-server:config"; ConstElementPtr options = Element::createList(); - EXPECT_NO_THROW_LOG(t_obj_->setOptionDataList(xpath, options)); + EXPECT_NO_THROW_LOG(translator_->setOptionDataList(xpath, options)); // Get it back. options.reset(); - EXPECT_NO_THROW_LOG(options = t_obj_->getOptionDataListFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(options = translator_->getOptionDataListFromAbsoluteXpath(xpath)); ASSERT_FALSE(options); } @@ -113,16 +113,16 @@ TEST_F(TranslatorOptionDataListTestv6, set) { ElementPtr options = Element::createList(); ElementPtr option = Element::createMap(); option->set("code", Element::create(100)); - option->set("space", Element::create(string("dns"))); + option->set("space", Element::create("dns")); option->set("csv-format", Element::create(false)); - option->set("data", Element::create(string("12121212"))); + option->set("data", Element::create("12121212")); option->set("always-send", Element::create(false)); options->add(option); - EXPECT_NO_THROW_LOG(t_obj_->setOptionDataList(xpath, options)); + EXPECT_NO_THROW_LOG(translator_->setOptionDataList(xpath, options)); // Get it back. ConstElementPtr got; - EXPECT_NO_THROW_LOG(got = t_obj_->getOptionDataListFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(got = translator_->getOptionDataListFromAbsoluteXpath(xpath)); ASSERT_TRUE(got); ASSERT_EQ(1, got->size()); EXPECT_TRUE(option->equals(*got->get(0))); diff --git a/src/lib/yang/tests/translator_option_def_unittests.cc b/src/lib/yang/tests/translator_option_def_unittests.cc index 6aa099b661..8482b93531 100644 --- a/src/lib/yang/tests/translator_option_def_unittests.cc +++ b/src/lib/yang/tests/translator_option_def_unittests.cc @@ -56,7 +56,7 @@ TEST_F(TranslatorOptionDefListTestKeaV4, getEmpty) { // Get the option definition list and check if it is empty. const string& xpath = "/kea-dhcp4-server:config"; ConstElementPtr options; - EXPECT_NO_THROW_LOG(options = t_obj_->getOptionDefListFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(options = translator_->getOptionDefListFromAbsoluteXpath(xpath)); ASSERT_FALSE(options); } @@ -79,7 +79,7 @@ TEST_F(TranslatorOptionDefListTestKeaV6, get) { // Get the option def. ConstElementPtr def; - EXPECT_NO_THROW_LOG(def = t_obj_->getOptionDefFromAbsoluteXpath(xdef)); + EXPECT_NO_THROW_LOG(def = translator_->getOptionDefFromAbsoluteXpath(xdef)); ASSERT_TRUE(def); EXPECT_EQ("{ " "\"array\": false, " @@ -91,7 +91,7 @@ TEST_F(TranslatorOptionDefListTestKeaV6, get) { // Get the option definition list. ConstElementPtr defs; - EXPECT_NO_THROW_LOG(defs = t_obj_->getOptionDefListFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(defs = translator_->getOptionDefListFromAbsoluteXpath(xpath)); ASSERT_TRUE(defs); ASSERT_EQ(Element::list, defs->getType()); EXPECT_EQ(1, defs->size()); @@ -104,11 +104,11 @@ TEST_F(TranslatorOptionDefListTestKeaV4, setEmpty) { // Set empty list. const string& xpath = "/kea-dhcp4-server:config"; ConstElementPtr defs = Element::createList(); - EXPECT_NO_THROW_LOG(t_obj_->setOptionDefList(xpath, defs)); + EXPECT_NO_THROW_LOG(translator_->setOptionDefList(xpath, defs)); // Get it back. defs.reset(); - EXPECT_NO_THROW_LOG(defs = t_obj_->getOptionDefListFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(defs = translator_->getOptionDefListFromAbsoluteXpath(xpath)); ASSERT_FALSE(defs); } @@ -120,16 +120,16 @@ TEST_F(TranslatorOptionDefListTestKeaV6, set) { ElementPtr defs = Element::createList(); ElementPtr def = Element::createMap(); def->set("code", Element::create(100)); - def->set("name", Element::create(string("foo"))); - def->set("space", Element::create(string("isc"))); - def->set("type", Element::create(string("string"))); + def->set("name", Element::create("foo")); + def->set("space", Element::create("isc")); + def->set("type", Element::create("string")); def->set("array", Element::create(false)); defs->add(def); - EXPECT_NO_THROW_LOG(t_obj_->setOptionDefList(xpath, defs)); + EXPECT_NO_THROW_LOG(translator_->setOptionDefList(xpath, defs)); // Get it back. ConstElementPtr got; - EXPECT_NO_THROW_LOG(got = t_obj_->getOptionDefListFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(got = translator_->getOptionDefListFromAbsoluteXpath(xpath)); ASSERT_TRUE(got); ASSERT_EQ(1, got->size()); EXPECT_TRUE(def->equals(*got->get(0))); diff --git a/src/lib/yang/tests/translator_pd_pool_unittests.cc b/src/lib/yang/tests/translator_pd_pool_unittests.cc index 23ac632026..f8c9388b55 100644 --- a/src/lib/yang/tests/translator_pd_pool_unittests.cc +++ b/src/lib/yang/tests/translator_pd_pool_unittests.cc @@ -52,7 +52,7 @@ TEST_F(TranslatorPdPoolsTestIetfV6, getEmptyIetf) { "/ietf-dhcpv6-server:server/server-config/network-ranges" "/network-range[network-range-id='111']/pd-pools"; ConstElementPtr pools; - EXPECT_NO_THROW_LOG(pools = t_obj_->getPdPoolsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(pools = translator_->getPdPoolsFromAbsoluteXpath(xpath)); ASSERT_FALSE(pools); } @@ -62,7 +62,7 @@ TEST_F(TranslatorPdPoolsTestKeaV6, getEmptyKea) { // Get the pd-pool list and check if it is empty. const string& xpath = "/kea-dhcp6-server:config/subnet6[id='111']"; ConstElementPtr pools; - EXPECT_NO_THROW_LOG(pools = t_obj_->getPdPoolsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(pools = translator_->getPdPoolsFromAbsoluteXpath(xpath)); ASSERT_FALSE(pools); } @@ -91,16 +91,16 @@ TEST_F(TranslatorPdPoolsTestIetfV6, getIetf) { // Get the pool. ConstElementPtr pool; - EXPECT_NO_THROW_LOG(pool = t_obj_->getPdPoolFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(pool = translator_->getPdPoolFromAbsoluteXpath(xpath)); ASSERT_TRUE(pool); ElementPtr expected = Element::createMap(); - expected->set("prefix", Element::create(string("2001:db8:0:1000::"))); + expected->set("prefix", Element::create("2001:db8:0:1000::")); expected->set("prefix-len", Element::create(56)); EXPECT_TRUE(expected->equals(*pool)); // Get the pd-pool list and check if the pd-pool is in it. ConstElementPtr pools; - EXPECT_NO_THROW_LOG(pools = t_obj_->getPdPoolsFromAbsoluteXpath(subnet + "/pd-pools")); + EXPECT_NO_THROW_LOG(pools = translator_->getPdPoolsFromAbsoluteXpath(subnet + "/pd-pools")); ASSERT_TRUE(pools); ASSERT_EQ(Element::list, pools->getType()); ASSERT_EQ(1, pools->size()); @@ -130,17 +130,17 @@ TEST_F(TranslatorPdPoolsTestKeaV6, getKea) { // Get the pool. ConstElementPtr pool; - EXPECT_NO_THROW_LOG(pool = t_obj_->getPdPoolFromAbsoluteXpath(spool.str())); + EXPECT_NO_THROW_LOG(pool = translator_->getPdPoolFromAbsoluteXpath(spool.str())); ASSERT_TRUE(pool); ElementPtr expected = Element::createMap(); - expected->set("prefix", Element::create(string("2001:db8:0:1000::"))); + expected->set("prefix", Element::create("2001:db8:0:1000::")); expected->set("prefix-len", Element::create(56)); expected->set("delegated-len", Element::create(64)); EXPECT_TRUE(expected->equals(*pool)); // Get the pd-pool list and check if the pd-pool is in it. ConstElementPtr pools; - EXPECT_NO_THROW_LOG(pools = t_obj_->getPdPoolsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(pools = translator_->getPdPoolsFromAbsoluteXpath(xpath)); ASSERT_TRUE(pools); ASSERT_EQ(Element::list, pools->getType()); ASSERT_EQ(1, pools->size()); @@ -162,11 +162,11 @@ TEST_F(TranslatorPdPoolsTestIetfV6, setEmptyIetf) { // Set empty list. const string& xpath = subnet + "/pd-pools"; ConstElementPtr pools = Element::createList(); - EXPECT_NO_THROW_LOG(t_obj_->setPdPools(xpath, pools)); + EXPECT_NO_THROW_LOG(translator_->setPdPools(xpath, pools)); // Get it back. pools.reset(); - EXPECT_NO_THROW_LOG(pools = t_obj_->getPdPoolsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(pools = translator_->getPdPoolsFromAbsoluteXpath(xpath)); ASSERT_FALSE(pools); } @@ -183,11 +183,11 @@ TEST_F(TranslatorPdPoolsTestKeaV6, setEmptyKea) { // Set empty list. ConstElementPtr pools = Element::createList(); - EXPECT_NO_THROW_LOG(t_obj_->setPdPools(xpath, pools)); + EXPECT_NO_THROW_LOG(translator_->setPdPools(xpath, pools)); // Get it back. pools.reset(); - EXPECT_NO_THROW_LOG(pools = t_obj_->getPdPoolsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(pools = translator_->getPdPoolsFromAbsoluteXpath(xpath)); ASSERT_FALSE(pools); } @@ -207,14 +207,14 @@ TEST_F(TranslatorPdPoolsTestIetfV6, setIetf) { const string& xpath = subnet + "/pd-pools"; ElementPtr pools = Element::createList(); ElementPtr pool = Element::createMap(); - pool->set("prefix", Element::create(string("2001:db8:0:1000::"))); + pool->set("prefix", Element::create("2001:db8:0:1000::")); pool->set("prefix-len", Element::create(56)); pools->add(pool); - EXPECT_NO_THROW_LOG(t_obj_->setPdPools(xpath, pools)); + EXPECT_NO_THROW_LOG(translator_->setPdPools(xpath, pools)); // Get it back. pools.reset(); - EXPECT_NO_THROW_LOG(pools = t_obj_->getPdPoolsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(pools = translator_->getPdPoolsFromAbsoluteXpath(xpath)); ASSERT_TRUE(pools); ASSERT_EQ(Element::list, pools->getType()); ASSERT_EQ(1, pools->size()); @@ -235,15 +235,15 @@ TEST_F(TranslatorPdPoolsTestKeaV6, setKea) { // Set one pool. ElementPtr pools = Element::createList(); ElementPtr pool = Element::createMap(); - pool->set("prefix", Element::create(string("2001:db8:0:1000::"))); + pool->set("prefix", Element::create("2001:db8:0:1000::")); pool->set("prefix-len", Element::create(56)); pool->set("delegated-len", Element::create(64)); pools->add(pool); - EXPECT_NO_THROW_LOG(t_obj_->setPdPools(xpath, pools)); + EXPECT_NO_THROW_LOG(translator_->setPdPools(xpath, pools)); // Get it back. pools.reset(); - EXPECT_NO_THROW_LOG(pools = t_obj_->getPdPoolsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(pools = translator_->getPdPoolsFromAbsoluteXpath(xpath)); ASSERT_TRUE(pools); ASSERT_EQ(Element::list, pools->getType()); ASSERT_EQ(1, pools->size()); @@ -283,7 +283,7 @@ TEST_F(TranslatorPdPoolsTestKeaV6, getListKea) { // Get the pools list. ConstElementPtr pools; - EXPECT_NO_THROW_LOG(pools = t_obj_->getPdPoolsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(pools = translator_->getPdPoolsFromAbsoluteXpath(xpath)); ASSERT_TRUE(pools); // Check that both of them are returned properly. diff --git a/src/lib/yang/tests/translator_pool_unittests.cc b/src/lib/yang/tests/translator_pool_unittests.cc index a68c20f408..ad0d25f428 100644 --- a/src/lib/yang/tests/translator_pool_unittests.cc +++ b/src/lib/yang/tests/translator_pool_unittests.cc @@ -59,7 +59,7 @@ TEST_F(TranslatorPoolsTestIetfV6, getEmptyIetf) { const string& xpath = "/ietf-dhcpv6-server:server/server-config/" "network-ranges/network-range[network-range-id='111']/address-pools"; ConstElementPtr pools; - EXPECT_NO_THROW_LOG(pools = t_obj_->getPoolsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(pools = translator_->getPoolsFromAbsoluteXpath(xpath)); ASSERT_FALSE(pools); } @@ -69,7 +69,7 @@ TEST_F(TranslatorPoolsTestKeaV6, getEmptyKea) { // Get the pool list and check if it is empty. const string& xpath = "/kea-dhcp6-server:config/subnet6[id='111']"; ConstElementPtr pools; - EXPECT_NO_THROW_LOG(pools = t_obj_->getPoolsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(pools = translator_->getPoolsFromAbsoluteXpath(xpath)); ASSERT_FALSE(pools); } @@ -93,13 +93,13 @@ TEST_F(TranslatorPoolsTestIetfV6, getIetf) { // Get the pool. ConstElementPtr pool; - EXPECT_NO_THROW_LOG(pool = t_obj_->getPoolFromAbsoluteXpath(xpath + "/address-pool[pool-id='222']")); + EXPECT_NO_THROW_LOG(pool = translator_->getPoolFromAbsoluteXpath(xpath + "/address-pool[pool-id='222']")); ASSERT_TRUE(pool); EXPECT_EQ("{ \"pool\": \"2001:db8::1:0/112\" }", pool->str()); // Get the pool list and check if the pool is in it. ConstElementPtr pools; - EXPECT_NO_THROW_LOG(pools = t_obj_->getPoolsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(pools = translator_->getPoolsFromAbsoluteXpath(xpath)); ASSERT_TRUE(pools); ASSERT_EQ(Element::list, pools->getType()); ASSERT_EQ(1, pools->size()); @@ -135,15 +135,15 @@ TEST_F(TranslatorPoolsTestKeaV6, getKea) { // Get the pool. ConstElementPtr pool; - EXPECT_NO_THROW_LOG(pool = t_obj_->getPoolFromAbsoluteXpath(spool.str())); + EXPECT_NO_THROW_LOG(pool = translator_->getPoolFromAbsoluteXpath(spool.str())); ASSERT_TRUE(pool); ElementPtr expected = Element::createMap(); - expected->set("pool", Element::create(string("2001:db8::1:0/112"))); + expected->set("pool", Element::create("2001:db8::1:0/112")); EXPECT_TRUE(expected->equals(*pool)); // Get the pool list and check if the pool is in it. ConstElementPtr pools; - EXPECT_NO_THROW_LOG(pools = t_obj_->getPoolsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(pools = translator_->getPoolsFromAbsoluteXpath(xpath)); ASSERT_TRUE(pools); ASSERT_EQ(Element::list, pools->getType()); ASSERT_EQ(1, pools->size()); @@ -164,11 +164,11 @@ TEST_F(TranslatorPoolsTestIetfV6, setEmptyIetf) { // Set empty list. const string& xpath = subnet + "/address-pools"; ConstElementPtr pools = Element::createList(); - EXPECT_NO_THROW_LOG(t_obj_->setPools(xpath, pools)); + EXPECT_NO_THROW_LOG(translator_->setPools(xpath, pools)); // Get it back. pools.reset(); - EXPECT_NO_THROW_LOG(pools = t_obj_->getPoolsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(pools = translator_->getPoolsFromAbsoluteXpath(xpath)); ASSERT_FALSE(pools); } @@ -185,11 +185,11 @@ TEST_F(TranslatorPoolsTestKeaV6, setEmptyKea) { // Set empty list. ConstElementPtr pools = Element::createList(); - EXPECT_NO_THROW_LOG(t_obj_->setPools(xpath, pools)); + EXPECT_NO_THROW_LOG(translator_->setPools(xpath, pools)); // Get it back. pools.reset(); - EXPECT_NO_THROW_LOG(pools = t_obj_->getPoolsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(pools = translator_->getPoolsFromAbsoluteXpath(xpath)); ASSERT_FALSE(pools); } @@ -208,13 +208,13 @@ TEST_F(TranslatorPoolsTestIetfV6, setIetf) { const string& xpath = subnet + "/address-pools"; ElementPtr pools = Element::createList(); ElementPtr pool = Element::createMap(); - pool->set("pool", Element::create(string("2001:db8::1:0/112"))); + pool->set("pool", Element::create("2001:db8::1:0/112")); pools->add(pool); - EXPECT_NO_THROW_LOG(t_obj_->setPools(xpath, pools)); + EXPECT_NO_THROW_LOG(translator_->setPools(xpath, pools)); // Get it back. pools.reset(); - EXPECT_NO_THROW_LOG(pools = t_obj_->getPoolsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(pools = translator_->getPoolsFromAbsoluteXpath(xpath)); ASSERT_TRUE(pools); ASSERT_EQ(Element::list, pools->getType()); ASSERT_EQ(1, pools->size()); @@ -236,13 +236,13 @@ TEST_F(TranslatorPoolsTestKeaV6, setKea) { ElementPtr pools = Element::createList(); ElementPtr pool = Element::createMap(); pool->set("pool", - Element::create(string("2001:db8::1 - 2001:db8::100"))); + Element::create("2001:db8::1 - 2001:db8::100")); pools->add(pool); - EXPECT_NO_THROW_LOG(t_obj_->setPools(xpath, pools)); + EXPECT_NO_THROW_LOG(translator_->setPools(xpath, pools)); // Get it back. pools.reset(); - EXPECT_NO_THROW_LOG(pools = t_obj_->getPoolsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(pools = translator_->getPoolsFromAbsoluteXpath(xpath)); ASSERT_TRUE(pools); ASSERT_EQ(Element::list, pools->getType()); ASSERT_EQ(1, pools->size()); diff --git a/src/lib/yang/tests/translator_shared_network_unittests.cc b/src/lib/yang/tests/translator_shared_network_unittests.cc index 374419aa44..e8977132ee 100644 --- a/src/lib/yang/tests/translator_shared_network_unittests.cc +++ b/src/lib/yang/tests/translator_shared_network_unittests.cc @@ -48,7 +48,7 @@ TEST_F(TranslatorSharedNetworksTestKeaV4, getEmpty) { // Get the shared network list and check if it is empty. const string& xpath = "/kea-dhcp4-server:config"; ConstElementPtr networks; - EXPECT_NO_THROW_LOG(networks = t_obj_->getSharedNetworksFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(networks = translator_->getSharedNetworksFromAbsoluteXpath(xpath)); ASSERT_FALSE(networks); } @@ -65,21 +65,21 @@ TEST_F(TranslatorSharedNetworksTestKeaV6, get) { // Get the shared network. ConstElementPtr network; - EXPECT_NO_THROW_LOG(network = t_obj_->getSharedNetworkFromAbsoluteXpath(xnetwork)); + EXPECT_NO_THROW_LOG(network = translator_->getSharedNetworkFromAbsoluteXpath(xnetwork)); ASSERT_TRUE(network); ElementPtr subnet = Element::createMap(); subnet->set("id", Element::create(111)); - subnet->set("subnet", Element::create(string("2001:db8::/48"))); + subnet->set("subnet", Element::create("2001:db8::/48")); ElementPtr subnets = Element::createList(); subnets->add(subnet); ElementPtr expected = Element::createMap(); - expected->set("name", Element::create(string("foo"))); + expected->set("name", Element::create("foo")); expected->set("subnet6", subnets); EXPECT_TRUE(expected->equals(*network)); // Get the shared network list and check if the shared network is in it. ConstElementPtr networks; - EXPECT_NO_THROW_LOG(networks = t_obj_->getSharedNetworksFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(networks = translator_->getSharedNetworksFromAbsoluteXpath(xpath)); ASSERT_TRUE(networks); ASSERT_EQ(Element::list, networks->getType()); ASSERT_EQ(1, networks->size()); @@ -92,11 +92,11 @@ TEST_F(TranslatorSharedNetworksTestKeaV4, setEmpty) { // Set empty list. const string& xpath = "/kea-dhcp4-server:config"; ConstElementPtr networks = Element::createList(); - EXPECT_NO_THROW_LOG(t_obj_->setSharedNetworks(xpath, networks)); + EXPECT_NO_THROW_LOG(translator_->setSharedNetworks(xpath, networks)); // Get it back. networks.reset(); - EXPECT_NO_THROW_LOG(networks = t_obj_->getSharedNetworksFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(networks = translator_->getSharedNetworksFromAbsoluteXpath(xpath)); ASSERT_FALSE(networks); } @@ -109,17 +109,17 @@ TEST_F(TranslatorSharedNetworksTestKeaV6, set) { ElementPtr share = Element::createMap(); ElementPtr subnets = Element::createList(); ElementPtr subnet = Element::createMap(); - subnet->set("subnet", Element::create(string("2001:db8::/48"))); + subnet->set("subnet", Element::create("2001:db8::/48")); subnet->set("id", Element::create(123)); subnets->add(subnet); - share->set("name", Element::create(string("foo"))); + share->set("name", Element::create("foo")); share->set("subnet6", subnets); networks->add(share); - EXPECT_NO_THROW_LOG(t_obj_->setSharedNetworks(xpath, networks)); + EXPECT_NO_THROW_LOG(translator_->setSharedNetworks(xpath, networks)); // Get it back. networks.reset(); - EXPECT_NO_THROW_LOG(networks = t_obj_->getSharedNetworksFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(networks = translator_->getSharedNetworksFromAbsoluteXpath(xpath)); ASSERT_TRUE(networks); ASSERT_EQ(Element::list, networks->getType()); ASSERT_EQ(1, networks->size()); @@ -187,22 +187,22 @@ TEST_F(TranslatorSharedNetworksTestKeaV6, getList) { ConstElementPtr network; // Get the first network. - EXPECT_NO_THROW_LOG(network = t_obj_->getSharedNetworkFromAbsoluteXpath(xnetwork1)); + EXPECT_NO_THROW_LOG(network = translator_->getSharedNetworkFromAbsoluteXpath(xnetwork1)); ASSERT_TRUE(network); EXPECT_EQ(exp_net1, network->str()); // Get the second network. - EXPECT_NO_THROW_LOG(network = t_obj_->getSharedNetworkFromAbsoluteXpath(xnetwork2)); + EXPECT_NO_THROW_LOG(network = translator_->getSharedNetworkFromAbsoluteXpath(xnetwork2)); ASSERT_TRUE(network); EXPECT_EQ(exp_net2, network->str()); // Check that networks with non-existent name are not returned. - EXPECT_NO_THROW_LOG(network = t_obj_->getSharedNetworkFromAbsoluteXpath(xnetwork3)); + EXPECT_NO_THROW_LOG(network = translator_->getSharedNetworkFromAbsoluteXpath(xnetwork3)); EXPECT_FALSE(network); // Now test returns all networks ConstElementPtr networks; - EXPECT_NO_THROW_LOG(networks = t_obj_->getSharedNetworksFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(networks = translator_->getSharedNetworksFromAbsoluteXpath(xpath)); ASSERT_TRUE(networks); EXPECT_EQ(exp_both, networks->str()); } diff --git a/src/lib/yang/tests/translator_subnet_unittests.cc b/src/lib/yang/tests/translator_subnet_unittests.cc index 332711ef11..d9a8104a11 100644 --- a/src/lib/yang/tests/translator_subnet_unittests.cc +++ b/src/lib/yang/tests/translator_subnet_unittests.cc @@ -59,7 +59,7 @@ TEST_F(TranslatorSubnetsTestIetfV6, getEmptyIetf) { const string& xpath = "/ietf-dhcpv6-server:server/server-config/network-ranges"; ConstElementPtr subnets; - EXPECT_NO_THROW_LOG(subnets = t_obj_->getSubnetsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath)); ASSERT_FALSE(subnets); } @@ -69,7 +69,7 @@ TEST_F(TranslatorSubnetsTestKeaV6, getEmptyKea) { // Get the subnet list and check if it is empty. const string& xpath = "/kea-dhcp6-server:config"; ConstElementPtr subnets; - EXPECT_NO_THROW_LOG(subnets = t_obj_->getSubnetsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath)); ASSERT_FALSE(subnets); } @@ -87,7 +87,7 @@ TEST_F(TranslatorSubnetsTestIetfV6, getIetf) { // Get the subnet. ConstElementPtr subnet; - EXPECT_NO_THROW_LOG(subnet = t_obj_->getSubnetFromAbsoluteXpath(xsub)); + EXPECT_NO_THROW_LOG(subnet = translator_->getSubnetFromAbsoluteXpath(xsub)); ASSERT_TRUE(subnet); EXPECT_EQ("{ \"id\": 111, " "\"subnet\": \"2001:db8::/48\" }", @@ -95,7 +95,7 @@ TEST_F(TranslatorSubnetsTestIetfV6, getIetf) { // Get the subnet list and check if the subnet is in it. ConstElementPtr subnets; - EXPECT_NO_THROW_LOG(subnets = t_obj_->getSubnetsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath)); ASSERT_TRUE(subnets); ASSERT_EQ(Element::list, subnets->getType()); ASSERT_EQ(1, subnets->size()); @@ -116,16 +116,16 @@ TEST_F(TranslatorSubnetsTestKeaV6, getKea) { // Get the subnet. ConstElementPtr subnet; - EXPECT_NO_THROW_LOG(subnet = t_obj_->getSubnetFromAbsoluteXpath(xsub)); + EXPECT_NO_THROW_LOG(subnet = translator_->getSubnetFromAbsoluteXpath(xsub)); ASSERT_TRUE(subnet); ElementPtr expected = Element::createMap(); expected->set("id", Element::create(111)); - expected->set("subnet", Element::create(string("2001:db8::/48"))); + expected->set("subnet", Element::create("2001:db8::/48")); EXPECT_TRUE(expected->equals(*subnet)); // Get the subnet list and check if the subnet is in it. ConstElementPtr subnets; - EXPECT_NO_THROW_LOG(subnets = t_obj_->getSubnetsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath)); ASSERT_TRUE(subnets); ASSERT_EQ(Element::list, subnets->getType()); ASSERT_EQ(1, subnets->size()); @@ -159,7 +159,7 @@ TEST_F(TranslatorSubnetsTestIetfV6, getPoolsIetf) { // Get the subnet. ConstElementPtr subnet; - EXPECT_NO_THROW_LOG(subnet = t_obj_->getSubnetFromAbsoluteXpath(xsub)); + EXPECT_NO_THROW_LOG(subnet = translator_->getSubnetFromAbsoluteXpath(xsub)); ASSERT_TRUE(subnet); string expected = "{\n" @@ -178,7 +178,7 @@ TEST_F(TranslatorSubnetsTestIetfV6, getPoolsIetf) { // Get the subnet list and check if the subnet is in it. ConstElementPtr subnets; - EXPECT_NO_THROW_LOG(subnets = t_obj_->getSubnetsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath)); ASSERT_TRUE(subnets); ASSERT_EQ(Element::list, subnets->getType()); ASSERT_EQ(1, subnets->size()); @@ -211,7 +211,7 @@ TEST_F(TranslatorSubnetsTestKeaV6, getPoolsKea) { // Get the subnet. ConstElementPtr subnet; - EXPECT_NO_THROW_LOG(subnet = t_obj_->getSubnetFromAbsoluteXpath(xsub)); + EXPECT_NO_THROW_LOG(subnet = translator_->getSubnetFromAbsoluteXpath(xsub)); ASSERT_TRUE(subnet); string expected = "{\n" @@ -230,7 +230,7 @@ TEST_F(TranslatorSubnetsTestKeaV6, getPoolsKea) { // Get the subnet list and check if the subnet is in it. ConstElementPtr subnets; - EXPECT_NO_THROW_LOG(subnets = t_obj_->getSubnetsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath)); ASSERT_TRUE(subnets); ASSERT_EQ(Element::list, subnets->getType()); ASSERT_EQ(1, subnets->size()); @@ -244,11 +244,11 @@ TEST_F(TranslatorSubnetsTestIetfV6, setEmptyIetf) { const string& xpath = "/ietf-dhcpv6-server:server/server-config/network-ranges"; ConstElementPtr subnets = Element::createList(); - EXPECT_NO_THROW_LOG(t_obj_->setSubnets(xpath, subnets)); + EXPECT_NO_THROW_LOG(translator_->setSubnets(xpath, subnets)); // Get it back. subnets.reset(); - EXPECT_NO_THROW_LOG(subnets = t_obj_->getSubnetsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath)); ASSERT_FALSE(subnets); } @@ -258,11 +258,11 @@ TEST_F(TranslatorSubnetsTestKeaV4, setEmptyKea) { // Set empty list. const string& xpath = "/kea-dhcp4-server:config"; ElementPtr subnets = Element::createList(); - EXPECT_NO_THROW_LOG(t_obj_->setSubnets(xpath, subnets)); + EXPECT_NO_THROW_LOG(translator_->setSubnets(xpath, subnets)); // Get it back. subnets.reset(); - EXPECT_NO_THROW_LOG(subnets = t_obj_->getSubnetsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath)); ASSERT_FALSE(subnets); } @@ -274,14 +274,14 @@ TEST_F(TranslatorSubnetsTestIetfV6, setIetf) { "/ietf-dhcpv6-server:server/server-config/network-ranges"; ElementPtr subnets = Element::createList(); ElementPtr subnet = Element::createMap(); - subnet->set("subnet", Element::create(string("2001:db8::/48"))); + subnet->set("subnet", Element::create("2001:db8::/48")); subnet->set("id", Element::create(123)); subnets->add(subnet); - EXPECT_NO_THROW_LOG(t_obj_->setSubnets(xpath, subnets)); + EXPECT_NO_THROW_LOG(translator_->setSubnets(xpath, subnets)); // Get it back. subnets.reset(); - EXPECT_NO_THROW_LOG(subnets = t_obj_->getSubnetsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath)); ASSERT_TRUE(subnets); ASSERT_EQ(Element::list, subnets->getType()); ASSERT_EQ(1, subnets->size()); @@ -295,14 +295,14 @@ TEST_F(TranslatorSubnetsTestKeaV4, setKea) { const string& xpath = "/kea-dhcp4-server:config"; ElementPtr subnets = Element::createList(); ElementPtr subnet = Element::createMap(); - subnet->set("subnet", Element::create(string("10.0.1.0/24"))); + subnet->set("subnet", Element::create("10.0.1.0/24")); subnet->set("id", Element::create(123)); subnets->add(subnet); - EXPECT_NO_THROW_LOG(t_obj_->setSubnets(xpath, subnets)); + EXPECT_NO_THROW_LOG(translator_->setSubnets(xpath, subnets)); // Get it back. subnets.reset(); - EXPECT_NO_THROW_LOG(subnets = t_obj_->getSubnetsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath)); ASSERT_TRUE(subnets); ASSERT_EQ(Element::list, subnets->getType()); ASSERT_EQ(1, subnets->size()); @@ -317,26 +317,26 @@ TEST_F(TranslatorSubnetsTestIetfV6, setTwoIetf) { "/ietf-dhcpv6-server:server/server-config/network-ranges"; ElementPtr subnets = Element::createList(); ElementPtr subnet = Element::createMap(); - subnet->set("subnet", Element::create(string("2001:db8::/48"))); + subnet->set("subnet", Element::create("2001:db8::/48")); subnet->set("id", Element::create(123)); // Add two pools. ElementPtr pools = Element::createList(); ElementPtr pool1 = Element::createMap(); - pool1->set("pool", Element::create(string("2001:db8::1:0/112"))); + pool1->set("pool", Element::create("2001:db8::1:0/112")); pools->add(pool1); ElementPtr pool2 = Element::createMap(); - pool2->set("pool", Element::create(string("2001:db8::2:0/112"))); + pool2->set("pool", Element::create("2001:db8::2:0/112")); pools->add(pool2); subnet->set("pools", pools); // Add the subnet. subnets->add(subnet); - EXPECT_NO_THROW_LOG(t_obj_->setSubnets(xpath, subnets)); + EXPECT_NO_THROW_LOG(translator_->setSubnets(xpath, subnets)); // Get it back. subnets.reset(); - EXPECT_NO_THROW_LOG(subnets = t_obj_->getSubnetsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath)); ASSERT_TRUE(subnets); ASSERT_EQ(Element::list, subnets->getType()); ASSERT_EQ(1, subnets->size()); @@ -350,26 +350,26 @@ TEST_F(TranslatorSubnetsTestKeaV4, setTwoKea) { const string& xpath = "/kea-dhcp4-server:config"; ElementPtr subnets = Element::createList(); ElementPtr subnet = Element::createMap(); - subnet->set("subnet", Element::create(string("10.0.1.0/24"))); + subnet->set("subnet", Element::create("10.0.1.0/24")); subnet->set("id", Element::create(123)); // Add two pools. ElementPtr pools = Element::createList(); ElementPtr pool1 = Element::createMap(); - pool1->set("pool", Element::create(string("10.0.1.0/28"))); + pool1->set("pool", Element::create("10.0.1.0/28")); pools->add(pool1); ElementPtr pool2 = Element::createMap(); - pool2->set("pool", Element::create(string("10.0.1.200 - 10.0.1.222"))); + pool2->set("pool", Element::create("10.0.1.200 - 10.0.1.222")); pools->add(pool2); subnet->set("pools", pools); // Add the subnet. subnets->add(subnet); - EXPECT_NO_THROW_LOG(t_obj_->setSubnets(xpath, subnets)); + EXPECT_NO_THROW_LOG(translator_->setSubnets(xpath, subnets)); // Get it back. subnets.reset(); - EXPECT_NO_THROW_LOG(subnets = t_obj_->getSubnetsFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath)); ASSERT_TRUE(subnets); ASSERT_EQ(Element::list, subnets->getType()); ASSERT_EQ(1, subnets->size()); diff --git a/src/lib/yang/tests/translator_unittests.cc b/src/lib/yang/tests/translator_unittests.cc index a17b61cec2..cd65e27850 100644 --- a/src/lib/yang/tests/translator_unittests.cc +++ b/src/lib/yang/tests/translator_unittests.cc @@ -52,8 +52,8 @@ TEST_F(TranslatorTest, constructor) { Session sess(Connection{}.sessionStart()); sess.switchDatastore(sysrepo::Datastore::Candidate); // Get a translator object. - std::unique_ptr<Translator> t_obj; - EXPECT_NO_THROW_LOG(t_obj.reset(new Translator(sess, ""))); + std::unique_ptr<Translator> translator; + EXPECT_NO_THROW_LOG(translator.reset(new Translator(sess, ""))); } // Test basic YANG to JSON value conversion using sysrepo test models. @@ -61,10 +61,10 @@ TEST_F(TranslatorTest, getItem) { // Get a translator object to play with. Session sess(Connection{}.sessionStart()); sess.switchDatastore(sysrepo::Datastore::Candidate); - std::unique_ptr<Translator> t_obj; - ASSERT_NO_THROW_LOG(t_obj.reset(new Translator(sess, ""))); + std::unique_ptr<Translator> translator; + ASSERT_NO_THROW_LOG(translator.reset(new Translator(sess, ""))); string value; - ConstElementPtr elem; + ConstElementPtr element; string xpath; // String. @@ -72,22 +72,22 @@ TEST_F(TranslatorTest, getItem) { value = "str"; EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::string, elem->getType()); - EXPECT_EQ("str", elem->stringValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::string, element->getType()); + EXPECT_EQ("str", element->stringValue()); + element.reset(); // Bool. xpath = "/keatest-module:main/boolean"; value = "true"; EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::boolean, elem->getType()); - EXPECT_TRUE(elem->boolValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::boolean, element->getType()); + EXPECT_TRUE(element->boolValue()); + element.reset(); // Unsigned 8 bit integer. xpath = "/keatest-module:main/ui8"; @@ -95,11 +95,11 @@ TEST_F(TranslatorTest, getItem) { value = to_string(u8); EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::integer, elem->getType()); - EXPECT_EQ(8, elem->intValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::integer, element->getType()); + EXPECT_EQ(8, element->intValue()); + element.reset(); // Unsigned 16 bit integer. xpath = "/keatest-module:main/ui16"; @@ -107,11 +107,11 @@ TEST_F(TranslatorTest, getItem) { value = to_string(u16); EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::integer, elem->getType()); - EXPECT_EQ(16, elem->intValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::integer, element->getType()); + EXPECT_EQ(16, element->intValue()); + element.reset(); // Unsigned 32 bit integer. xpath = "/keatest-module:main/ui32"; @@ -119,11 +119,11 @@ TEST_F(TranslatorTest, getItem) { value = to_string(u32); EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::integer, elem->getType()); - EXPECT_EQ(32, elem->intValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::integer, element->getType()); + EXPECT_EQ(32, element->intValue()); + element.reset(); // Unsigned 64 bit integer. xpath = "/keatest-module:main/ui64"; @@ -131,22 +131,22 @@ TEST_F(TranslatorTest, getItem) { value = to_string(u64); EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::integer, elem->getType()); - EXPECT_EQ(64, elem->intValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::integer, element->getType()); + EXPECT_EQ(64, element->intValue()); + element.reset(); // Empty. xpath = "/keatest-module:main/empty"; value = string(); EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::string, elem->getType()); - EXPECT_EQ(string(), elem->stringValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::string, element->getType()); + EXPECT_EQ(string(), element->stringValue()); + element.reset(); // Signed 8 bit integer. xpath = "/keatest-module:main/i8"; @@ -154,11 +154,11 @@ TEST_F(TranslatorTest, getItem) { value = to_string(s8); EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::integer, elem->getType()); - EXPECT_EQ(8, elem->intValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::integer, element->getType()); + EXPECT_EQ(8, element->intValue()); + element.reset(); // Signed 16 bit integer. xpath = "/keatest-module:main/i16"; @@ -166,11 +166,11 @@ TEST_F(TranslatorTest, getItem) { value = to_string(s16); EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::integer, elem->getType()); - EXPECT_EQ(16, elem->intValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::integer, element->getType()); + EXPECT_EQ(16, element->intValue()); + element.reset(); // Signed 32 bit integer. xpath = "/keatest-module:main/i32"; @@ -178,11 +178,11 @@ TEST_F(TranslatorTest, getItem) { value = to_string(s32); EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::integer, elem->getType()); - EXPECT_EQ(32, elem->intValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::integer, element->getType()); + EXPECT_EQ(32, element->intValue()); + element.reset(); // Signed 64 bit integer. xpath = "/keatest-module:main/i64"; @@ -190,61 +190,61 @@ TEST_F(TranslatorTest, getItem) { value = to_string(s64); EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::integer, elem->getType()); - EXPECT_EQ(64, elem->intValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::integer, element->getType()); + EXPECT_EQ(64, element->intValue()); + element.reset(); // Identity reference. xpath = "/keatest-module:main/id_ref"; value = "keatest-module:id_1"; EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::string, elem->getType()); - EXPECT_EQ("keatest-module:id_1", elem->stringValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::string, element->getType()); + EXPECT_EQ("keatest-module:id_1", element->stringValue()); + element.reset(); // Enumeration item. xpath = "/keatest-module:main/enum"; value = "maybe"; EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::string, elem->getType()); - EXPECT_EQ("maybe", elem->stringValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::string, element->getType()); + EXPECT_EQ("maybe", element->stringValue()); + element.reset(); // Bits. xpath = "/keatest-module:main/options"; value = "strict recursive logging"; EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::string, elem->getType()); - EXPECT_EQ("strict recursive logging", elem->stringValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::string, element->getType()); + EXPECT_EQ("strict recursive logging", element->stringValue()); + element.reset(); // Binary. xpath = "/keatest-module:main/raw"; value = "Zm9vYmFy"; EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::string, elem->getType()); - EXPECT_EQ("foobar", elem->stringValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::string, element->getType()); + EXPECT_EQ("foobar", element->stringValue()); + element.reset(); // Leaf-list: not yet exist. xpath = "/keatest-module:main/numbers"; - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - EXPECT_FALSE(elem); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + EXPECT_FALSE(element); + element.reset(); // No easy way to create it empty. @@ -261,103 +261,136 @@ TEST_F(TranslatorTest, getItem) { value = to_string(u8); EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::list, elem->getType()); - EXPECT_EQ(3, elem->size()); - EXPECT_EQ("[ 1, 2, 3 ]", elem->str()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::list, element->getType()); + EXPECT_EQ(3, element->size()); + EXPECT_EQ("[ 1, 2, 3 ]", element->str()); + element.reset(); // Instance identifier. xpath = "/keatest-module:main/instance_id"; value = "/keatest-module:main/numbers[.='1']"; EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::string, elem->getType()); - EXPECT_EQ(value, elem->stringValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::string, element->getType()); + EXPECT_EQ(value, element->stringValue()); + element.reset(); // Union. xpath = "/keatest-module:main/union"; value = "8"; EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::string, elem->getType()); - EXPECT_EQ(value, elem->stringValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::string, element->getType()); + EXPECT_EQ(value, element->stringValue()); + element.reset(); value = "infinity"; EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::string, elem->getType()); - EXPECT_EQ(value, elem->stringValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::string, element->getType()); + EXPECT_EQ(value, element->stringValue()); + element.reset(); // Leafref. xpath = "/keatest-module:main/leafref-i8"; value = "9"; EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::string, elem->getType()); - EXPECT_EQ(value, elem->stringValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::string, element->getType()); + EXPECT_EQ(value, element->stringValue()); + element.reset(); // Leafref. xpath = "/keatest-module:main/leafref-raw"; value = "ff012345"; EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::string, elem->getType()); - EXPECT_EQ(value, elem->stringValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::string, element->getType()); + EXPECT_EQ(value, element->stringValue()); + element.reset(); // Leafref. xpath = "/keatest-module:main/leafref-string"; value = "string through leafref"; EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::string, elem->getType()); - EXPECT_EQ(value, elem->stringValue()); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::string, element->getType()); + EXPECT_EQ(value, element->stringValue()); + element.reset(); // Decimal 64. xpath = "/keatest-module:main/dec64"; value = to_string(9.85); EXPECT_NO_THROW_LOG(sess.setItem(xpath, value)); sess.applyChanges(); - EXPECT_NO_THROW_LOG(elem = t_obj->getItemFromAbsoluteXpath(xpath)); - ASSERT_TRUE(elem); - ASSERT_EQ(Element::real, elem->getType()); - EXPECT_EQ("9.85", elem->str()); - elem.reset(); - - // Not found. - xpath = "/keatest-module:main/no_such_string"; - EXPECT_THROW_MSG(t_obj->deleteItem(xpath), NetconfError, - "sysrepo error getting item at '/keatest-module:main/no_such_string': " - "Couldn't find schema node: /keatest-module:main/no_such_string"); - EXPECT_THROW_MSG(elem = t_obj->getItemFromAbsoluteXpath(xpath), NetconfError, - "sysrepo error getting item at '/keatest-module:main/no_such_string': " - "Couldn't find schema node: /keatest-module:main/no_such_string"); - EXPECT_FALSE(elem); - elem.reset(); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + ASSERT_TRUE(element); + ASSERT_EQ(Element::real, element->getType()); + EXPECT_EQ("9.85", element->str()); + element.reset(); + + // Not existing. + xpath = "/keatest-module:main/no_such_node"; + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + EXPECT_FALSE(element); + element.reset(); // Check error. xpath = "null"; - EXPECT_THROW_MSG(elem = t_obj->getItemFromAbsoluteXpath(xpath), NetconfError, - "sysrepo error getting item at 'null': Couldn't find schema node: null"); - EXPECT_FALSE(elem); + EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath)); + EXPECT_FALSE(element); +} + + +TEST_F(TranslatorTest, deleteItem) { + ElementPtr got; + string xpath; + + // Get a translator object to play with. + Translator translator(Connection{}.sessionStart(), "keatest-module"); + + // Missing schema node + EXPECT_NO_THROW(translator.deleteItem("/keatest-module:main/no_such_node")); + + // Existing schema node, but no data + xpath = "/keatest-module:main/string"; + EXPECT_NO_THROW(translator.deleteItem(xpath)); + EXPECT_NO_THROW_LOG(got = translator.getItemFromAbsoluteXpath(xpath)); + EXPECT_FALSE(got); + got.reset(); + + // Existing schema node, existing data + translator.setItem(xpath, Element::create("value"), LeafBaseType::String); + EXPECT_NO_THROW(translator.deleteItem(xpath)); + EXPECT_NO_THROW_LOG(got = translator.getItemFromAbsoluteXpath(xpath)); + EXPECT_FALSE(got); + got.reset(); + + // Container schema node, no data + EXPECT_NO_THROW(translator.deleteItem("/keatest-module:main")); + EXPECT_NO_THROW_LOG(got = translator.getItemFromAbsoluteXpath(xpath)); + EXPECT_FALSE(got); + got.reset(); + + // Container schema node, existing data + translator.setItem(xpath, Element::create("value"), LeafBaseType::String); + EXPECT_NO_THROW(translator.deleteItem("/keatest-module:main")); + EXPECT_NO_THROW_LOG(got = translator.getItemFromAbsoluteXpath(xpath)); + EXPECT_FALSE(got); + got.reset(); } // Test JSON to basic YANG value conversion using the static method. @@ -365,119 +398,119 @@ TEST_F(TranslatorTest, valueTo) { optional<string> value; // Null. - ConstElementPtr elem; - EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::String)); + ConstElementPtr element; + EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::String)); EXPECT_EQ(nullopt, value); - EXPECT_FALSE(elem); + EXPECT_FALSE(element); // Container. - elem = Element::createMap(); - EXPECT_THROW_MSG(Translator::translateToYang(elem, LeafBaseType::Unknown), NotImplemented, + element = Element::createMap(); + EXPECT_THROW_MSG(Translator::translateToYang(element, LeafBaseType::Unknown), NotImplemented, "Translator::value(): map element"); // List. - elem = Element::createList(); - EXPECT_THROW_MSG(Translator::translateToYang(elem, LeafBaseType::Unknown), NotImplemented, + element = Element::createList(); + EXPECT_THROW_MSG(Translator::translateToYang(element, LeafBaseType::Unknown), NotImplemented, "Translator::value(): list element"); // String. string str("foo"); - elem = Element::create(str); - EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::String)); - EXPECT_EQ(elem->stringValue(), value); + element = Element::create(str); + EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::String)); + EXPECT_EQ(element->stringValue(), value); // Bool. - elem = Element::create(false); - EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Bool)); - EXPECT_EQ(elem->str(), value); + element = Element::create(false); + EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Bool)); + EXPECT_EQ(element->str(), value); // Unsigned 8 bit integer. - elem = Element::create(123); - EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Uint8)); - EXPECT_EQ(elem->str(), value); - elem.reset(); + element = Element::create(123); + EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Uint8)); + EXPECT_EQ(element->str(), value); + element.reset(); // Unsigned 16 bit integer. - elem = Element::create(12345); - EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Uint16)); - EXPECT_EQ(elem->str(), value); - elem.reset(); + element = Element::create(12345); + EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Uint16)); + EXPECT_EQ(element->str(), value); + element.reset(); // Unsigned 32 bit integer. - elem = Element::create(123456789); - EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Uint32)); - EXPECT_EQ(elem->str(), value); - elem.reset(); + element = Element::create(123456789); + EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Uint32)); + EXPECT_EQ(element->str(), value); + element.reset(); // Unsigned 64 bit integer. - elem = Element::create(int64_t(1234567890123456)); - EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Uint64)); + element = Element::create(int64_t(1234567890123456)); + EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Uint64)); EXPECT_EQ("1234567890123456", value); - elem.reset(); + element.reset(); // Signed 8 bit integer. - elem = Element::create(-123); - EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Int8)); - EXPECT_EQ(elem->str(), value); - elem.reset(); + element = Element::create(-123); + EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Int8)); + EXPECT_EQ(element->str(), value); + element.reset(); // Signed 16 bit integer. - elem = Element::create(-12345); - EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Int16)); - EXPECT_EQ(elem->str(), value); - elem.reset(); + element = Element::create(-12345); + EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Int16)); + EXPECT_EQ(element->str(), value); + element.reset(); // Signed 32 bit integer. - elem = Element::create(-123456789); - EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Int32)); - EXPECT_EQ(elem->str(), value); - elem.reset(); + element = Element::create(-123456789); + EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Int32)); + EXPECT_EQ(element->str(), value); + element.reset(); // Signed 32 bit integer. - elem = Element::create(int64_t(-1234567890123456)); - EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Int64)); + element = Element::create(int64_t(-1234567890123456)); + EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Int64)); EXPECT_EQ("-1234567890123456", value); - elem.reset(); + element.reset(); // Identity reference. - elem = Element::create(str); - EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::IdentityRef)); - EXPECT_EQ(elem->stringValue(), value); + element = Element::create(str); + EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::IdentityRef)); + EXPECT_EQ(element->stringValue(), value); // Enumeration item. - EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Enum)); - EXPECT_EQ(elem->stringValue(), value); + EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Enum)); + EXPECT_EQ(element->stringValue(), value); // Binary. - elem = Element::create(string("foobar")); - EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Binary)); + element = Element::create("foobar"); + EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Binary)); EXPECT_EQ("Zm9vYmFy", value); // Bits. - elem = Element::create(string("foobar")); - EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Bits)); - EXPECT_EQ(elem->stringValue(), value); + element = Element::create("foobar"); + EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Bits)); + EXPECT_EQ(element->stringValue(), value); // Decimal 64. double d64(.1234); - elem = Element::create(d64); - EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Dec64)); - EXPECT_EQ(elem->str(), value); + element = Element::create(d64); + EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Dec64)); + EXPECT_EQ(element->str(), value); // Empty. - elem = Element::create(string()); - EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Empty)); - EXPECT_EQ(elem->stringValue(), value); + element = Element::create(string()); + EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Empty)); + EXPECT_EQ(element->stringValue(), value); // Leafref. - elem = Element::create(string("leafref")); - EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Leafref)); - EXPECT_EQ(elem->stringValue(), value); + element = Element::create("leafref"); + EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Leafref)); + EXPECT_EQ(element->stringValue(), value); // Union. - elem = Element::create(string("union")); - EXPECT_NO_THROW_LOG(value = Translator::translateToYang(elem, LeafBaseType::Union)); - EXPECT_EQ(elem->stringValue(), value); + element = Element::create("union"); + EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Union)); + EXPECT_EQ(element->stringValue(), value); } // Test JSON to basic YANG value conversion using sysrepo test models. @@ -485,160 +518,160 @@ TEST_F(TranslatorTest, setItem) { // Get a translator object to play with. Session sess(Connection{}.sessionStart()); sess.switchDatastore(sysrepo::Datastore::Candidate); - std::unique_ptr<Translator> t_obj; - ASSERT_NO_THROW_LOG(t_obj.reset(new Translator(sess, ""))); + std::unique_ptr<Translator> translator; + ASSERT_NO_THROW_LOG(translator.reset(new Translator(sess, "keatest-module"))); - ElementPtr elem; + ElementPtr element; string xpath; // String. optional<DataNode> data_node; xpath = "/keatest-module:main/string"; - elem = Element::create(string("str")); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::String)); + element = Element::create("str"); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::String)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::String, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->stringValue(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr())); // Bool. xpath = "/keatest-module:main/boolean"; - elem = Element::create(true); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Bool)); + element = Element::create(true); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Bool)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::Bool, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->str(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr())); // Unsigned 8 bit integer. xpath = "/keatest-module:main/ui8"; - elem = Element::create(8); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Uint8)); + element = Element::create(8); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Uint8)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::Uint8, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->str(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr())); // Unsigned 16 bit integer. xpath = "/keatest-module:main/ui16"; - elem = Element::create(16); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Uint16)); + element = Element::create(16); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Uint16)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::Uint16, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->str(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr())); // Unsigned 32 bit integer. xpath = "/keatest-module:main/ui32"; - elem = Element::create(32); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Uint32)); + element = Element::create(32); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Uint32)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::Uint32, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->str(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr())); // Unsigned 64 bit integer. xpath = "/keatest-module:main/ui64"; - elem = Element::create(64); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Uint64)); + element = Element::create(64); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Uint64)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::Uint64, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->str(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr())); // Empty. xpath = "/keatest-module:main/empty"; - elem = Element::create(string()); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Empty)); + element = Element::create(string()); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Empty)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::Empty, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->stringValue(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr())); // Signed 8 bit integer. xpath = "/keatest-module:main/i8"; - elem = Element::create(8); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Int8)); + element = Element::create(8); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Int8)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::Int8, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->str(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr())); // Signed 16 bit integer. xpath = "/keatest-module:main/i16"; - elem = Element::create(16); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Int16)); + element = Element::create(16); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Int16)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::Int16, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->str(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr())); // Signed 32 bit integer. xpath = "/keatest-module:main/i32"; - elem = Element::create(32); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Int32)); + element = Element::create(32); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Int32)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::Int32, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->str(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr())); // Signed 64 bit integer. xpath = "/keatest-module:main/i64"; - elem = Element::create(64); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Int64)); + element = Element::create(64); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Int64)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::Int64, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->str(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr())); // Identity reference. xpath = "/keatest-module:main/id_ref"; - elem = Element::create(string("keatest-module:id_1")); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::IdentityRef)); + element = Element::create("keatest-module:id_1"); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::IdentityRef)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::IdentityRef, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->stringValue(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr())); // Enumeration item. xpath = "/keatest-module:main/enum"; - elem = Element::create(string("maybe")); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Enum)); + element = Element::create("maybe"); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Enum)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::Enum, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->stringValue(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr())); // Binary. xpath = "/keatest-module:main/raw"; - elem = Element::create(string("foobar")); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Binary)); + element = Element::create("foobar"); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Binary)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); @@ -648,122 +681,122 @@ TEST_F(TranslatorTest, setItem) { // Bits. xpath = "/keatest-module:main/options"; - elem = Element::create(string("strict recursive logging")); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Bits)); + element = Element::create("strict recursive logging"); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Bits)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::Bits, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->stringValue(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr())); // Decimal 64. xpath = "/keatest-module:main/dec64"; double d64(9.85); - elem = Element::create(d64); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Dec64)); + element = Element::create(d64); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Dec64)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::Dec64, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->str(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr())); // Leaf-list. xpath = "/keatest-module:main/numbers"; - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, Element::fromJSON("1"), LeafBaseType::Uint8)); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, Element::fromJSON("2"), LeafBaseType::Uint8)); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, Element::fromJSON("3"), LeafBaseType::Uint8)); - ElementPtr got(t_obj->getItemFromAbsoluteXpath(xpath)); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, Element::fromJSON("1"), LeafBaseType::Uint8)); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, Element::fromJSON("2"), LeafBaseType::Uint8)); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, Element::fromJSON("3"), LeafBaseType::Uint8)); + ElementPtr got(translator->getItemFromAbsoluteXpath(xpath)); ASSERT_EQ(LeafBaseType::Dec64, data_node->schema().asLeaf().valueType().base()); EXPECT_EQ("[ 1, 2, 3 ]", got->str()); // Clean the leaf-list. - EXPECT_NO_THROW_LOG(t_obj->deleteItem(xpath)); + EXPECT_NO_THROW_LOG(translator->deleteItem(xpath)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); EXPECT_FALSE(data_node); data_node.reset(); // Instance identifier. xpath = "/keatest-module:main/instance_id"; - elem = Element::create(string("/keatest-module:main/numbers[.='1']")); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::InstanceIdentifier)); + element = Element::create("/keatest-module:main/numbers[.='1']"); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::InstanceIdentifier)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::InstanceIdentifier, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->stringValue(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr())); // Union. xpath = "/keatest-module:main/union"; - elem = Element::create(string("8")); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Union)); + element = Element::create("8"); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Union)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::Union, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->stringValue(), string(data_node->asTerm().valueStr())); - elem = Element::create(string("infinity")); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Union)); + EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr())); + element = Element::create("infinity"); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Union)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::Union, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->stringValue(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr())); // Leafref. xpath = "/keatest-module:main/leafref-i8"; - elem = Element::create(string("9")); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Leafref)); + element = Element::create("9"); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Leafref)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::Leafref, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->stringValue(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr())); // Leafref. xpath = "/keatest-module:main/leafref-raw"; - elem = Element::create(string("ff012345")); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Leafref)); + element = Element::create("ff012345"); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Leafref)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::Leafref, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->stringValue(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr())); // Leafref. xpath = "/keatest-module:main/leafref-string"; - elem = Element::create(string("string through")); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Leafref)); + element = Element::create("string through"); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Leafref)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); ASSERT_TRUE(data_node); EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath)); ASSERT_TRUE(data_node); ASSERT_EQ(LeafBaseType::Leafref, data_node->schema().asLeaf().valueType().base()); - EXPECT_EQ(elem->stringValue(), string(data_node->asTerm().valueStr())); + EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr())); // Bad xpath. - xpath = "/keatest-module:main/no_such_string"; - elem = Element::create(string("str")); - EXPECT_THROW_MSG(t_obj->setItem(xpath, elem, LeafBaseType::String), NetconfError, - "sysrepo error setting item '\"str\"' at '" + xpath + + xpath = "/keatest-module:main/no_such_node"; + element = Element::create("str"); + EXPECT_THROW_MSG(translator->setItem(xpath, element, LeafBaseType::String), NetconfError, + "setting item '\"str\"' at '" + xpath + "': Session::setItem: Couldn't set " - "'/keatest-module:main/no_such_string' to 'str': SR_ERR_INVAL_ARG"); + "'/keatest-module:main/no_such_node' to 'str': SR_ERR_INVAL_ARG"); // Bad type. xpath = "/keatest-module:main/string"; - elem = Element::create(true); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, elem, LeafBaseType::Bool)); + element = Element::create(true); + EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Bool)); - elem = t_obj->getItemFromAbsoluteXpath(xpath); - ASSERT_TRUE(elem); - EXPECT_EQ(elem->getType(), Element::string); - EXPECT_EQ(elem->str(), "\"true\""); + element = translator->getItemFromAbsoluteXpath(xpath); + ASSERT_TRUE(element); + EXPECT_EQ(element->getType(), Element::string); + EXPECT_EQ(element->str(), "\"true\""); // Delete (twice). xpath = "/keatest-module:main/string"; @@ -773,37 +806,91 @@ TEST_F(TranslatorTest, setItem) { EXPECT_TRUE(data_node); ASSERT_TRUE(NodeType::Leaf == data_node->schema().nodeType()); EXPECT_EQ("true", data_node->asTerm().valueStr()); - EXPECT_NO_THROW_LOG(t_obj->deleteItem(xpath)); + EXPECT_NO_THROW_LOG(translator->deleteItem(xpath)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); EXPECT_FALSE(data_node); - EXPECT_NO_THROW_LOG(t_obj->deleteItem(xpath)); + EXPECT_NO_THROW_LOG(translator->deleteItem(xpath)); EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath)); EXPECT_FALSE(data_node); } -// Test YANG list item retrieval. -TEST_F(TranslatorTest, list) { +// Test YANG container retrieval. +TEST_F(TranslatorTest, container) { + ElementPtr element; + // Get a translator object to play with. - Session sess(Connection{}.sessionStart()); - sess.switchDatastore(sysrepo::Datastore::Candidate); - std::unique_ptr<Translator> t_obj; - ASSERT_NO_THROW_LOG(t_obj.reset(new Translator(sess, ""))); - string xpath; + Translator translator(Connection{}.sessionStart(), "keatest-module"); + + // Container with no data apparently throws. + EXPECT_THROW_MSG(element = translator.getItemFromAbsoluteXpath("/keatest-module:container"), + NotImplemented, + "getting node of type 1 not supported, xpath is '/keatest-module:container'"); + EXPECT_FALSE(element); + element.reset(); + + EXPECT_NO_THROW_LOG( + translator.setItem("/keatest-module:container", + ElementPtr(), LeafBaseType::Unknown)); + + // Container with data filled in throws when retrieving the container itself. + element = Element::create("Leaf value"); + EXPECT_NO_THROW_LOG( + translator.setItem("/keatest-module:container/list[key1='key1'][key2='key2']/leaf", + element, LeafBaseType::String)); + element.reset(); + EXPECT_THROW_MSG( + element = translator.getItemFromAbsoluteXpath("/keatest-module:container"), + NotImplemented, + "getting node of type 1 not supported, xpath is '/keatest-module:container'"); + EXPECT_FALSE(element); + element.reset(); + EXPECT_NO_THROW_LOG(element = translator.getItemFromAbsoluteXpath("/keatest-module:container[key1=" + "'key1'][key2='key2']")); + EXPECT_FALSE(element); +} - // Empty list. +// Test YANG list retrieval. +TEST_F(TranslatorTest, list) { ElementPtr element; - EXPECT_NO_THROW_LOG(element = t_obj->getItemFromAbsoluteXpath("/keatest-module:container/list")); + + // Get a translator to play with. + Translator translator(Connection{}.sessionStart(), "keatest-module"); + + // List with no data does not throw and returns a null ElementPtr by default. + EXPECT_NO_THROW_LOG( + element = translator.getItemFromAbsoluteXpath("/keatest-module:container/list")); EXPECT_FALSE(element); element.reset(); - // Retried with a filled list. - xpath = "/keatest-module:container/list[key1='key1'][key2='key2']/leaf"; + // List with data filled in throws when retrieving the list itself. element = Element::create("Leaf value"); - EXPECT_NO_THROW_LOG(t_obj->setItem(xpath, element, LeafBaseType::String)); - EXPECT_NO_THROW_LOG(element = t_obj->getItemFromAbsoluteXpath("/keatest-module:container/list")); + EXPECT_NO_THROW_LOG( + translator.setItem("/keatest-module:container/list[key1='key1'][key2='key2']/leaf", element, + LeafBaseType::String)); + element.reset(); + EXPECT_THROW_MSG( + element = translator.getItemFromAbsoluteXpath("/keatest-module:container/list"), + NotImplemented, + "getting node of type 16 not supported, xpath is '/keatest-module:container/list'"); EXPECT_FALSE(element); - EXPECT_NO_THROW_LOG(element = t_obj->getItemFromAbsoluteXpath("/keatest-module:container/list[key1='key1'][key2='key2']")); + element.reset(); + EXPECT_THROW_MSG(element = translator.getItemFromAbsoluteXpath( + "/keatest-module:container/list[key1='key1'][key2='key2']"), + NotImplemented, + "getting node of type 16 not supported, xpath is " + "'/keatest-module:container/list[key1='key1'][key2='key2']'"); EXPECT_FALSE(element); } +// Test that we can check if a schema node exists. +TEST_F(TranslatorTest, schemaNodeExists) { + // Get a translator to play with. + Translator translator(Connection{}.sessionStart(), "keatest-module"); + + EXPECT_FALSE(translator.schemaNodeExists("/keatest-module:main/no_such_node")); + EXPECT_TRUE(translator.schemaNodeExists("/keatest-module:main")); + EXPECT_TRUE(translator.schemaNodeExists("/keatest-module:main/string")); + EXPECT_TRUE(translator.schemaNodeExists("/keatest-module:container/list")); +} + } // anonymous namespace diff --git a/src/lib/yang/tests/translator_utils_unittests.cc b/src/lib/yang/tests/translator_utils_unittests.cc index a4593cd052..753ca0303f 100644 --- a/src/lib/yang/tests/translator_utils_unittests.cc +++ b/src/lib/yang/tests/translator_utils_unittests.cc @@ -9,6 +9,7 @@ #include <gtest/gtest.h> #include <testutils/gtest_utils.h> +#include <yang/testutils/translator_test.h> #include <yang/tests/sysrepo_setup.h> #include <yang/tests/yang_configs.h> diff --git a/src/lib/yang/tests/yang_configs.h b/src/lib/yang/tests/yang_configs.h index bd9a6b1eb6..994a8939ed 100644 --- a/src/lib/yang/tests/yang_configs.h +++ b/src/lib/yang/tests/yang_configs.h @@ -641,4 +641,4 @@ const std::vector<std::pair<std::string, YRTree> > TEST_CONFIGS = } // namespace yang } // namespace isc -#endif // ISC_YANG_CONFIGS_H +#endif // ISC_YANG_CONFIGS_H diff --git a/src/lib/yang/testutils/translator_test.cc b/src/lib/yang/testutils/translator_test.cc index ca6f09a1b6..aa0e1ca8a9 100644 --- a/src/lib/yang/testutils/translator_test.cc +++ b/src/lib/yang/testutils/translator_test.cc @@ -104,7 +104,7 @@ YangRepr::YangReprItem::get(const string& xpath, Session session) { val_xpath = string(data_node->path()); } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error in YangReprItem: " << ex.what()); + "in YangReprItem: " << ex.what()); } return (YangReprItem(val_xpath, value, type, settable)); } @@ -121,7 +121,7 @@ YangRepr::get(Session session) const { }); } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error in YangRepr::getTree: " << ex.what()); + "in YangRepr::getTree: " << ex.what()); } return (result); } @@ -186,7 +186,7 @@ YangRepr::set(const Tree& tree, Session session) const { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error in YangRepr::set for " << item + "in YangRepr::set for " << item << ", error: " << ex.what()); } } diff --git a/src/lib/yang/testutils/translator_test.h b/src/lib/yang/testutils/translator_test.h index fa7a26a35d..00b0702ec0 100644 --- a/src/lib/yang/testutils/translator_test.h +++ b/src/lib/yang/testutils/translator_test.h @@ -159,4 +159,4 @@ std::ostream& operator<<(std::ostream& os, const YRTree& tree); } // namespace yang } // namespace isc -#endif // ISC_TRANSLATOR_TEST_H +#endif // ISC_TRANSLATOR_TEST_H diff --git a/src/lib/yang/translator.cc b/src/lib/yang/translator.cc index 5b432503fd..1bb4485ffd 100644 --- a/src/lib/yang/translator.cc +++ b/src/lib/yang/translator.cc @@ -124,15 +124,6 @@ Translator::decode64(string const& input) { void Translator::deleteItem(string const& xpath) { - /// @todo: Remove this if convenient. It is not strictly required and only done to detect - /// missing schema nodes and throw an exception to keep old behavior. - try { - Context const& context(session_.getContext()); - context.findPath(xpath); - } catch (libyang::Error const& ex) { - isc_throw(NetconfError, "sysrepo error getting item at '" << xpath - << "': " << ex.what()); - } try { if (session_.getData(xpath)) { @@ -140,7 +131,7 @@ Translator::deleteItem(string const& xpath) { } } catch (sysrepo::Error const& ex) { isc_throw(NetconfError, - "sysrepo error deleting item at '" + "deleting item at '" << xpath << "': " << ex.what()); } session_.applyChanges(); @@ -170,21 +161,11 @@ Translator::findXPath(string const& xpath) { optional<DataNode> Translator::getData(string const& xpath) const { - /// @todo: Remove this if convenient. It is not strictly required and only done to detect - /// missing schema nodes and throw an exception to keep old behavior. - try { - Context const& context(session_.getContext()); - context.findPath(xpath); - } catch (libyang::Error const& ex) { - isc_throw(NetconfError, "sysrepo error getting item at '" << xpath - << "': " << ex.what()); - } - optional<DataNode> data_node; try { data_node = session_.getData(xpath); } catch (sysrepo::Error const& ex) { - isc_throw(NetconfError, "sysrepo error getting item at '" << xpath + isc_throw(NetconfError, "getting item at '" << xpath << "': " << ex.what()); } @@ -202,27 +183,23 @@ Translator::getItem(DataNode const& data_node, DataNode const& front(nodes.front()); NodeType const node_type(front.schema().nodeType()); - // Leaf-list - if (node_type == NodeType::Leaflist) { + // Leaf + if (node_type == NodeType::Leaf) { + return translateFromYang(front); + } else if (node_type == NodeType::Leaflist) { ElementPtr result(Element::createList()); for (DataNode const& i : nodes) { result->add(translateFromYang(i)); } return result; - } else if (node_type == NodeType::Container) { - /// @todo: - /// isc_throw(NetconfError, "getting containers not supported, xpath is '" << xpath << "'"); - return ElementPtr(); - } else if (node_type == NodeType::List) { - /// @todo: - /// isc_throw(NetconfError, "getting lists not supported, xpath is '" << xpath << "'"); - return ElementPtr(); + } else { + isc_throw(NotImplemented, "getting node of type " + << int(node_type) << " not supported, xpath is '" << xpath + << "'"); } - // Leaf - return translateFromYang(front); } catch (sysrepo::Error const& ex) { - isc_throw(NetconfError, "sysrepo error getting item at '" << xpath + isc_throw(NetconfError, "getting item at '" << xpath << "': " << ex.what()); } } @@ -231,8 +208,6 @@ ElementPtr Translator::getItemFromAbsoluteXpath(string const& xpath) const { optional<DataNode> const& data_node(getData(xpath)); if (!data_node) { - /// @todo: - /// isc_throw(NetconfError, "no data "); return ElementPtr(); } return getItem(*data_node, xpath); @@ -315,6 +290,17 @@ Translator::initializeSerializer() { return result; } + +bool Translator::schemaNodeExists(std::string const& xpath) { + Context const& context(session_.getContext()); + try { + context.findPath(xpath); + } catch (libyang::Error const& ex) { + return false; + } + return true; +} + void Translator::setItem(const string& xpath, ConstElementPtr elem, LeafBaseType type) { @@ -322,7 +308,7 @@ Translator::setItem(const string& xpath, ConstElementPtr elem, try { session_.setItem(xpath, value); } catch (sysrepo::Error const& ex) { - isc_throw(NetconfError, "sysrepo error setting item '" << (elem ? elem->str() : "nullopt") + isc_throw(NetconfError, "setting item '" << (elem ? elem->str() : "nullopt") << "' at '" << xpath << "': " << ex.what()); } session_.applyChanges(); @@ -381,10 +367,8 @@ Translator::translateToYang(ConstElementPtr const& element, // keys in sysrepo since setting the key itself results in an error. return nullopt; } else if (element->getType() == Element::map) { - /// @todo: implement isc_throw(NotImplemented, "Translator::value(): map element"); } else if (element->getType() == Element::list) { - /// @todo: implement isc_throw(NotImplemented, "Translator::value(): list element"); } else if (element->getType() == Element::string) { // If it's a string, get the variant wthout quotes. diff --git a/src/lib/yang/translator.h b/src/lib/yang/translator.h index 8c49aad1c8..73ff541151 100644 --- a/src/lib/yang/translator.h +++ b/src/lib/yang/translator.h @@ -165,6 +165,13 @@ public: } } + /// @brief Checks whether a YANG node exists in the schema. + /// + /// @param xpath the xpath to be checked + /// + /// @return true if the YANG node exists in the schema, false otherwise + bool schemaNodeExists(std::string const& xpath); + /// @brief Get a YANG data node found at the given absolute xpath. /// /// @note This is a computationally expensive operation that makes a lookup in the sysrepo @@ -230,7 +237,7 @@ public: } return result; } catch (libyang::Error const& ex) { - isc_throw(NetconfError, "sysrepo error getting item: " << ex.what()); + isc_throw(NetconfError, "getting item: " << ex.what()); } } @@ -364,4 +371,4 @@ protected: } // namespace yang } // namespace isc -#endif // ISC_TRANSLATOR_H +#endif // ISC_TRANSLATOR_H diff --git a/src/lib/yang/translator_class.cc b/src/lib/yang/translator_class.cc index 18e56b6ed9..6419b861e6 100644 --- a/src/lib/yang/translator_class.cc +++ b/src/lib/yang/translator_class.cc @@ -36,7 +36,7 @@ TranslatorClass::getClass(DataNode const& data_node) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error getting client class:" + "getting client class:" << ex.what()); } isc_throw(NotImplemented, @@ -101,7 +101,7 @@ TranslatorClass::setClass(string const& xpath, ConstElementPtr elem) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting client class '" << elem->str() + "setting client class '" << elem->str() << "' : " << ex.what()); } } @@ -159,7 +159,7 @@ TranslatorClasses::getClasses(DataNode const& data_node) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error getting client classes:" + "getting client classes:" << ex.what()); } isc_throw(NotImplemented, @@ -193,7 +193,7 @@ TranslatorClasses::setClasses(string const& xpath, ConstElementPtr elem) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting client classes '" << elem->str() + "setting client classes '" << elem->str() << "' : " << ex.what()); } } diff --git a/src/lib/yang/translator_class.h b/src/lib/yang/translator_class.h index 851851f4d9..5b2b7f6cc4 100644 --- a/src/lib/yang/translator_class.h +++ b/src/lib/yang/translator_class.h @@ -200,4 +200,4 @@ protected: } // namespace yang } // namespace isc -#endif // ISC_TRANSLATOR_CLASS_H +#endif // ISC_TRANSLATOR_CLASS_H diff --git a/src/lib/yang/translator_config.cc b/src/lib/yang/translator_config.cc index a74d5eb54e..feff99ad32 100644 --- a/src/lib/yang/translator_config.cc +++ b/src/lib/yang/translator_config.cc @@ -56,7 +56,7 @@ TranslatorConfig::getConfig() { return (getConfigKea6()); } } catch (Error const& ex) { - isc_throw(NetconfError, "sysrepo error getting config: " << ex.what()); + isc_throw(NetconfError, "getting config: " << ex.what()); } isc_throw(NotImplemented, "getConfig not implemented for the model: " << model_); @@ -462,7 +462,7 @@ TranslatorConfig::setConfig(ConstElementPtr elem) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting config '" << elem->str() + "setting config '" << elem->str() << "': " << ex.what()); } } diff --git a/src/lib/yang/translator_config.h b/src/lib/yang/translator_config.h index 911d2ef726..9741f7c512 100644 --- a/src/lib/yang/translator_config.h +++ b/src/lib/yang/translator_config.h @@ -553,4 +553,4 @@ protected: } // namespace yang } // namespace isc -#endif // ISC_TRANSLATOR_CONFIG_H +#endif // ISC_TRANSLATOR_CONFIG_H diff --git a/src/lib/yang/translator_control_socket.cc b/src/lib/yang/translator_control_socket.cc index 2f1d3f1bea..e3dabdf6ff 100644 --- a/src/lib/yang/translator_control_socket.cc +++ b/src/lib/yang/translator_control_socket.cc @@ -35,7 +35,7 @@ TranslatorControlSocket::getControlSocket(DataNode const& data_node) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error getting control socket: " << ex.what()); + "getting control socket: " << ex.what()); } isc_throw(NotImplemented, "getControlSocket not implemented for the model: " << model_); @@ -75,7 +75,7 @@ TranslatorControlSocket::setControlSocket(string const& xpath, } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting control socket '" << elem->str() + "setting control socket '" << elem->str() << "' at '" << xpath << "': " << ex.what()); } } diff --git a/src/lib/yang/translator_control_socket.h b/src/lib/yang/translator_control_socket.h index 5b591c110b..f2602c734b 100644 --- a/src/lib/yang/translator_control_socket.h +++ b/src/lib/yang/translator_control_socket.h @@ -131,4 +131,4 @@ protected: } // namespace yang } // namespace isc -#endif // ISC_TRANSLATOR_CONTROL_SOCKET_H +#endif // ISC_TRANSLATOR_CONTROL_SOCKET_H diff --git a/src/lib/yang/translator_database.cc b/src/lib/yang/translator_database.cc index f3945497b1..dabb339564 100644 --- a/src/lib/yang/translator_database.cc +++ b/src/lib/yang/translator_database.cc @@ -32,7 +32,7 @@ TranslatorDatabase::getDatabase(DataNode const& data_node) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error getting database access: " << ex.what()); + "getting database access: " << ex.what()); } isc_throw(NotImplemented, "getDatabase not implemented for the model: " << model_); @@ -90,7 +90,7 @@ TranslatorDatabase::setDatabase(string const& xpath, } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting database access '" << elem->str() + "setting database access '" << elem->str() << "' : " << ex.what()); } } @@ -145,7 +145,7 @@ TranslatorDatabases::getDatabases(DataNode const& data_node, } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error getting database accesses: " << ex.what()); + "getting database accesses: " << ex.what()); } isc_throw(NotImplemented, "getDatabases not implemented for the model: " << model_); @@ -179,7 +179,7 @@ TranslatorDatabases::setDatabases(string const& xpath, ConstElementPtr elem) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting database accesses '" << elem->str() + "setting database accesses '" << elem->str() << "' : " << ex.what()); } } diff --git a/src/lib/yang/translator_database.h b/src/lib/yang/translator_database.h index 3e890f891e..6fca6aae7a 100644 --- a/src/lib/yang/translator_database.h +++ b/src/lib/yang/translator_database.h @@ -241,4 +241,4 @@ protected: } // namespace yang } // namespace isc -#endif // ISC_TRANSLATOR_DATABASE_H +#endif // ISC_TRANSLATOR_DATABASE_H diff --git a/src/lib/yang/translator_host.cc b/src/lib/yang/translator_host.cc index 9292ccd442..a71e40e95b 100644 --- a/src/lib/yang/translator_host.cc +++ b/src/lib/yang/translator_host.cc @@ -34,7 +34,7 @@ TranslatorHost::getHost(DataNode const& data_node) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error getting host reservation:" + "getting host reservation:" << ex.what()); } isc_throw(NotImplemented, @@ -95,7 +95,7 @@ TranslatorHost::setHost(string const& xpath, ConstElementPtr elem) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting host reservation '" << elem->str() + "setting host reservation '" << elem->str() << "' : " << ex.what()); } } @@ -161,7 +161,7 @@ TranslatorHosts::setHosts(string const& xpath, ConstElementPtr elem) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting host reservations '" << elem->str() + "setting host reservations '" << elem->str() << "' : " << ex.what()); } } diff --git a/src/lib/yang/translator_host.h b/src/lib/yang/translator_host.h index 65f169bfa2..2236b14c4a 100644 --- a/src/lib/yang/translator_host.h +++ b/src/lib/yang/translator_host.h @@ -226,4 +226,4 @@ protected: } // namespace yang } // namespace isc -#endif // ISC_TRANSLATOR_HOST_H +#endif // ISC_TRANSLATOR_HOST_H diff --git a/src/lib/yang/translator_logger.cc b/src/lib/yang/translator_logger.cc index 74b0114991..87417d36cf 100644 --- a/src/lib/yang/translator_logger.cc +++ b/src/lib/yang/translator_logger.cc @@ -34,7 +34,7 @@ TranslatorLogger::getLogger(DataNode const& data_node) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error getting logger: " << ex.what()); + "getting logger: " << ex.what()); } isc_throw(NotImplemented, "getLogger not implemented for the model: " << model_); @@ -93,7 +93,7 @@ TranslatorLogger::setLogger(string const& xpath, ConstElementPtr elem) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting logger '" << elem->str() + "setting logger '" << elem->str() << "' : " << ex.what()); } } @@ -154,7 +154,7 @@ TranslatorLoggers::getLoggers(DataNode const& data_node) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error getting loggers: " << ex.what()); + "getting loggers: " << ex.what()); } isc_throw(NotImplemented, "getLoggers not implemented for the model: " << model_); @@ -189,7 +189,7 @@ TranslatorLoggers::setLoggers(string const& xpath, ConstElementPtr elem) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting loggers '" << elem->str() + "setting loggers '" << elem->str() << "' : " << ex.what()); } } diff --git a/src/lib/yang/translator_logger.h b/src/lib/yang/translator_logger.h index 7629fab638..6d54dc4b25 100644 --- a/src/lib/yang/translator_logger.h +++ b/src/lib/yang/translator_logger.h @@ -230,4 +230,4 @@ protected: } // namespace yang } // namespace isc -#endif // ISC_TRANSLATOR_LOGGER_H +#endif // ISC_TRANSLATOR_LOGGER_H diff --git a/src/lib/yang/translator_option_data.cc b/src/lib/yang/translator_option_data.cc index 34e7fd26bb..3595815c48 100644 --- a/src/lib/yang/translator_option_data.cc +++ b/src/lib/yang/translator_option_data.cc @@ -33,7 +33,7 @@ TranslatorOptionData::getOptionData(DataNode const& data_node) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error getting option data:" + "getting option data:" << ex.what()); } isc_throw(NotImplemented, @@ -80,7 +80,7 @@ TranslatorOptionData::setOptionData(string const& xpath, } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting option data '" << elem->str() + "setting option data '" << elem->str() << "' : " << ex.what()); } } @@ -113,7 +113,7 @@ TranslatorOptionDataList::getOptionDataList(DataNode const& data_node) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error getting option data list:" + "getting option data list:" << ex.what()); } isc_throw(NotImplemented, @@ -149,7 +149,7 @@ TranslatorOptionDataList::setOptionDataList(string const& xpath, } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting option data list '" << elem->str() + "setting option data list '" << elem->str() << "' : " << ex.what()); } } diff --git a/src/lib/yang/translator_option_data.h b/src/lib/yang/translator_option_data.h index 2bdfd7f1d1..cd57b36618 100644 --- a/src/lib/yang/translator_option_data.h +++ b/src/lib/yang/translator_option_data.h @@ -187,4 +187,4 @@ protected: } // namespace yang } // namespace isc -#endif // ISC_TRANSLATOR_OPTION_DATA_H +#endif // ISC_TRANSLATOR_OPTION_DATA_H diff --git a/src/lib/yang/translator_option_def.cc b/src/lib/yang/translator_option_def.cc index f354a6812a..cdacd2d6cd 100644 --- a/src/lib/yang/translator_option_def.cc +++ b/src/lib/yang/translator_option_def.cc @@ -33,7 +33,7 @@ TranslatorOptionDef::getOptionDef(DataNode const& data_node) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error getting option definition:" + "getting option definition:" << ex.what()); } isc_throw(NotImplemented, @@ -80,7 +80,7 @@ TranslatorOptionDef::setOptionDef(string const& xpath, ConstElementPtr elem) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting option definition '" << elem->str() + "setting option definition '" << elem->str() << "' : " << ex.what()); } } @@ -115,7 +115,7 @@ TranslatorOptionDefList::getOptionDefList(DataNode const& data_node) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error getting option definition list:" + "getting option definition list:" << ex.what()); } isc_throw(NotImplemented, @@ -151,7 +151,7 @@ TranslatorOptionDefList::setOptionDefList(string const& xpath, } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting option definition list '" + "setting option definition list '" << elem->str() << "' : " << ex.what()); } } diff --git a/src/lib/yang/translator_option_def.h b/src/lib/yang/translator_option_def.h index a1caa11bd4..700cdd8b0a 100644 --- a/src/lib/yang/translator_option_def.h +++ b/src/lib/yang/translator_option_def.h @@ -196,4 +196,4 @@ protected: } // namespace yang } // namespace isc -#endif // ISC_TRANSLATOR_OPTION_DEF_H +#endif // ISC_TRANSLATOR_OPTION_DEF_H diff --git a/src/lib/yang/translator_pd_pool.cc b/src/lib/yang/translator_pd_pool.cc index 92bc0e6081..5ea621b6d2 100644 --- a/src/lib/yang/translator_pd_pool.cc +++ b/src/lib/yang/translator_pd_pool.cc @@ -37,7 +37,7 @@ TranslatorPdPool::getPdPool(DataNode const& data_node) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error getting pd-pool:" + "getting pd-pool:" << ex.what()); } isc_throw(NotImplemented, @@ -174,7 +174,7 @@ TranslatorPdPool::setPdPool(string const& xpath, ConstElementPtr elem) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting pd-pool '" << elem->str() + "setting pd-pool '" << elem->str() << "' : " << ex.what()); } } @@ -201,7 +201,7 @@ TranslatorPdPool::setPdPoolIetf6(string const& xpath, ConstElementPtr elem) { checkAndSetDivergingLeaf(elem, xpath, "renew-timer", "renew-time", LeafBaseType::Uint32); // Set max pd space utilization to disabled. - setItem(xpath + "/max-pd-space-utilization", Element::create(string("disabled")), + setItem(xpath + "/max-pd-space-utilization", Element::create("disabled"), LeafBaseType::Enum); // Skip rapid-commit. @@ -249,7 +249,7 @@ TranslatorPdPools::getPdPools(DataNode const& data_node) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error getting pd-pools:" + "getting pd-pools:" << ex.what()); } isc_throw(NotImplemented, @@ -284,7 +284,7 @@ TranslatorPdPools::setPdPools(string const& xpath, ConstElementPtr elem) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting pools '" << elem->str() + "setting pools '" << elem->str() << "' : " << ex.what()); } } diff --git a/src/lib/yang/translator_pd_pool.h b/src/lib/yang/translator_pd_pool.h index 7812209bc0..a7d0ec030b 100644 --- a/src/lib/yang/translator_pd_pool.h +++ b/src/lib/yang/translator_pd_pool.h @@ -253,4 +253,4 @@ protected: } // namespace yang } // namespace isc -#endif // ISC_TRANSLATOR_PD_POOL_H +#endif // ISC_TRANSLATOR_PD_POOL_H diff --git a/src/lib/yang/translator_pool.cc b/src/lib/yang/translator_pool.cc index 24940c73d6..e48678af92 100644 --- a/src/lib/yang/translator_pool.cc +++ b/src/lib/yang/translator_pool.cc @@ -41,7 +41,7 @@ TranslatorPool::getPool(DataNode const& data_node) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error getting pool:" + "getting pool:" << ex.what()); } isc_throw(NotImplemented, @@ -126,7 +126,7 @@ TranslatorPool::setPool(string const& xpath, ConstElementPtr elem) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting pool '" << elem->str() + "setting pool '" << elem->str() << "' : " << ex.what()); } } @@ -164,7 +164,7 @@ TranslatorPool::setPoolIetf6(string const& xpath, ConstElementPtr elem) { // Set max address count to disabled. setItem(xpath + "/max-address-count", - Element::create(string("disabled")), + Element::create("disabled"), LeafBaseType::Enum); // Skip max-addr-count. @@ -242,7 +242,7 @@ TranslatorPools::getPools(DataNode const& data_node) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error getting pools:" + "getting pools:" << ex.what()); } isc_throw(NotImplemented, @@ -284,7 +284,7 @@ TranslatorPools::setPools(string const& xpath, ConstElementPtr elem) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting pools '" << elem->str() + "setting pools '" << elem->str() << "' : " << ex.what()); } } diff --git a/src/lib/yang/translator_pool.h b/src/lib/yang/translator_pool.h index 6b5605a8d4..90b9f352f3 100644 --- a/src/lib/yang/translator_pool.h +++ b/src/lib/yang/translator_pool.h @@ -274,4 +274,4 @@ protected: } // namespace yang } // namespace isc -#endif // ISC_TRANSLATOR_POOL_H +#endif // ISC_TRANSLATOR_POOL_H diff --git a/src/lib/yang/translator_shared_network.cc b/src/lib/yang/translator_shared_network.cc index 5c2de97663..f13b661040 100644 --- a/src/lib/yang/translator_shared_network.cc +++ b/src/lib/yang/translator_shared_network.cc @@ -44,7 +44,7 @@ TranslatorSharedNetwork::getSharedNetwork(DataNode const& data_node) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error getting shared network:" + "getting shared network:" << ex.what()); } isc_throw(NotImplemented, @@ -149,7 +149,7 @@ TranslatorSharedNetwork::setSharedNetwork(string const& xpath, } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting shared network '" << elem->str() + "setting shared network '" << elem->str() << "' : " << ex.what()); } } @@ -275,7 +275,7 @@ TranslatorSharedNetworks::setSharedNetworks(string const& xpath, } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting shared networks '" << elem->str() + "setting shared networks '" << elem->str() << "' : " << ex.what()); } } diff --git a/src/lib/yang/translator_shared_network.h b/src/lib/yang/translator_shared_network.h index ec8e94740d..04f8335943 100644 --- a/src/lib/yang/translator_shared_network.h +++ b/src/lib/yang/translator_shared_network.h @@ -278,4 +278,4 @@ protected: } // namespace yang } // namespace isc -#endif // ISC_TRANSLATOR_SHARED_NETWORK_H +#endif // ISC_TRANSLATOR_SHARED_NETWORK_H diff --git a/src/lib/yang/translator_subnet.cc b/src/lib/yang/translator_subnet.cc index 6ac373d810..8288a89618 100644 --- a/src/lib/yang/translator_subnet.cc +++ b/src/lib/yang/translator_subnet.cc @@ -43,7 +43,7 @@ TranslatorSubnet::getSubnet(DataNode const& data_node) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error getting subnet:" + "getting subnet:" << ex.what()); } isc_throw(NotImplemented, @@ -201,7 +201,7 @@ TranslatorSubnet::setSubnet(string const& xpath, ConstElementPtr elem) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting subnet '" << elem->str() + "setting subnet '" << elem->str() << "' : " << ex.what()); } } @@ -357,7 +357,7 @@ TranslatorSubnets::getSubnets(DataNode const& data_node) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error getting subnets:" + "getting subnets:" << ex.what()); } isc_throw(NotImplemented, @@ -395,7 +395,7 @@ TranslatorSubnets::setSubnets(string const& xpath, ConstElementPtr elem) { } } catch (Error const& ex) { isc_throw(NetconfError, - "sysrepo error setting subnets '" << elem->str() + "setting subnets '" << elem->str() << "' : " << ex.what()); } } diff --git a/src/lib/yang/translator_subnet.h b/src/lib/yang/translator_subnet.h index 60e54b2657..b5e48d705d 100644 --- a/src/lib/yang/translator_subnet.h +++ b/src/lib/yang/translator_subnet.h @@ -408,4 +408,4 @@ protected: } // namespace yang } // namespace isc -#endif // ISC_TRANSLATOR_SUBNET_H +#endif // ISC_TRANSLATOR_SUBNET_H diff --git a/src/lib/yang/yang_models.h b/src/lib/yang/yang_models.h index d3d67e9aae..8055d5dbc0 100644 --- a/src/lib/yang/yang_models.h +++ b/src/lib/yang/yang_models.h @@ -34,4 +34,4 @@ static const std::string KEA_CTRL_AGENT = "kea-ctrl-agent"; } // namespace yang } // namespace isc -#endif // ISC_YANG_MODELS_H +#endif // ISC_YANG_MODELS_H diff --git a/src/lib/yang/yang_revisions.h b/src/lib/yang/yang_revisions.h index fade868897..b28a400804 100644 --- a/src/lib/yang/yang_revisions.h +++ b/src/lib/yang/yang_revisions.h @@ -32,4 +32,4 @@ static const std::unordered_map<std::string, std::string> YANG_REVISIONS = { } // namespace yang } // namespace isc -#endif // ISC_YANG_REVISIONS_H +#endif // ISC_YANG_REVISIONS_H diff --git a/src/lib/yang/yang_revisions.h.skel b/src/lib/yang/yang_revisions.h.skel index 7acf0ff2ab..826f26eb78 100644 --- a/src/lib/yang/yang_revisions.h.skel +++ b/src/lib/yang/yang_revisions.h.skel @@ -24,4 +24,4 @@ static const std::unordered_map<std::string, std::string> YANG_REVISIONS = { } // namespace yang } // namespace isc -#endif // ISC_YANG_REVISIONS_H +#endif // ISC_YANG_REVISIONS_H |