Skip to content

Commit

Permalink
Resolved issue #891
Browse files Browse the repository at this point in the history
  • Loading branch information
ygorelik authored and Abhi Keshav committed May 15, 2019
1 parent 7ea363f commit fb66e31
Show file tree
Hide file tree
Showing 18 changed files with 180 additions and 143 deletions.
4 changes: 2 additions & 2 deletions sdk/cpp/tests/test_executor_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ TEST_CASE("es_edit_config_rpc")

// runner and filter
auto runner = make_shared<ydktest_sanity::Runner>();
runner->ydktest_sanity_one->number = 1;
runner->ydktest_sanity_one->name = "runner:one:name";
runner->one->number = 1;
runner->one->name = "runner:one:name";
std::string runner_xml = codec_service.encode(codec_provider, *runner, true);

auto filter = make_unique<ydktest_sanity::Runner>();
Expand Down
4 changes: 2 additions & 2 deletions sdk/cpp/tests/test_sanity_codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ TEST_CASE("encode_decode")

ydktest_sanity::Runner * entity_ptr = dynamic_cast<ydktest_sanity::Runner*>(redecode.get());
auto runner = std::make_unique<ydktest_sanity::Runner>();
runner->ydktest_sanity_one->name = "test";
runner->one->name = "test";

CHECK(entity_ptr->ydktest_sanity_one->name == runner->ydktest_sanity_one->name);
CHECK(entity_ptr->one->name == runner->one->name);
}

TEST_CASE("multiple_bundles_codec")
Expand Down
52 changes: 26 additions & 26 deletions sdk/cpp/tests/test_sanity_levels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,38 @@ TEST_CASE("one_level_pos")
bool reply = crud.delete_(provider, *r_1);
REQUIRE(reply);

auto ydktest_sanity_one = make_unique<ydktest_sanity::Runner::YdktestSanityOne>();
ydktest_sanity_one->number = 1;
ydktest_sanity_one->name = "1.2.3.4";
reply = crud.create(provider, *ydktest_sanity_one);
auto one = make_unique<ydktest_sanity::Runner::One>();
one->number = 1;
one->name = "1.2.3.4";
reply = crud.create(provider, *one);
REQUIRE(reply);

auto filter = make_unique<ydktest_sanity::Runner>();
auto sanity_one_filter = filter->ydktest_sanity_one;
auto sanity_one_filter = filter->one;
auto r_2 = crud.read(provider, *sanity_one_filter);
REQUIRE(r_2!=nullptr);
auto * r_2_ptr = dynamic_cast<ydktest_sanity::Runner::YdktestSanityOne*>(r_2.get());
auto * r_2_ptr = dynamic_cast<ydktest_sanity::Runner::One*>(r_2.get());
REQUIRE(r_2_ptr!=nullptr);

REQUIRE(ydktest_sanity_one->number == r_2_ptr->number);
REQUIRE(ydktest_sanity_one->name == r_2_ptr->name);
REQUIRE(one->number == r_2_ptr->number);
REQUIRE(one->name == r_2_ptr->name);

//UPDATE
ydktest_sanity_one->number = 10;
ydktest_sanity_one->name = "runner/one/name";
reply = crud.update(provider, *ydktest_sanity_one);
one->number = 10;
one->name = "runner/one/name";
reply = crud.update(provider, *one);
REQUIRE(reply);

r_2 = crud.read(provider, *sanity_one_filter);
REQUIRE(r_2!=nullptr);
r_2_ptr = dynamic_cast<ydktest_sanity::Runner::YdktestSanityOne*>(r_2.get());
r_2_ptr = dynamic_cast<ydktest_sanity::Runner::One*>(r_2.get());
REQUIRE(r_2_ptr!=nullptr);

REQUIRE(ydktest_sanity_one->number == r_2_ptr->number);
REQUIRE(ydktest_sanity_one->name == r_2_ptr->name);
REQUIRE(one->number == r_2_ptr->number);
REQUIRE(one->name == r_2_ptr->name);

// DELETE
reply = crud.delete_(provider, *ydktest_sanity_one);
reply = crud.delete_(provider, *one);
REQUIRE(reply);
}

Expand Down Expand Up @@ -527,7 +527,7 @@ TEST_CASE("test_leafref_pos")
REQUIRE(reply);

//CREATE
r_1->ydktest_sanity_one->name = "1.2.3.4";
r_1->one->name = "1.2.3.4";
r_1->two->sub1->number = 21;
r_1->three->sub1->sub2->number = 311;
auto e_1 = make_shared<ydktest_sanity::Runner::InbtwList::Ldata>();
Expand Down Expand Up @@ -567,8 +567,8 @@ TEST_CASE("test_leafref_pos")
auto r_filter = make_unique<ydktest_sanity::Runner>();
auto r_read = crud.read(provider, *r_filter);
ydktest_sanity::Runner* r_2 = dynamic_cast<ydktest_sanity::Runner*>(r_read.get());
REQUIRE(r_1->ydktest_sanity_one->name == r_2->ydktest_sanity_one->name);
REQUIRE(r_1->ydktest_sanity_one->number == r_2->ydktest_sanity_one->number);
REQUIRE(r_1->one->name == r_2->one->name);
REQUIRE(r_1->one->number == r_2->one->number);

auto ldata0 = dynamic_cast<ydktest_sanity::Runner::InbtwList::Ldata*> (r_2->inbtw_list->ldata[0].get());
auto ldata1 = dynamic_cast<ydktest_sanity::Runner::InbtwList::Ldata*> (r_2->inbtw_list->ldata[1].get());
Expand All @@ -593,8 +593,8 @@ TEST_CASE("aug_one_pos")
REQUIRE(reply);

//CREATE
r_1->ydktest_sanity_one->one_aug->number = 1;
r_1->ydktest_sanity_one->one_aug->name = "one";
r_1->one->one_aug->number = 1;
r_1->one->one_aug->name = "one";
reply = crud.create(provider, *r_1);
REQUIRE(reply);

Expand All @@ -603,12 +603,12 @@ TEST_CASE("aug_one_pos")
auto r_read = crud.read(provider, *r_filter);
REQUIRE(r_read!=nullptr);
ydktest_sanity::Runner* r_2 = dynamic_cast<ydktest_sanity::Runner*>(r_read.get());
REQUIRE(r_1->ydktest_sanity_one->one_aug->number == r_2->ydktest_sanity_one->one_aug->number);
REQUIRE(r_1->ydktest_sanity_one->one_aug->name == r_2->ydktest_sanity_one->one_aug->name);
REQUIRE(r_1->one->one_aug->number == r_2->one->one_aug->number);
REQUIRE(r_1->one->one_aug->name == r_2->one->one_aug->name);

//UPDATE
r_1->ydktest_sanity_one->one_aug->number = 10;
r_1->ydktest_sanity_one->one_aug->name = "onenone";
r_1->one->one_aug->number = 10;
r_1->one->one_aug->name = "onenone";
reply = crud.update(provider, *r_1);
REQUIRE(reply);
}
Expand Down Expand Up @@ -683,7 +683,7 @@ TEST_CASE("aug_leaf")
REQUIRE(reply);

//CREATE
r_1->ydktest_sanity_one->augmented_leaf = "test";
r_1->one->augmented_leaf = "test";
reply = crud.create(provider, *r_1);
REQUIRE(reply);

Expand All @@ -692,7 +692,7 @@ TEST_CASE("aug_leaf")
auto r_read = crud.read(provider, *r_filter);
REQUIRE(r_read != nullptr);
ydktest_sanity::Runner* r_2 = dynamic_cast<ydktest_sanity::Runner*>(r_read.get());
REQUIRE(r_2->ydktest_sanity_one->augmented_leaf==r_1->ydktest_sanity_one->augmented_leaf);
REQUIRE(r_2->one->augmented_leaf==r_1->one->augmented_leaf);
}

TEST_CASE("oc_pattern")
Expand Down
34 changes: 28 additions & 6 deletions sdk/go/core/tests/levels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,38 @@ func (suite *SanityLevelsTestSuite) TearDownSuite() {
func (suite *SanityLevelsTestSuite) TestOneLevelPos() {
// READ
runner := ysanity.Runner{}
runner.YdktestSanityOne.Number = 1
runner.YdktestSanityOne.Name = "runner:one:name"
runner.One.Number = 1
runner.One.Name = "runner:one:name"
suite.CRUD.Create(&suite.Provider, &runner)
runnerRead := suite.CRUD.Read(&suite.Provider, &ysanity.Runner{})
suite.Equal(types.EntityEqual(&runner, runnerRead), true)

// UPDATE
runner = ysanity.Runner{}
runner.YdktestSanityOne.Number = 10
runner.YdktestSanityOne.Name = "runner/one/name"
runner.One.Number = 10
runner.One.Name = "runner/one/name"
suite.CRUD.Update(&suite.Provider, &runner)
runnerRead = suite.CRUD.Read(&suite.Provider, &ysanity.Runner{})
suite.Equal(types.EntityEqual(&runner, runnerRead), true)

// // DELETE
runner = ysanity.Runner{}
suite.CRUD.Delete(&suite.Provider, &runner)
entity := suite.CRUD.Read(&suite.Provider, &ysanity.Runner{})
suite.Nil(entity)
}

func (suite *SanityLevelsTestSuite) TestOneLevelAugPos() {
// READ
runner := ysanity.Runner{}
runner.YdktestSanityAugmOne.TwinNumber = 1000
suite.CRUD.Create(&suite.Provider, &runner)
runnerRead := suite.CRUD.Read(&suite.Provider, &ysanity.Runner{})
suite.Equal(types.EntityEqual(&runner, runnerRead), true)

// UPDATE
runner = ysanity.Runner{}
runner.YdktestSanityAugmOne.TwinNumber = 100
suite.CRUD.Update(&suite.Provider, &runner)
runnerRead = suite.CRUD.Read(&suite.Provider, &ysanity.Runner{})
suite.Equal(types.EntityEqual(&runner, runnerRead), true)
Expand Down Expand Up @@ -331,13 +353,13 @@ func (suite *SanityLevelsTestSuite) TestLeafrefSimplePos() {
}

func (suite *SanityLevelsTestSuite) TestAugOnePos() {
oneAug := ysanity.Runner_YdktestSanityOne_OneAug{}
oneAug := ysanity.Runner_One{}
oneAug.Number = 1
oneAug.Name = "runner:one:one_aug"

suite.CRUD.Create(&suite.Provider, &oneAug)

oneRead := suite.CRUD.Read(&suite.Provider, &ysanity.Runner_YdktestSanityOne_OneAug{})
oneRead := suite.CRUD.Read(&suite.Provider, &ysanity.Runner_One{})
suite.Equal(types.EntityEqual(&oneAug, oneRead), true)
}

Expand Down
6 changes: 3 additions & 3 deletions sdk/go/core/tests/service_codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,13 @@ func (suite *CodecTestSuite) TestXMLEncodeDecodeMultiple() {

func (suite *CodecTestSuite) TestPassiveInterfaceCodec() {
runner := ysanity.Runner{}
ospf := ysanity.Runner_YdktestSanityOne_Ospf{}
ospf := ysanity.Runner_One_Ospf{}
ospf.Id = 22
ospf.PassiveInterface.Interface = "xyz"
test := ysanity.Runner_YdktestSanityOne_Ospf_Test{}
test := ysanity.Runner_One_Ospf_Test{}
test.Name = "abc"
ospf.Test = append(ospf.Test, &test)
runner.YdktestSanityOne.Ospf = append(runner.YdktestSanityOne.Ospf, &ospf)
runner.One.Ospf = append(runner.One.Ospf, &ospf)
suite.Provider.Encoding = encoding.XML
payload := suite.Codec.Encode(&suite.Provider, &runner)
suite.Equal(payload,
Expand Down
20 changes: 10 additions & 10 deletions sdk/go/core/tests/service_crud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ func (suite *CrudTestSuite) BeforeTest(suiteName, testName string) {

func (suite *CrudTestSuite) TestDeleteObjectOnLeaf() {
runnerCreate := ysanity.Runner{}
runnerCreate.YdktestSanityOne.Name = "runner.YdktestSanityOne.Name"
runnerCreate.One.Name = "runner.YdktestSanityOne.Name"
runnerCreate.Two.Name = "runner.Two.Name"
suite.CRUD.Create(&suite.Provider, &runnerCreate)

// Use YFilter Delete and CRUD update to remove leaf
runnerUpdate := ysanity.Runner{}
runnerUpdate.YdktestSanityOne.Name = yfilter.Delete
runnerUpdate.One.Name = yfilter.Delete
suite.CRUD.Update(&suite.Provider, &runnerUpdate)

entityRead := suite.CRUD.Read(&suite.Provider, &ysanity.Runner{})
Expand All @@ -124,7 +124,7 @@ func (suite *CrudTestSuite) TestDeleteObjectOnLeaf() {
// TODO: leaf-list encoding error
// func (suite *CrudTestSuite) TestDeleteOnLeafListSlice() {
// runnerCreate := ysanity.Runner{}
// runnerCreate.YdktestSanityOne.Name = "runner.YdktestSanityOne.Name"
// runnerCreate.One.Name = "runner.YdktestSanityOne.Name"
// // TODO: leaf-list encoding error
// runnerCreate.Ytypes.BuiltInT.Llstring = append(runnerCreate.Ytypes.BuiltInT.Llstring, "1")
// runnerCreate.Ytypes.BuiltInT.Llstring = append(runnerCreate.Ytypes.BuiltInT.Llstring, "2")
Expand All @@ -142,7 +142,7 @@ func (suite *CrudTestSuite) TestDeleteObjectOnLeaf() {
// entityRead := suite.CRUD.Read(&suite.Provider, &ysanity.Runner{})

// runnerCmp := ysanity.Runner{}
// runnerCmp.YdktestSanityOne.Name = "runner.YdktestSanityOne.Name"
// runnerCmp.One.Name = "runner.One.Name"
// runnerCmp.Ytypes.BuiltInT.Llstring = append(runnerCmp.Ytypes.BuiltInT.Llstring, "2")
// runnerCmp.Ytypes.BuiltInT.Llstring = append(runnerCmp.Ytypes.BuiltInT.Llstring, "4")
// runnerCmp.Ytypes.BuiltInT.Llstring = append(runnerCmp.Ytypes.BuiltInT.Llstring, "5")
Expand All @@ -152,7 +152,7 @@ func (suite *CrudTestSuite) TestDeleteObjectOnLeaf() {
// TODO: delete leaf from leaf-list
// func (suite *CrudTestSuite) TestDeleteOnLeafList() {
// runnerCreate := ysanity.Runner{}
// runnerCreate.YdktestSanityOne.Name = "runner.YdktestSanityOne.Name"
// runnerCreate.One.Name = "runner.YdktestSanityOne.Name"
// runnerCreate.Ytypes.BuiltInT.Llstring = append(runnerCreate.Ytypes.BuiltInT.Llstring, "0")
// runnerCreate.Ytypes.BuiltInT.Llstring = append(runnerCreate.Ytypes.BuiltInT.Llstring, "1")
// runnerCreate.Ytypes.BuiltInT.Llstring = append(runnerCreate.Ytypes.BuiltInT.Llstring, "2")
Expand All @@ -170,7 +170,7 @@ func (suite *CrudTestSuite) TestDeleteObjectOnLeaf() {
// entityRead := suite.CRUD.Read(&suite.Provider, &ysanity.Runner{})

// runnerCmp := ysanity.Runner{}
// runnerCmp.YdktestSanityOne.Name = "runner.YdktestSanityOne.Name"
// runnerCmp.One.Name = "runner.YdktestSanityOne.Name"
// runnerCmp.Ytypes.BuiltInT.Llstring = append(runnerCmp.Ytypes.BuiltInT.Llstring, "0")
// runnerCmp.Ytypes.BuiltInT.Llstring = append(runnerCmp.Ytypes.BuiltInT.Llstring, "1")
// runnerCmp.Ytypes.BuiltInT.Llstring = append(runnerCmp.Ytypes.BuiltInT.Llstring, "2")
Expand All @@ -195,7 +195,7 @@ func (suite *CrudTestSuite) TestDeleteOnListWithIdentitykey() {

func (suite *CrudTestSuite) TestDeleteOnContainer() {
runnerCreate := ysanity.Runner{}
runnerCreate.YdktestSanityOne.Name = "runner.YdktestSanityOne.Name"
runnerCreate.One.Name = "runner.YdktestSanityOne.Name"
runnerCreate.Two.Name = "runner.Two.Name"
suite.CRUD.Create(&suite.Provider, &runnerCreate)

Expand All @@ -204,7 +204,7 @@ func (suite *CrudTestSuite) TestDeleteOnContainer() {
suite.CRUD.Update(&suite.Provider, &runnerUpdate)

runnerCmp := ysanity.Runner{}
runnerCmp.YdktestSanityOne.Name = "runner.YdktestSanityOne.Name"
runnerCmp.One.Name = "runner.YdktestSanityOne.Name"

entityRead := suite.CRUD.Read(&suite.Provider, &ysanity.Runner{})

Expand Down Expand Up @@ -249,7 +249,7 @@ func (suite *CrudTestSuite) TestDeleteOnListElement() {

func (suite *CrudTestSuite) TestDeleteOnListElements() {
runnerCreate := ysanity.Runner{}
runnerCreate.YdktestSanityOne.Name = "one"
runnerCreate.One.Name = "one"
foo := ysanity.Runner_OneList_Ldata{}
bar := ysanity.Runner_OneList_Ldata{}
baz := ysanity.Runner_OneList_Ldata{}
Expand Down Expand Up @@ -340,7 +340,7 @@ func (suite *CrudTestSuite) TestSanityReadConfig() {
// TODO: Delete list using YFilter
// func (suite *CrudTestSuite) TestDeleteOnList() {
// runnerCreate := ysanity.Runner{}
// runnerCreate.YdktestSanityOne.Name = "one"
// runnerCreate.One.Name = "one"
// foo := ysanity.Runner_OneList_Ldata{}
// bar := ysanity.Runner_OneList_Ldata{}
// foo.Number = 1
Expand Down
8 changes: 4 additions & 4 deletions sdk/go/core/tests/service_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func (suite *ExecutorServiceTestSuite) TestEditCommitGet() {
suite.CodecProvider.Encoding = encoding.XML

runner := ysanity.Runner{}
runner.YdktestSanityOne.Number = 1
runner.YdktestSanityOne.Name = "runner:one:name"
runner.One.Number = 1
runner.One.Name = "runner:one:name"
runnerXML := suite.CodecService.Encode(&suite.CodecProvider, &runner)

// Edit Config
Expand Down Expand Up @@ -123,8 +123,8 @@ func (suite *ExecutorServiceTestSuite) TestValidate() {

suite.CodecProvider.Encoding = encoding.XML
runner := ysanity.Runner{}
runner.YdktestSanityOne.Number = 1
runner.YdktestSanityOne.Name = "runner:one:name"
runner.One.Number = 1
runner.One.Name = "runner:one:name"
runnerXML := suite.CodecService.Encode(&suite.CodecProvider, &runner)

rpc = ietfNetconf.Validate{}
Expand Down
8 changes: 4 additions & 4 deletions sdk/go/core/tests/service_netconf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func (suite *NetconfServiceTestSuite) BeforeTest(suiteName, testName string) {

func (suite *NetconfServiceTestSuite) TestEditCommitGet() {
runner := ysanity.Runner{}
runner.YdktestSanityOne.Number = 1
runner.YdktestSanityOne.Name = "runner:one:name"
runner.One.Number = 1
runner.One.Name = "runner:one:name"

// Edit Config
op := suite.NS.EditConfig(&suite.Provider, datastore.Candidate, &runner, "", "", "")
Expand Down Expand Up @@ -95,8 +95,8 @@ func (suite *NetconfServiceTestSuite) TestValidate() {
suite.Equal(op, true)

runner := ysanity.Runner{}
runner.YdktestSanityOne.Number = 1
runner.YdktestSanityOne.Name = "runner:one:name"
runner.One.Number = 1
runner.One.Name = "runner:one:name"
op = suite.NS.Validate(&suite.Provider, datastore.NotSet, &runner, "")
suite.Equal(op, true)
}
Expand Down
Loading

0 comments on commit fb66e31

Please sign in to comment.