Unify item creation/deletion in datastore access

All of our implementations are using the same implementation; all of the
smartness is actually in sysrepo or in libyang. As a bonus, this should
make it possible to remove regular leafs as well (backend-wise at
least).

Change-Id: I177cd233b4b699f66475eae735a659b7c8577534
diff --git a/tests/data_query.cpp b/tests/data_query.cpp
index 5adc661..f075b4b 100644
--- a/tests/data_query.cpp
+++ b/tests/data_query.cpp
@@ -46,9 +46,9 @@
 
         SECTION("example-schema:person")
         {
-            datastore.createListInstance("/example-schema:person[name='Vaclav']");
-            datastore.createListInstance("/example-schema:person[name='Tomas']");
-            datastore.createListInstance("/example-schema:person[name='Jan Novak']");
+            datastore.createItem("/example-schema:person[name='Vaclav']");
+            datastore.createItem("/example-schema:person[name='Tomas']");
+            datastore.createItem("/example-schema:person[name='Jan Novak']");
             listPath.m_nodes.push_back(dataNode_{{"example-schema"}, list_{"person"}});
             expected = {
                 {{"name", std::string{"Jan Novak"}}},
@@ -66,9 +66,9 @@
 
         SECTION("example-schema:selectedNumbers")
         {
-            datastore.createListInstance("/example-schema:selectedNumbers[value='45']");
-            datastore.createListInstance("/example-schema:selectedNumbers[value='99']");
-            datastore.createListInstance("/example-schema:selectedNumbers[value='127']");
+            datastore.createItem("/example-schema:selectedNumbers[value='45']");
+            datastore.createItem("/example-schema:selectedNumbers[value='99']");
+            datastore.createItem("/example-schema:selectedNumbers[value='127']");
             listPath.m_nodes.push_back(dataNode_{{"example-schema"}, list_{"selectedNumbers"}});
             expected = {
                 {{"value", int8_t{127}}},
@@ -79,9 +79,9 @@
 
         SECTION("example-schema:animalWithColor")
         {
-            datastore.createListInstance("/example-schema:animalWithColor[name='Dog'][color='brown']");
-            datastore.createListInstance("/example-schema:animalWithColor[name='Dog'][color='white']");
-            datastore.createListInstance("/example-schema:animalWithColor[name='Cat'][color='grey']");
+            datastore.createItem("/example-schema:animalWithColor[name='Dog'][color='brown']");
+            datastore.createItem("/example-schema:animalWithColor[name='Dog'][color='white']");
+            datastore.createItem("/example-schema:animalWithColor[name='Cat'][color='grey']");
             listPath.m_nodes.push_back(dataNode_{{"example-schema"}, list_{"animalWithColor"}});
             expected = {
                 {{"name", std::string{"Cat"}}, {"color", std::string{"grey"}}},
@@ -92,7 +92,7 @@
 
         SECTION("example-schema:animalWithColor - quotes in values")
         {
-            datastore.createListInstance("/example-schema:animalWithColor[name='D\"o\"g'][color=\"b'r'own\"]");
+            datastore.createItem("/example-schema:animalWithColor[name='D\"o\"g'][color=\"b'r'own\"]");
             listPath.m_nodes.push_back(dataNode_{{"example-schema"}, list_{"animalWithColor"}});
             expected = {
                 {{"name", std::string{"D\"o\"g"}}, {"color", std::string{"b'r'own"}}}
@@ -101,9 +101,9 @@
 
         SECTION("example-schema:ports")
         {
-            datastore.createListInstance("/example-schema:ports[name='A']");
-            datastore.createListInstance("/example-schema:ports[name='B']");
-            datastore.createListInstance("/example-schema:ports[name='E']");
+            datastore.createItem("/example-schema:ports[name='A']");
+            datastore.createItem("/example-schema:ports[name='B']");
+            datastore.createItem("/example-schema:ports[name='E']");
             listPath.m_nodes.push_back(dataNode_{{"example-schema"}, list_{"ports"}});
             expected = {
                 {{"name", enum_{"A"}}},
@@ -114,17 +114,17 @@
 
         SECTION("example-schema:org/example:people - nested list")
         {
-            datastore.createListInstance("/example-schema:org[department='accounting']");
-            datastore.createListInstance("/example-schema:org[department='sales']");
-            datastore.createListInstance("/example-schema:org[department='programmers']");
-            datastore.createListInstance("/example-schema:org[department='accounting']/people[name='Alice']");
-            datastore.createListInstance("/example-schema:org[department='accounting']/people[name='Bob']");
-            datastore.createListInstance("/example-schema:org[department='sales']/people[name='Alice']");
-            datastore.createListInstance("/example-schema:org[department='sales']/people[name='Cyril']");
-            datastore.createListInstance("/example-schema:org[department='sales']/people[name='Alice']/computers[type='laptop']");
-            datastore.createListInstance("/example-schema:org[department='sales']/people[name='Alice']/computers[type='server']");
-            datastore.createListInstance("/example-schema:org[department='sales']/people[name='Cyril']/computers[type='PC']");
-            datastore.createListInstance("/example-schema:org[department='sales']/people[name='Cyril']/computers[type='server']");
+            datastore.createItem("/example-schema:org[department='accounting']");
+            datastore.createItem("/example-schema:org[department='sales']");
+            datastore.createItem("/example-schema:org[department='programmers']");
+            datastore.createItem("/example-schema:org[department='accounting']/people[name='Alice']");
+            datastore.createItem("/example-schema:org[department='accounting']/people[name='Bob']");
+            datastore.createItem("/example-schema:org[department='sales']/people[name='Alice']");
+            datastore.createItem("/example-schema:org[department='sales']/people[name='Cyril']");
+            datastore.createItem("/example-schema:org[department='sales']/people[name='Alice']/computers[type='laptop']");
+            datastore.createItem("/example-schema:org[department='sales']/people[name='Alice']/computers[type='server']");
+            datastore.createItem("/example-schema:org[department='sales']/people[name='Cyril']/computers[type='PC']");
+            datastore.createItem("/example-schema:org[department='sales']/people[name='Cyril']/computers[type='server']");
 
             SECTION("outer list")
             {
@@ -215,8 +215,8 @@
 
         SECTION("/other-module:parking-lot/example-schema:cars - list coming from an augment")
         {
-            datastore.createListInstance("/other-module:parking-lot/example-schema:cars[id='1']");
-            datastore.createListInstance("/other-module:parking-lot/example-schema:cars[id='2']");
+            datastore.createItem("/other-module:parking-lot/example-schema:cars[id='1']");
+            datastore.createItem("/other-module:parking-lot/example-schema:cars[id='2']");
 
             listPath.m_nodes.push_back(dataNode_{{"other-module"}, container_{"parking-lot"}});
             listPath.m_nodes.push_back(dataNode_{{"example-schema"}, list_{"cars"}});
diff --git a/tests/datastore_access.cpp b/tests/datastore_access.cpp
index e9030db..bab7fac 100644
--- a/tests/datastore_access.cpp
+++ b/tests/datastore_access.cpp
@@ -133,7 +133,7 @@
     SECTION("create presence container")
     {
         REQUIRE_CALL(mock, write("/example-schema:pContainer", std::nullopt, ""s));
-        datastore.createPresenceContainer("/example-schema:pContainer");
+        datastore.createItem("/example-schema:pContainer");
         datastore.commitChanges();
     }
 
@@ -142,13 +142,13 @@
         {
             REQUIRE_CALL(mock, write("/example-schema:person[name='Nguyen']", std::nullopt, ""s));
             REQUIRE_CALL(mock, write("/example-schema:person[name='Nguyen']/name", std::nullopt, "Nguyen"s));
-            datastore.createListInstance("/example-schema:person[name='Nguyen']");
+            datastore.createItem("/example-schema:person[name='Nguyen']");
             datastore.commitChanges();
         }
         {
             REQUIRE_CALL(mock, write("/example-schema:person[name='Nguyen']", ""s, std::nullopt));
             REQUIRE_CALL(mock, write("/example-schema:person[name='Nguyen']/name", "Nguyen"s, std::nullopt));
-            datastore.deleteListInstance("/example-schema:person[name='Nguyen']");
+            datastore.deleteItem("/example-schema:person[name='Nguyen']");
             datastore.commitChanges();
         }
     }
@@ -156,15 +156,15 @@
     SECTION("deleting non-existing list keys")
     {
         tryThis<THROWS_ON_NONEXISTING_KEYS>([&]{
-            datastore.deleteListInstance("/example-schema:person[name='non existing']");
+            datastore.deleteItem("/example-schema:person[name='non existing']");
             datastore.commitChanges();
         });
     }
 
-    SECTION("accessing non-existing schema nodes")
+    SECTION("deleting non-existing schema nodes as a list")
     {
         tryThis<THROWS_ON_INVALID_SCHEMA_PATHS>([&]{
-            datastore.deleteListInstance("/example-schema:non-existing-list[xxx='non existing']");
+            datastore.deleteItem("/example-schema:non-existing-list[xxx='non existing']");
             datastore.commitChanges();
         });
     }
@@ -178,9 +178,9 @@
             REQUIRE_CALL(mock, write("/example-schema:person[name='Elfi']/name", std::nullopt, "Elfi"s));
             REQUIRE_CALL(mock, write("/example-schema:person[name='Kolafa']", std::nullopt, ""s));
             REQUIRE_CALL(mock, write("/example-schema:person[name='Kolafa']/name", std::nullopt, "Kolafa"s));
-            datastore.createListInstance("/example-schema:person[name='Dan']");
-            datastore.createListInstance("/example-schema:person[name='Elfi']");
-            datastore.createListInstance("/example-schema:person[name='Kolafa']");
+            datastore.createItem("/example-schema:person[name='Dan']");
+            datastore.createItem("/example-schema:person[name='Elfi']");
+            datastore.createItem("/example-schema:person[name='Kolafa']");
             datastore.commitChanges();
         }
 
@@ -269,9 +269,9 @@
             REQUIRE_CALL(mock, write("/example-schema:person[name='Michal']/name", std::nullopt, "Michal"s));
             REQUIRE_CALL(mock, write("/example-schema:person[name='Petr']", std::nullopt, ""s));
             REQUIRE_CALL(mock, write("/example-schema:person[name='Petr']/name", std::nullopt, "Petr"s));
-            datastore.createListInstance("/example-schema:person[name='Jan']");
-            datastore.createListInstance("/example-schema:person[name='Michal']");
-            datastore.createListInstance("/example-schema:person[name='Petr']");
+            datastore.createItem("/example-schema:person[name='Jan']");
+            datastore.createItem("/example-schema:person[name='Michal']");
+            datastore.createItem("/example-schema:person[name='Petr']");
             datastore.commitChanges();
         }
         DatastoreAccess::Tree expected{
@@ -294,7 +294,7 @@
 
         {
             REQUIRE_CALL(mock, write("/example-schema:pContainer", std::nullopt, ""s));
-            datastore.createPresenceContainer("/example-schema:pContainer");
+            datastore.createItem("/example-schema:pContainer");
             datastore.commitChanges();
         }
         expected = {
@@ -305,17 +305,17 @@
         // Make sure it's not there after we delete it
         {
             REQUIRE_CALL(mock, write("/example-schema:pContainer", ""s, std::nullopt));
-            datastore.deletePresenceContainer("/example-schema:pContainer");
+            datastore.deleteItem("/example-schema:pContainer");
             datastore.commitChanges();
         }
         expected = {};
         REQUIRE(datastore.getItems("/example-schema:pContainer") == expected);
     }
 
-    SECTION("non-existing persistent container schema node")
+    SECTION("deleting a non-existing schema node as a container or leaf")
     {
         tryThis<THROWS_ON_INVALID_SCHEMA_PATHS>([&]{
-            datastore.deletePresenceContainer("/example-schema:non-existing-presence-container");
+            datastore.deleteItem("/example-schema:non-existing-presence-container");
             datastore.commitChanges();
         });
     }
@@ -328,7 +328,7 @@
         {
             REQUIRE_CALL(mock, write("/example-schema:inventory", std::nullopt, ""s));
             REQUIRE_CALL(mock, write("/example-schema:inventory/stuff", std::nullopt, ""s));
-            datastore.createPresenceContainer("/example-schema:inventory/stuff");
+            datastore.createItem("/example-schema:inventory/stuff");
             datastore.commitChanges();
         }
         expected = {
@@ -338,7 +338,7 @@
         {
             REQUIRE_CALL(mock, write("/example-schema:inventory", ""s, std::nullopt));
             REQUIRE_CALL(mock, write("/example-schema:inventory/stuff", ""s, std::nullopt));
-            datastore.deletePresenceContainer("/example-schema:inventory/stuff");
+            datastore.deleteItem("/example-schema:inventory/stuff");
             datastore.commitChanges();
         }
         expected = {};
@@ -428,8 +428,8 @@
         DatastoreAccess::Tree expected;
         REQUIRE_CALL(mock, write("/example-schema:addresses", std::nullopt, "0.0.0.0"s));
         REQUIRE_CALL(mock, write("/example-schema:addresses", std::nullopt, "127.0.0.1"s));
-        datastore.createLeafListInstance("/example-schema:addresses[.='0.0.0.0']");
-        datastore.createLeafListInstance("/example-schema:addresses[.='127.0.0.1']");
+        datastore.createItem("/example-schema:addresses[.='0.0.0.0']");
+        datastore.createItem("/example-schema:addresses[.='127.0.0.1']");
         datastore.commitChanges();
         expected = {
             {"/example-schema:addresses", special_{SpecialValue::LeafList}},
@@ -439,7 +439,7 @@
         REQUIRE(datastore.getItems("/example-schema:addresses") == expected);
 
         REQUIRE_CALL(mock, write("/example-schema:addresses", "0.0.0.0"s, std::nullopt));
-        datastore.deleteLeafListInstance("/example-schema:addresses[.='0.0.0.0']");
+        datastore.deleteItem("/example-schema:addresses[.='0.0.0.0']");
         datastore.commitChanges();
         expected = {
             {"/example-schema:addresses", special_{SpecialValue::LeafList}},
@@ -448,24 +448,24 @@
         REQUIRE(datastore.getItems("/example-schema:addresses") == expected);
 
         REQUIRE_CALL(mock, write("/example-schema:addresses", "127.0.0.1"s, std::nullopt));
-        datastore.deleteLeafListInstance("/example-schema:addresses[.='127.0.0.1']");
+        datastore.deleteItem("/example-schema:addresses[.='127.0.0.1']");
         datastore.commitChanges();
         expected = {};
         REQUIRE(datastore.getItems("/example-schema:addresses") == expected);
     }
 
-    SECTION("non-existing leaf-list")
+    SECTION("deleting a non-existing leaf-list")
     {
         tryThis<THROWS_ON_NONEXISTING_KEYS>([&]{
-            datastore.deleteLeafListInstance("/example-schema:addresses[.='non-existing']");
+            datastore.deleteItem("/example-schema:addresses[.='non-existing']");
             datastore.commitChanges();
         });
     }
 
-    SECTION("non-existing leaf-list schema node")
+    SECTION("deleting a non-existing schema node as a leaf-list")
     {
         tryThis<THROWS_ON_INVALID_SCHEMA_PATHS>([&]{
-            datastore.deleteLeafListInstance("/example-schema:non-existing[.='non-existing']");
+            datastore.deleteItem("/example-schema:non-existing[.='non-existing']");
             datastore.commitChanges();
         });
     }
@@ -494,9 +494,9 @@
             REQUIRE_CALL(mock, write("/example-schema:protocols", std::nullopt, "pop3"s));
             REQUIRE_CALL(mock, write("/example-schema:protocols", "http"s, "ftp"s));
             REQUIRE_CALL(mock, write("/example-schema:protocols", "ftp"s, "pop3"s));
-            datastore.createLeafListInstance("/example-schema:protocols[.='http']");
-            datastore.createLeafListInstance("/example-schema:protocols[.='ftp']");
-            datastore.createLeafListInstance("/example-schema:protocols[.='pop3']");
+            datastore.createItem("/example-schema:protocols[.='http']");
+            datastore.createItem("/example-schema:protocols[.='ftp']");
+            datastore.createItem("/example-schema:protocols[.='pop3']");
             datastore.commitChanges();
             expected = {
                 {"/example-schema:protocols", special_{SpecialValue::LeafList}},
@@ -582,9 +582,9 @@
             REQUIRE_CALL(mock, write("/example-schema:players[name='Adam']", std::nullopt, ""s));
             REQUIRE_CALL(mock, write("/example-schema:players[name='Adam']/name", std::nullopt, "Adam"s));
             REQUIRE_CALL(mock, write("/example-schema:players[name='Adam']", ""s, ""s));
-            datastore.createListInstance("/example-schema:players[name='John']");
-            datastore.createListInstance("/example-schema:players[name='Eve']");
-            datastore.createListInstance("/example-schema:players[name='Adam']");
+            datastore.createItem("/example-schema:players[name='John']");
+            datastore.createItem("/example-schema:players[name='Eve']");
+            datastore.createItem("/example-schema:players[name='Adam']");
             datastore.commitChanges();
             expected = {
                 {"/example-schema:players[name='John']", special_{SpecialValue::List}},
diff --git a/tests/datastoreaccess_mock.hpp b/tests/datastoreaccess_mock.hpp
index 354dd44..8252d04 100644
--- a/tests/datastoreaccess_mock.hpp
+++ b/tests/datastoreaccess_mock.hpp
@@ -21,12 +21,8 @@
 class MockDatastoreAccess : public trompeloeil::mock_interface<DatastoreAccess> {
     IMPLEMENT_MOCK1(getItems);
     IMPLEMENT_MOCK2(setLeaf);
-    IMPLEMENT_MOCK1(createPresenceContainer);
-    IMPLEMENT_MOCK1(deletePresenceContainer);
-    IMPLEMENT_MOCK1(createLeafListInstance);
-    IMPLEMENT_MOCK1(deleteLeafListInstance);
-    IMPLEMENT_MOCK1(createListInstance);
-    IMPLEMENT_MOCK1(deleteListInstance);
+    IMPLEMENT_MOCK1(createItem);
+    IMPLEMENT_MOCK1(deleteItem);
     IMPLEMENT_MOCK2(moveItem);
     IMPLEMENT_MOCK2(executeRpc);
 
diff --git a/tests/interpreter.cpp b/tests/interpreter.cpp
index 3acef2b..15a268e 100644
--- a/tests/interpreter.cpp
+++ b/tests/interpreter.cpp
@@ -335,22 +335,22 @@
         SECTION("list instance")
         {
             inputPath.m_nodes = {dataNode_{{"mod"}, listElement_{"department", {{"name", "engineering"s}}}}};
-            expectations.push_back(NAMED_REQUIRE_CALL(datastore, createListInstance("/mod:department[name='engineering']")));
-            expectations.push_back(NAMED_REQUIRE_CALL(datastore, deleteListInstance("/mod:department[name='engineering']")));
+            expectations.push_back(NAMED_REQUIRE_CALL(datastore, createItem("/mod:department[name='engineering']")));
+            expectations.push_back(NAMED_REQUIRE_CALL(datastore, deleteItem("/mod:department[name='engineering']")));
         }
 
         SECTION("leaflist instance")
         {
             inputPath.m_nodes = {dataNode_{{"mod"}, leafListElement_{"addresses", "127.0.0.1"s}}};
-            expectations.push_back(NAMED_REQUIRE_CALL(datastore, createLeafListInstance("/mod:addresses[.='127.0.0.1']")));
-            expectations.push_back(NAMED_REQUIRE_CALL(datastore, deleteLeafListInstance("/mod:addresses[.='127.0.0.1']")));
+            expectations.push_back(NAMED_REQUIRE_CALL(datastore, createItem("/mod:addresses[.='127.0.0.1']")));
+            expectations.push_back(NAMED_REQUIRE_CALL(datastore, deleteItem("/mod:addresses[.='127.0.0.1']")));
         }
 
         SECTION("presence container")
         {
             inputPath.m_nodes = {dataNode_{{"mod"}, container_{"pContainer"}}};
-            expectations.push_back(NAMED_REQUIRE_CALL(datastore, createPresenceContainer("/mod:pContainer")));
-            expectations.push_back(NAMED_REQUIRE_CALL(datastore, deletePresenceContainer("/mod:pContainer")));
+            expectations.push_back(NAMED_REQUIRE_CALL(datastore, createItem("/mod:pContainer")));
+            expectations.push_back(NAMED_REQUIRE_CALL(datastore, deleteItem("/mod:pContainer")));
         }
 
         create_ createCmd;