const string& xnetwork3 = xpath + "/shared-network[name='baz']";
const string& exp_net1 =
- "{ \"name\": \"foo\", \"subnet6\": [ { \"id\": 1, \"subnet\": "
- "\"2001:db8:1::/48\" }, { \"id\": 2, \"subnet\": \"2001:db8:2::/48\" } ] }";
+ "{ \"name\": \"foo\", \"subnet6\": [ { \"id\": 1, "
+ "\"subnet\": \"2001:db8:1::/48\" }, "
+ "{ \"id\": 2, \"subnet\": \"2001:db8:2::/48\" } ] }";
const string& exp_net2 =
- "{ \"name\": \"bar\", \"subnet6\": [ { \"id\": 101, \"subnet\": "
- "\"2001:db8:101::/48\" }, { \"id\": 102, \"subnet\": \"2001:db8:102::/48\" } ] }";
+ "{ \"name\": \"bar\", \"subnet6\": [ { \"id\": 101, "
+ "\"subnet\": \"2001:db8:101::/48\" }, "
+ "{ \"id\": 102, \"subnet\": \"2001:db8:102::/48\" } ] }";
const string exp_both =
"[ " + exp_net1 + ", " + exp_net2 + " ]";
EXPECT_EQ(exp_net2, network->str());
// Check that networks with non-existent name are not returned.
- EXPECT_NO_THROW(network = t_obj_->getSharedNetwork(xnetwork3));
- EXPECT_FALSE(network) << "Unexpected shared network returned, "
- << " expected null, but got: " << network->str();
+ EXPECT_THROW(network = t_obj_->getSharedNetwork(xnetwork3), Unexpected);
// Now test returns all networks
ConstElementPtr networks;
TranslatorSharedNetwork::getSharedNetworkKea(const string& xpath,
const std::string& subsel) {
ElementPtr result = Element::createMap();
- result->set("name", getItem(xpath + "/name"));
+ ConstElementPtr name = getItem(xpath + "/name");
+ if (!name) {
+ // Can't happen as the name is the key.
+ isc_throw(Unexpected, "getSharedNetworkKea requires name: " << xpath);
+ }
+ result->set("name", name);
ConstElementPtr subnets = getSubnets(xpath + "/" + subsel);
if (subnets && (subnets->size() > 0)) {
result->set(subsel, subnets);
/// }
/// @endcode
///
-/// YANG syntax for kea-dhcp[46] is with name as the list key:
+/// YANG syntax for kea-dhcp[46]-server is with name as the list key:
/// @code
/// +--rw name string
/// +--rw valid-lifetime? uint32
isc::data::ConstElementPtr elem);
protected:
- /// @brief getSharedNetwork for kea-dhcp4-server and kea-dhcp6-server models
+ /// @brief getSharedNetwork for kea-dhcp4-server and
+ /// kea-dhcp6-server models
///
/// @param xpath The xpath of the shared network.
/// @param subsel The subnet list name (either "subnet4" or "subnet6").
isc::data::ElementPtr getSharedNetworkKea(const std::string& xpath,
const std::string& subsel);
- /// @brief setSharedNetwork for kea-dhcp4-server and kea-dhcp6-server models
+ /// @brief setSharedNetwork for kea-dhcp4-server and
+ /// kea-dhcp6-server models
///
/// @param xpath The xpath of the shared network.
/// @param elem The JSON element.
isc::data::ConstElementPtr elem);
protected:
- /// @brief setSharedNetworks for kea-dhcp[46]-server.
+ /// @brief setSharedNetworks for kea-dhcp4-server and
+ /// kea-dhcp6-server
///
/// @param xpath The xpath of the shared network list.
/// @param elem The JSON element.