Commit 8354fff5 authored by Francis Dupont's avatar Francis Dupont

[65-libyang-class] Fixed rebased errors

parent 67444792
......@@ -7,6 +7,7 @@
#include <config.h>
#include <yang/translator_class.h>
#include <yang/yang_models.h>
#include <yang/tests/sysrepo_setup.h>
#include <gtest/gtest.h>
......@@ -38,7 +39,7 @@ public:
// This test verifies that an empty client class list can be properly
// translated from YANG to JSON.
TEST_F(TranslatorClassesTest, getEmpty) {
useModel("kea-dhcp4-server");
useModel(KEA_DHCP4_SERVER);
// Get the client class list and checks it is empty.
const string& xpath = "/kea-dhcp4-server:config/client-classes";
......@@ -50,7 +51,7 @@ TEST_F(TranslatorClassesTest, getEmpty) {
// This test verifies that one client class can be properly translated
// from YANG to JSON.
TEST_F(TranslatorClassesTest, get) {
useModel("kea-dhcp6-server");
useModel(KEA_DHCP6_SERVER);
// Create the client class.
const string& xpath = "/kea-dhcp6-server:config/client-classes";
......@@ -80,7 +81,7 @@ TEST_F(TranslatorClassesTest, get) {
// This test verifies that an empty client class list can be properly
// translated from JSON to YANG.
TEST_F(TranslatorClassesTest, setEmpty) {
useModel("kea-dhcp4-server");
useModel(KEA_DHCP4_SERVER);
// Set empty list.
const string& xpath = "/kea-dhcp4-server:config/client-classes";
......@@ -101,7 +102,7 @@ TEST_F(TranslatorClassesTest, setEmpty) {
// This test verifies that one client class can be properly translated
// from JSON to YANG.
TEST_F(TranslatorClassesTest, set) {
useModel("kea-dhcp6-server");
useModel(KEA_DHCP6_SERVER);
// Set one client class.
const string& xpath = "/kea-dhcp6-server:config/client-classes";
......
......@@ -6,6 +6,7 @@
#include <yang/translator_class.h>
#include <yang/adaptor.h>
#include <yang/yang_models.h>
#include <sstream>
using namespace std;
......@@ -29,8 +30,8 @@ TranslatorClass::~TranslatorClass() {
ElementPtr
TranslatorClass::getClass(const string& xpath) {
try {
if ((model_ == "kea-dhcp4-server") ||
(model_ == "kea-dhcp6-server")) {
if ((model_ == KEA_DHCP4_SERVER) ||
(model_ == KEA_DHCP6_SERVER)) {
return (getClassKea(xpath));
}
} catch (const sysrepo_exception& ex) {
......@@ -63,7 +64,7 @@ TranslatorClass::getClassKea(const string& xpath) {
if (options && (options->size() > 0)) {
result->set("option-data", options);
}
if (model_ == "kea-dhcp4-server") {
if (model_ == KEA_DHCP4_SERVER) {
ConstElementPtr defs = getOptionDefList(xpath +"/option-def-list");
if (defs && (defs->size() > 0)) {
result->set("option-def", defs);
......@@ -91,8 +92,8 @@ TranslatorClass::getClassKea(const string& xpath) {
void
TranslatorClass::setClass(const string& xpath, ConstElementPtr elem) {
try {
if ((model_ == "kea-dhcp4-server") ||
(model_ == "kea-dhcp6-server")) {
if ((model_ == KEA_DHCP4_SERVER) ||
(model_ == KEA_DHCP6_SERVER)) {
setClassKea(xpath, elem);
} else {
isc_throw(NotImplemented,
......@@ -124,7 +125,7 @@ TranslatorClass::setClassKea(const string& xpath, ConstElementPtr elem) {
setOptionDataList(xpath + "/option-data-list", options);
created = true;
}
if (model_ == "kea-dhcp4-server") {
if (model_ == KEA_DHCP4_SERVER) {
ConstElementPtr defs = elem->get("option-def");
if (defs) {
setOptionDefList(xpath + "/option-def-list", defs);
......@@ -175,8 +176,8 @@ TranslatorClasses::~TranslatorClasses() {
ConstElementPtr
TranslatorClasses::getClasses(const string& xpath) {
try {
if ((model_ == "kea-dhcp4-server") ||
(model_ == "kea-dhcp6-server")) {
if ((model_ == KEA_DHCP4_SERVER) ||
(model_ == KEA_DHCP6_SERVER)) {
return (getClassesKea(xpath));
}
} catch (const sysrepo_exception& ex) {
......@@ -213,8 +214,8 @@ TranslatorClasses::getClassesKea(const string& xpath) {
void
TranslatorClasses::setClasses(const string& xpath, ConstElementPtr elem) {
try {
if ((model_ == "kea-dhcp4-server") ||
(model_ == "kea-dhcp6-server")) {
if ((model_ == KEA_DHCP4_SERVER) ||
(model_ == KEA_DHCP6_SERVER)) {
setClassesKea(xpath, elem);
} else {
isc_throw(NotImplemented,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment