Add TestModel.EMPTY_TEST 93/114193/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 25 Oct 2024 14:12:50 +0000 (16:12 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 25 Oct 2024 14:12:50 +0000 (16:12 +0200)
This is a useful empty container, which is used all over tests. Add a
constant and refer to it wherever appropriate.

Change-Id: I3f7feff3d854ddbacde9bc9358a580b5577ac6de
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 files changed:
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractDistributedDataStoreIntegrationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerSupportTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortIntegrationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreSnapshotRestoreTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardCommitCoordinationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/actors/ShardSnapshotActorTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/ReadyLocalTransactionSerializerTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/AbstractModificationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModificationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MergeModificationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/WriteModificationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/NormalizedNodeAggregatorTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java

index 5d61312e3018d0854f2dd3c9db40bdbca18e6b2b..1bc79e9788a5c0fc43ddb12fe8d8cbb370a3ddd1 100644 (file)
@@ -103,7 +103,7 @@ public abstract class AbstractDistributedDataStoreIntegrationTest {
         final IntegrationTestKit testKit = new IntegrationTestKit(getSystem(), datastoreContextBuilder);
         try (var dataStore = testKit.setupDataStore(testParameter, "transactionIntegrationTest", "test-1")) {
 
-            testKit.testWriteTransaction(dataStore, TestModel.TEST_PATH, containerNode(TestModel.TEST_QNAME));
+            testKit.testWriteTransaction(dataStore, TestModel.TEST_PATH, TestModel.EMPTY_TEST);
 
             testKit.testWriteTransaction(dataStore, TestModel.OUTER_LIST_PATH,
                 mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
@@ -165,7 +165,7 @@ public abstract class AbstractDistributedDataStoreIntegrationTest {
 
             // 2. Write some data
             final YangInstanceIdentifier nodePath = TestModel.TEST_PATH;
-            final NormalizedNode nodeToWrite = containerNode(TestModel.TEST_QNAME);
+            final ContainerNode nodeToWrite = TestModel.EMPTY_TEST;
             readWriteTx.write(nodePath, nodeToWrite);
 
             // 3. Read the data from Tx
@@ -381,7 +381,7 @@ public abstract class AbstractDistributedDataStoreIntegrationTest {
             final DOMStoreWriteTransaction writeTx = dataStore.newWriteOnlyTransaction();
             assertNotNull("newWriteOnlyTransaction returned null", writeTx);
 
-            writeTx.write(TestModel.TEST_PATH, containerNode(TestModel.TEST_QNAME));
+            writeTx.write(TestModel.TEST_PATH, TestModel.EMPTY_TEST);
 
             final DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
 
@@ -389,7 +389,7 @@ public abstract class AbstractDistributedDataStoreIntegrationTest {
 
             cohort.abort().get(5, TimeUnit.SECONDS);
 
-            testKit.testWriteTransaction(dataStore, TestModel.TEST_PATH, containerNode(TestModel.TEST_QNAME));
+            testKit.testWriteTransaction(dataStore, TestModel.TEST_PATH, TestModel.EMPTY_TEST);
         }
     }
 
@@ -406,7 +406,7 @@ public abstract class AbstractDistributedDataStoreIntegrationTest {
             assertNotNull("newWriteOnlyTransaction returned null", writeTx);
 
             // 2. Write some data
-            final NormalizedNode testNode = containerNode(TestModel.TEST_QNAME);
+            final NormalizedNode testNode = TestModel.EMPTY_TEST;
             writeTx.write(TestModel.TEST_PATH, testNode);
 
             // 3. Ready the Tx for commit
@@ -603,7 +603,7 @@ public abstract class AbstractDistributedDataStoreIntegrationTest {
             final DOMStoreWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
             assertNotNull("newWriteOnlyTransaction returned null", writeTx);
 
-            writeTx.write(TestModel.TEST_PATH, containerNode(TestModel.TEST_QNAME));
+            writeTx.write(TestModel.TEST_PATH, TestModel.EMPTY_TEST);
 
             // Try to create another Tx of each type - each should fail
             // b/c the previous Tx wasn't
@@ -637,7 +637,7 @@ public abstract class AbstractDistributedDataStoreIntegrationTest {
 
             // Create a write tx and submit.
             final DOMStoreWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
-            writeTx.write(TestModel.TEST_PATH, containerNode(TestModel.TEST_QNAME));
+            writeTx.write(TestModel.TEST_PATH, TestModel.EMPTY_TEST);
             final DOMStoreThreePhaseCommitCohort cohort1 = writeTx.ready();
 
             // Create read-only tx's and issue a read.
@@ -750,7 +750,7 @@ public abstract class AbstractDistributedDataStoreIntegrationTest {
         try (var dataStore = testKit.setupDataStore(testParameter, "testDataTreeChangeListenerRegistration",
             "test-1")) {
 
-            testKit.testWriteTransaction(dataStore, TestModel.TEST_PATH, containerNode(TestModel.TEST_QNAME));
+            testKit.testWriteTransaction(dataStore, TestModel.TEST_PATH, TestModel.EMPTY_TEST);
 
             final MockDataTreeChangeListener listener = new MockDataTreeChangeListener(1);
 
index 88a564f83200aecdf18e26689f3ea34e3f377832..2943a26b4ae3dc7358c50a64ee05f16f76c178ff 100644 (file)
@@ -311,7 +311,7 @@ public abstract class AbstractShardTest extends AbstractActorTest {
         final DataTree testStore = new InMemoryDataTreeFactory().create(
             DataTreeConfiguration.DEFAULT_OPERATIONAL, SCHEMA_CONTEXT);
 
-        writeToStore(testStore, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+        writeToStore(testStore, TestModel.TEST_PATH, TestModel.EMPTY_TEST);
 
         final NormalizedNode root = readStore(testStore, YangInstanceIdentifier.of());
 
index 9864ed45266f4cc47556fd658de542543078fe53..d6a26d10a38c64f5de17c769f192772c722260b9 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
+import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.EMPTY_TEST;
 import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.INNER_LIST_QNAME;
 import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.OUTER_LIST_PATH;
 import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.OUTER_LIST_QNAME;
 import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.TEST_PATH;
-import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.TEST_QNAME;
 import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.innerEntryPath;
 import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.innerNode;
 import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.outerEntryKey;
@@ -40,9 +40,7 @@ import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeNo
 import org.opendaylight.controller.cluster.datastore.utils.MockDataTreeChangeListener;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataValidationFailedException;
 import scala.concurrent.Await;
 import scala.concurrent.duration.FiniteDuration;
@@ -79,9 +77,7 @@ public class DataTreeChangeListenerSupportTest extends AbstractShardTest {
 
     @Test
     public void testInitialChangeListenerEventWithContainerPath() throws DataValidationFailedException {
-        writeToStore(shard.getDataStore(), TEST_PATH, ImmutableNodes.newContainerBuilder()
-            .withNodeIdentifier(new NodeIdentifier(TEST_QNAME))
-            .build());
+        writeToStore(shard.getDataStore(), TEST_PATH, EMPTY_TEST);
 
         Entry<MockDataTreeChangeListener, ActorSelection> entry = registerChangeListener(TEST_PATH, 1);
         MockDataTreeChangeListener listener = entry.getKey();
@@ -91,9 +87,7 @@ public class DataTreeChangeListenerSupportTest extends AbstractShardTest {
 
         listener.reset(1);
 
-        writeToStore(shard.getDataStore(), TEST_PATH, ImmutableNodes.newContainerBuilder()
-            .withNodeIdentifier(new NodeIdentifier(TEST_QNAME))
-            .build());
+        writeToStore(shard.getDataStore(), TEST_PATH, EMPTY_TEST);
         listener.waitForChangeEvents();
         listener.verifyNotifiedData(TEST_PATH);
 
@@ -102,9 +96,7 @@ public class DataTreeChangeListenerSupportTest extends AbstractShardTest {
         entry.getValue().tell(CloseDataTreeNotificationListenerRegistration.getInstance(), kit.getRef());
         kit.expectMsgClass(Duration.ofSeconds(5), CloseDataTreeNotificationListenerRegistrationReply.class);
 
-        writeToStore(shard.getDataStore(), TEST_PATH, ImmutableNodes.newContainerBuilder()
-            .withNodeIdentifier(new NodeIdentifier(TEST_QNAME))
-            .build());
+        writeToStore(shard.getDataStore(), TEST_PATH, EMPTY_TEST);
         listener.verifyNoNotifiedData(TEST_PATH);
     }
 
index 0ccdc4148e0fbd8c950c2c12ce487b1b9b4779ce..32c436f810de1bf8451dd69ae1afd9b6d3498e86 100644 (file)
@@ -107,7 +107,7 @@ public class DataTreeCohortIntegrationTest {
             IntegrationTestKit.verifyShardState(dataStore, "test-1",
                 state -> assertEquals("Cohort registrations", 1, state.getCommitCohortActors().size()));
 
-            final var node = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+            final var node = TestModel.EMPTY_TEST;
             kit.testWriteTransaction(dataStore, TestModel.TEST_PATH, node);
             verify(cohort).canCommit(any(Object.class), any(EffectiveModelContext.class), candidateCapt.capture());
             assertDataTreeCandidate((DOMDataTreeCandidate) candidateCapt.getValue().iterator().next(), TEST_ID,
@@ -148,7 +148,7 @@ public class DataTreeCohortIntegrationTest {
                 state -> assertEquals("Cohort registrations", 1, state.getCommitCohortActors().size()));
 
             DOMStoreWriteTransaction writeTx = dataStore.newWriteOnlyTransaction();
-            writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+            writeTx.write(TestModel.TEST_PATH, TestModel.EMPTY_TEST);
             DOMStoreThreePhaseCommitCohort dsCohort = writeTx.ready();
             try {
                 dsCohort.canCommit().get(5, TimeUnit.SECONDS);
@@ -292,7 +292,7 @@ public class DataTreeCohortIntegrationTest {
                 state -> assertEquals("Cohort registrations", 1, state.getCommitCohortActors().size()));
 
             var writeTx = dataStore.newWriteOnlyTransaction();
-            writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+            writeTx.write(TestModel.TEST_PATH, TestModel.EMPTY_TEST);
             writeTx.write(CarsModel.BASE_PATH, CarsModel.emptyContainer());
             var dsCohort = writeTx.ready();
 
index 9b13193b15da96b2633ec71a3cff8838780cf116..e8c35db7e895a51f41535bf6c5f0de19f290a64b 100644 (file)
@@ -35,7 +35,6 @@ import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.yangtools.yang.common.Uint64;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory;
@@ -70,7 +69,7 @@ public class DatastoreSnapshotRestoreTest {
 
         DatastoreSnapshot operSnapshot = new DatastoreSnapshot("oper",
                 null, Arrays.asList(new DatastoreSnapshot.ShardSnapshot("oper-one", newSnapshot(TestModel.TEST_PATH,
-                        ImmutableNodes.containerNode(TestModel.TEST_QNAME)))));
+                        TestModel.EMPTY_TEST))));
 
         DatastoreSnapshotList snapshotList = new DatastoreSnapshotList(Arrays.asList(configSnapshot, operSnapshot));
 
index 09be93cd6b3441a9eb52f0df1f91cecde3e4effe..b45fde89d99ffff46c52687aee5dba69c5de8aea 100644 (file)
@@ -104,7 +104,7 @@ public class DistributedDataStoreIntegrationTest extends AbstractDistributedData
             final CountDownLatch txReady = new CountDownLatch(1);
             final Thread txThread = new Thread(() -> {
                 try {
-                    writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+                    writeTx.write(TestModel.TEST_PATH, TestModel.EMPTY_TEST);
 
                     writeTx.merge(TestModel.OUTER_LIST_PATH,
                         ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
@@ -193,8 +193,7 @@ public class DistributedDataStoreIntegrationTest extends AbstractDistributedData
             final CountDownLatch txReadsDone = new CountDownLatch(1);
             final Thread txThread = new Thread(() -> {
                 try {
-                    readWriteTx.write(TestModel.TEST_PATH,
-                        ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+                    readWriteTx.write(TestModel.TEST_PATH, TestModel.EMPTY_TEST);
 
                     txExistsFuture.set(readWriteTx.exists(TestModel.TEST_PATH));
 
@@ -260,7 +259,7 @@ public class DistributedDataStoreIntegrationTest extends AbstractDistributedData
         final CountDownLatch txReady = new CountDownLatch(1);
         final Thread txThread = new Thread(() -> {
             try {
-                writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+                writeTx.write(TestModel.TEST_PATH, TestModel.EMPTY_TEST);
 
                 txCohort.set(writeTx.ready());
             } catch (Exception e) {
@@ -324,8 +323,7 @@ public class DistributedDataStoreIntegrationTest extends AbstractDistributedData
             final CountDownLatch txReadDone = new CountDownLatch(1);
             final Thread txThread = new Thread(() -> {
                 try {
-                    readWriteTx.write(TestModel.TEST_PATH,
-                        ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+                    readWriteTx.write(TestModel.TEST_PATH, TestModel.EMPTY_TEST);
 
                     txReadFuture.set(readWriteTx.read(TestModel.TEST_PATH));
 
index 8d192498c74d32904a31aec50439847740147ddf..114e2a4cb38e756a8f27de28dc8ed3948dc90446 100644 (file)
@@ -9,13 +9,13 @@ package org.opendaylight.controller.cluster.datastore;
 
 import static org.junit.Assert.assertNotNull;
 import static org.opendaylight.controller.cluster.datastore.DataStoreVersions.CURRENT_VERSION;
+import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.EMPTY_TEST;
 import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.ID_QNAME;
 import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.INNER_LIST_QNAME;
 import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.NAME_QNAME;
 import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.OUTER_LIST_PATH;
 import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.OUTER_LIST_QNAME;
 import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.TEST_PATH;
-import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.TEST_QNAME;
 import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.innerEntryPath;
 import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.innerMapPath;
 import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.innerNode;
@@ -94,8 +94,7 @@ public class ShardCommitCoordinationTest extends AbstractShardTest {
 
         // Ready [tx1, tx2] on shard A.
 
-        shardA.tell(newReadyBatchedModifications(txId1, TEST_PATH,
-                ImmutableNodes.containerNode(TEST_QNAME), participatingShardNames), kit1.getRef());
+        shardA.tell(newReadyBatchedModifications(txId1, TEST_PATH, EMPTY_TEST, participatingShardNames), kit1.getRef());
         kit1.expectMsgClass(ReadyTransactionReply.class);
 
         shardA.tell(newReadyBatchedModifications(txId2, OUTER_LIST_PATH, outerNode(1),
@@ -108,8 +107,7 @@ public class ShardCommitCoordinationTest extends AbstractShardTest {
                 participatingShardNames), kit2.getRef());
         kit2.expectMsgClass(ReadyTransactionReply.class);
 
-        shardB.tell(newReadyBatchedModifications(txId1, TEST_PATH,
-                ImmutableNodes.containerNode(TEST_QNAME), participatingShardNames), kit1.getRef());
+        shardB.tell(newReadyBatchedModifications(txId1, TEST_PATH, EMPTY_TEST, participatingShardNames), kit1.getRef());
         kit1.expectMsgClass(ReadyTransactionReply.class);
 
         // Send tx2 CanCommit to A - tx1 is at the head of the queue so tx2 should not proceed as A is the first shard
@@ -213,8 +211,8 @@ public class ShardCommitCoordinationTest extends AbstractShardTest {
 
         // Ready [tx3, tx4, tx5] on shard A.
 
-        shardA.tell(newReadyBatchedModifications(txId3, TEST_PATH,
-                ImmutableNodes.containerNode(TEST_QNAME), participatingShardNames1), kit3.getRef());
+        shardA.tell(newReadyBatchedModifications(txId3, TEST_PATH, EMPTY_TEST, participatingShardNames1),
+            kit3.getRef());
         kit3.expectMsgClass(ReadyTransactionReply.class);
 
         shardA.tell(newReadyBatchedModifications(txId4, OUTER_LIST_PATH, outerMapNode(),
@@ -227,8 +225,8 @@ public class ShardCommitCoordinationTest extends AbstractShardTest {
 
         // Ready [tx1, tx2, tx5, tx4, tx3] on shard B.
 
-        shardB.tell(newReadyBatchedModifications(txId1, TEST_PATH,
-                ImmutableNodes.containerNode(TEST_QNAME), participatingShardNames2), kit1.getRef());
+        shardB.tell(newReadyBatchedModifications(txId1, TEST_PATH, EMPTY_TEST, participatingShardNames2),
+            kit1.getRef());
         kit1.expectMsgClass(ReadyTransactionReply.class);
 
         shardB.tell(newReadyBatchedModifications(txId2, OUTER_LIST_PATH, outerMapNode(),
@@ -378,20 +376,20 @@ public class ShardCommitCoordinationTest extends AbstractShardTest {
 
         // Ready [tx1] on shard A.
 
-        shardA.tell(newReadyBatchedModifications(txId1, TEST_PATH,
-                ImmutableNodes.containerNode(TEST_QNAME), participatingShardNames1), kit1.getRef());
+        shardA.tell(newReadyBatchedModifications(txId1, TEST_PATH, EMPTY_TEST, participatingShardNames1),
+            kit1.getRef());
         kit1.expectMsgClass(ReadyTransactionReply.class);
 
         // Ready [tx2] on shard B.
 
-        shardB.tell(newReadyBatchedModifications(txId2, TEST_PATH,
-                ImmutableNodes.containerNode(TEST_QNAME), participatingShardNames2), kit2.getRef());
+        shardB.tell(newReadyBatchedModifications(txId2, TEST_PATH, EMPTY_TEST, participatingShardNames2),
+            kit2.getRef());
         kit2.expectMsgClass(ReadyTransactionReply.class);
 
         // Ready [tx2, tx1] on shard C.
 
-        shardC.tell(newReadyBatchedModifications(txId2, TEST_PATH,
-                ImmutableNodes.containerNode(TEST_QNAME), participatingShardNames2), kit2.getRef());
+        shardC.tell(newReadyBatchedModifications(txId2, TEST_PATH, EMPTY_TEST, participatingShardNames2),
+            kit2.getRef());
         kit2.expectMsgClass(ReadyTransactionReply.class);
 
         shardC.tell(newReadyBatchedModifications(txId1, OUTER_LIST_PATH, outerNode(1),
@@ -491,14 +489,14 @@ public class ShardCommitCoordinationTest extends AbstractShardTest {
 
         // Ready [tx1] on shard A.
 
-        shardA.tell(newReadyBatchedModifications(txId1, TEST_PATH,
-                ImmutableNodes.containerNode(TEST_QNAME), participatingShardNames1), kit1.getRef());
+        shardA.tell(newReadyBatchedModifications(txId1, TEST_PATH, EMPTY_TEST, participatingShardNames1),
+            kit1.getRef());
         kit1.expectMsgClass(ReadyTransactionReply.class);
 
         // Ready [tx2, tx1] on shard B.
 
-        shardB.tell(newReadyBatchedModifications(txId2, TEST_PATH,
-                ImmutableNodes.containerNode(TEST_QNAME), participatingShardNames2), kit2.getRef());
+        shardB.tell(newReadyBatchedModifications(txId2, TEST_PATH, EMPTY_TEST, participatingShardNames2),
+            kit2.getRef());
         kit2.expectMsgClass(ReadyTransactionReply.class);
 
         shardB.tell(newReadyBatchedModifications(txId1, OUTER_LIST_PATH, outerNode(1),
@@ -507,8 +505,8 @@ public class ShardCommitCoordinationTest extends AbstractShardTest {
 
         // Ready [tx2] on shard C.
 
-        shardC.tell(newReadyBatchedModifications(txId2, TEST_PATH,
-                ImmutableNodes.containerNode(TEST_QNAME), participatingShardNames2), kit2.getRef());
+        shardC.tell(newReadyBatchedModifications(txId2, TEST_PATH, EMPTY_TEST, participatingShardNames2),
+            kit2.getRef());
         kit2.expectMsgClass(ReadyTransactionReply.class);
 
         // Send tx1 CanCommit to A - should succeed.
index 5afcaa4e8e4303e062d7ea7cfdb2a88440a93eb4..86788a1775fc64d25619353e12e53dbd9c496235 100644 (file)
@@ -152,7 +152,7 @@ public class ShardTest extends AbstractShardTest {
             replyPath.matches("pekko:\\/\\/test\\/user\\/testRegisterDataTreeChangeListener\\/\\$.*"));
 
         final YangInstanceIdentifier path = TestModel.TEST_PATH;
-        writeToStore(shard, path, containerNode(TestModel.TEST_QNAME));
+        writeToStore(shard, path, TestModel.EMPTY_TEST);
 
         listener.waitForChangeEvents();
         listener.verifyOnInitialDataEvent();
@@ -339,7 +339,7 @@ public class ShardTest extends AbstractShardTest {
             SCHEMA_CONTEXT);
 
         final DataTreeModification writeMod = store.takeSnapshot().newModification();
-        final ContainerNode node = containerNode(TestModel.TEST_QNAME);
+        final ContainerNode node = TestModel.EMPTY_TEST;
         writeMod.write(TestModel.TEST_PATH, node);
         writeMod.ready();
 
@@ -481,8 +481,8 @@ public class ShardTest extends AbstractShardTest {
         final CapturingShardDataTreeCohort cohort2 = cohortMap.get(transactionID2);
         final CapturingShardDataTreeCohort cohort3 = cohortMap.get(transactionID3);
 
-        shard.tell(prepareBatchedModifications(transactionID1, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), false), testKit.getRef());
+        shard.tell(prepareBatchedModifications(transactionID1, TestModel.TEST_PATH, TestModel.EMPTY_TEST, false),
+            testKit.getRef());
         final ReadyTransactionReply readyReply = ReadyTransactionReply
                 .fromSerializable(testKit.expectMsgClass(duration, ReadyTransactionReply.class));
 
@@ -575,8 +575,8 @@ public class ShardTest extends AbstractShardTest {
 
         // Send a BatchedModifications to start a transaction.
 
-        shard.tell(newBatchedModifications(transactionID, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), false, false, 1), testKit.getRef());
+        shard.tell(newBatchedModifications(transactionID, TestModel.TEST_PATH, TestModel.EMPTY_TEST, false, false, 1),
+            testKit.getRef());
         testKit.expectMsgClass(duration, BatchedModificationsReply.class);
 
         // Send a couple more BatchedModifications.
@@ -623,8 +623,8 @@ public class ShardTest extends AbstractShardTest {
 
         // Send a BatchedModifications to start a transaction.
 
-        shard.tell(newBatchedModifications(transactionID, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), false, false, 1), testKit.getRef());
+        shard.tell(newBatchedModifications(transactionID, TestModel.TEST_PATH, TestModel.EMPTY_TEST, false, false, 1),
+            testKit.getRef());
         testKit.expectMsgClass(duration, BatchedModificationsReply.class);
 
         // Send a couple more BatchedModifications.
@@ -728,7 +728,7 @@ public class ShardTest extends AbstractShardTest {
         // Send a BatchedModifications to start a chained write
         // transaction and ready it.
 
-        final ContainerNode containerNode = containerNode(TestModel.TEST_QNAME);
+        final ContainerNode containerNode = TestModel.EMPTY_TEST;
         final YangInstanceIdentifier path = TestModel.TEST_PATH;
         shard.tell(newBatchedModifications(transactionID1, path, containerNode, true, false, 1), testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
@@ -820,8 +820,8 @@ public class ShardTest extends AbstractShardTest {
         Failure failure = testKit.expectMsgClass(Failure.class);
         assertEquals("Failure cause type", NoShardLeaderException.class, failure.cause().getClass());
 
-        shard.tell(prepareForwardedReadyTransaction(shard, txId, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), true), testKit.getRef());
+        shard.tell(prepareForwardedReadyTransaction(shard, txId, TestModel.TEST_PATH, TestModel.EMPTY_TEST, true),
+            testKit.getRef());
         failure = testKit.expectMsgClass(Failure.class);
         assertEquals("Failure cause type", NoShardLeaderException.class, failure.cause().getClass());
 
@@ -850,7 +850,7 @@ public class ShardTest extends AbstractShardTest {
         ShardTestKit.waitUntilLeader(shard);
 
         final TransactionIdentifier transactionID = nextTransactionId();
-        final NormalizedNode containerNode = containerNode(TestModel.TEST_QNAME);
+        final var containerNode = TestModel.EMPTY_TEST;
         if (readWrite) {
             shard.tell(prepareForwardedReadyTransaction(shard, transactionID, TestModel.TEST_PATH, containerNode, true),
                 testKit.getRef());
@@ -878,7 +878,7 @@ public class ShardTest extends AbstractShardTest {
 
         final DataTreeModification modification = dataStore.newModification();
 
-        final var writeData = containerNode(TestModel.TEST_QNAME);
+        final var writeData = TestModel.EMPTY_TEST;
         modification.write(TestModel.TEST_PATH, writeData);
         final var mergeData = mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
                 .addChild(mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 42))
@@ -911,7 +911,7 @@ public class ShardTest extends AbstractShardTest {
 
         final DataTreeModification modification = dataStore.newModification();
 
-        final ContainerNode writeData = containerNode(TestModel.TEST_QNAME);
+        final ContainerNode writeData = TestModel.EMPTY_TEST;
         modification.write(TestModel.TEST_PATH, writeData);
         final MapNode mergeData = mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
                 .addChild(mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 42))
@@ -958,7 +958,7 @@ public class ShardTest extends AbstractShardTest {
         final Duration duration = Duration.ofSeconds(5);
 
         final TransactionIdentifier transactionID = nextTransactionId();
-        final NormalizedNode containerNode = containerNode(TestModel.TEST_QNAME);
+        final ContainerNode containerNode = TestModel.EMPTY_TEST;
         shard.tell(prepareBatchedModifications(transactionID, TestModel.TEST_PATH, containerNode, false),
             testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
@@ -1003,10 +1003,10 @@ public class ShardTest extends AbstractShardTest {
 
         if (readWrite) {
             shard.tell(prepareForwardedReadyTransaction(shard, transactionID, TestModel.TEST_PATH,
-                containerNode(TestModel.TEST_QNAME), false), testKit.getRef());
+                TestModel.EMPTY_TEST, false), testKit.getRef());
         } else {
             shard.tell(prepareBatchedModifications(transactionID, TestModel.TEST_PATH,
-                containerNode(TestModel.TEST_QNAME), false), testKit.getRef());
+                TestModel.EMPTY_TEST, false), testKit.getRef());
         }
 
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
@@ -1062,13 +1062,13 @@ public class ShardTest extends AbstractShardTest {
         .commit(any(DataTreeCandidate.class));
 
         final TransactionIdentifier transactionID1 = nextTransactionId();
-        shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), true, false, 1), testKit.getRef());
+        shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH, TestModel.EMPTY_TEST, true, false, 1),
+            testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
 
         final TransactionIdentifier transactionID2 = nextTransactionId();
-        shard.tell(newBatchedModifications(transactionID2, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), true, false, 1), testKit.getRef());
+        shard.tell(newBatchedModifications(transactionID2, TestModel.TEST_PATH, TestModel.EMPTY_TEST, true, false, 1),
+            testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
 
         // Send the CanCommitTransaction message for the first Tx.
@@ -1132,13 +1132,13 @@ public class ShardTest extends AbstractShardTest {
         .prepare(any(DataTreeModification.class));
 
         final TransactionIdentifier transactionID1 = nextTransactionId();
-        shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), true, false, 1), testKit.getRef());
+        shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH, TestModel.EMPTY_TEST, true, false, 1),
+            testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
 
         final TransactionIdentifier transactionID2 = nextTransactionId();
-        shard.tell(newBatchedModifications(transactionID2, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), true, false, 1), testKit.getRef());
+        shard.tell(newBatchedModifications(transactionID2, TestModel.TEST_PATH, TestModel.EMPTY_TEST, true, false, 1),
+            testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
 
         // Send the CanCommitTransaction message for the first Tx.
@@ -1196,8 +1196,8 @@ public class ShardTest extends AbstractShardTest {
         doThrow(new DataValidationFailedException(YangInstanceIdentifier.of(), "mock canCommit failure"))
         .doNothing().when(dataTree).validate(any(DataTreeModification.class));
 
-        shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), true, false, 1), testKit.getRef());
+        shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH, TestModel.EMPTY_TEST, true, false, 1),
+            testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
 
         // Send the CanCommitTransaction message.
@@ -1209,8 +1209,8 @@ public class ShardTest extends AbstractShardTest {
         // up.
 
         final TransactionIdentifier transactionID2 = nextTransactionId();
-        shard.tell(newBatchedModifications(transactionID2, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), true, false, 1), testKit.getRef());
+        shard.tell(newBatchedModifications(transactionID2, TestModel.TEST_PATH, TestModel.EMPTY_TEST, true, false, 1),
+            testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
 
         shard.tell(new CanCommitTransaction(transactionID2, CURRENT_VERSION).toSerializable(), testKit.getRef());
@@ -1243,10 +1243,10 @@ public class ShardTest extends AbstractShardTest {
 
         if (readWrite) {
             shard.tell(prepareForwardedReadyTransaction(shard, transactionID1, TestModel.TEST_PATH,
-                containerNode(TestModel.TEST_QNAME), true), testKit.getRef());
+                TestModel.EMPTY_TEST, true), testKit.getRef());
         } else {
             shard.tell(prepareBatchedModifications(transactionID1, TestModel.TEST_PATH,
-                containerNode(TestModel.TEST_QNAME), true), testKit.getRef());
+                TestModel.EMPTY_TEST, true), testKit.getRef());
         }
 
         testKit.expectMsgClass(duration, org.apache.pekko.actor.Status.Failure.class);
@@ -1257,10 +1257,10 @@ public class ShardTest extends AbstractShardTest {
         final TransactionIdentifier transactionID2 = nextTransactionId();
         if (readWrite) {
             shard.tell(prepareForwardedReadyTransaction(shard, transactionID2, TestModel.TEST_PATH,
-                containerNode(TestModel.TEST_QNAME), true), testKit.getRef());
+                TestModel.EMPTY_TEST, true), testKit.getRef());
         } else {
             shard.tell(prepareBatchedModifications(transactionID2, TestModel.TEST_PATH,
-                containerNode(TestModel.TEST_QNAME), true), testKit.getRef());
+                TestModel.EMPTY_TEST, true), testKit.getRef());
         }
 
         testKit.expectMsgClass(duration, CommitTransactionReply.class);
@@ -1292,8 +1292,8 @@ public class ShardTest extends AbstractShardTest {
 
         final TransactionIdentifier transactionID = nextTransactionId();
 
-        shard.tell(prepareBatchedModifications(transactionID, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), false), testKit.getRef());
+        shard.tell(prepareBatchedModifications(transactionID, TestModel.TEST_PATH, TestModel.EMPTY_TEST, false),
+            testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
 
         shard.tell(new CanCommitTransaction(transactionID, CURRENT_VERSION).toSerializable(), testKit.getRef());
@@ -1324,7 +1324,7 @@ public class ShardTest extends AbstractShardTest {
 
         final Duration duration = Duration.ofSeconds(5);
 
-        writeToStore(shard, TestModel.TEST_PATH, containerNode(TestModel.TEST_QNAME));
+        writeToStore(shard, TestModel.TEST_PATH, TestModel.EMPTY_TEST);
         writeToStore(shard, TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
 
         // Ready 2 Tx's - the first will timeout
@@ -1452,18 +1452,18 @@ public class ShardTest extends AbstractShardTest {
         final Duration duration = Duration.ofSeconds(5);
 
         final TransactionIdentifier transactionID1 = nextTransactionId();
-        shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), true, false, 1), testKit.getRef());
+        shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH, TestModel.EMPTY_TEST, true, false, 1),
+            testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
 
         final TransactionIdentifier transactionID2 = nextTransactionId();
-        shard.tell(newBatchedModifications(transactionID2, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), true, false, 1), testKit.getRef());
+        shard.tell(newBatchedModifications(transactionID2, TestModel.TEST_PATH, TestModel.EMPTY_TEST, true, false, 1),
+            testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
 
         final TransactionIdentifier transactionID3 = nextTransactionId();
-        shard.tell(newBatchedModifications(transactionID3, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), true, false, 1), testKit.getRef());
+        shard.tell(newBatchedModifications(transactionID3, TestModel.TEST_PATH, TestModel.EMPTY_TEST, true, false, 1),
+            testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
 
         // All Tx's are readied. We'll send canCommit for the last one
@@ -1490,8 +1490,8 @@ public class ShardTest extends AbstractShardTest {
         final ShardDataTree dataStore = shard.underlyingActor().getDataStore();
 
         final TransactionIdentifier transactionID1 = nextTransactionId();
-        shard.tell(prepareBatchedModifications(transactionID1, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), false), testKit.getRef());
+        shard.tell(prepareBatchedModifications(transactionID1, TestModel.TEST_PATH, TestModel.EMPTY_TEST, false),
+            testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
 
         // CanCommit the first Tx so it's the current in-progress Tx.
@@ -1502,8 +1502,8 @@ public class ShardTest extends AbstractShardTest {
         // Ready the second Tx.
 
         final TransactionIdentifier transactionID2 = nextTransactionId();
-        shard.tell(prepareBatchedModifications(transactionID2, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), false), testKit.getRef());
+        shard.tell(prepareBatchedModifications(transactionID2, TestModel.TEST_PATH, TestModel.EMPTY_TEST, false),
+            testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
 
         // Ready the third Tx.
@@ -1556,13 +1556,13 @@ public class ShardTest extends AbstractShardTest {
         // Ready 2 transactions - the first one will be aborted.
 
         final TransactionIdentifier transactionID1 = nextTransactionId();
-        shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), true, false, 1), testKit.getRef());
+        shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH, TestModel.EMPTY_TEST, true, false, 1),
+            testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
 
         final TransactionIdentifier transactionID2 = nextTransactionId();
-        shard.tell(newBatchedModifications(transactionID2, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), true, false, 1), testKit.getRef());
+        shard.tell(newBatchedModifications(transactionID2, TestModel.TEST_PATH, TestModel.EMPTY_TEST, true, false, 1),
+            testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
 
         // Send the CanCommitTransaction message for the first Tx.
@@ -1607,8 +1607,8 @@ public class ShardTest extends AbstractShardTest {
         // Ready a tx.
 
         final TransactionIdentifier transactionID1 = nextTransactionId();
-        shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), true, false, 1), testKit.getRef());
+        shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH, TestModel.EMPTY_TEST, true, false, 1),
+            testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
 
         // Send the AbortTransaction message.
@@ -1627,8 +1627,8 @@ public class ShardTest extends AbstractShardTest {
         // Ready and CanCommit another and verify success.
 
         final TransactionIdentifier transactionID2 = nextTransactionId();
-        shard.tell(newBatchedModifications(transactionID2, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), true, false, 1), testKit.getRef());
+        shard.tell(newBatchedModifications(transactionID2, TestModel.TEST_PATH, TestModel.EMPTY_TEST, true, false, 1),
+            testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
 
         shard.tell(new CanCommitTransaction(transactionID2, CURRENT_VERSION).toSerializable(), testKit.getRef());
@@ -1648,13 +1648,13 @@ public class ShardTest extends AbstractShardTest {
         // Ready 3 tx's.
 
         final TransactionIdentifier transactionID1 = nextTransactionId();
-        shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), true, false, 1), testKit.getRef());
+        shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH, TestModel.EMPTY_TEST, true, false, 1),
+            testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
 
         final TransactionIdentifier transactionID2 = nextTransactionId();
-        shard.tell(newBatchedModifications(transactionID2, TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME), true, false, 1), testKit.getRef());
+        shard.tell(newBatchedModifications(transactionID2, TestModel.TEST_PATH, TestModel.EMPTY_TEST, true, false, 1),
+            testKit.getRef());
         testKit.expectMsgClass(duration, ReadyTransactionReply.class);
 
         final TransactionIdentifier transactionID3 = nextTransactionId();
@@ -1741,7 +1741,7 @@ public class ShardTest extends AbstractShardTest {
             new DelegatingShardCreator(creator)).withDispatcher(Dispatchers.DefaultDispatcherId()), shardActorName);
 
         ShardTestKit.waitUntilLeader(shard);
-        writeToStore(shard, TestModel.TEST_PATH, containerNode(TestModel.TEST_QNAME));
+        writeToStore(shard, TestModel.TEST_PATH, TestModel.EMPTY_TEST);
 
         final NormalizedNode expectedRoot = readStore(shard, YangInstanceIdentifier.of());
 
@@ -1781,7 +1781,7 @@ public class ShardTest extends AbstractShardTest {
             SCHEMA_CONTEXT);
 
         final DataTreeModification putTransaction = store.takeSnapshot().newModification();
-        putTransaction.write(TestModel.TEST_PATH, containerNode(TestModel.TEST_QNAME));
+        putTransaction.write(TestModel.TEST_PATH, TestModel.EMPTY_TEST);
         commitTransaction(store, putTransaction);
 
 
@@ -1794,9 +1794,7 @@ public class ShardTest extends AbstractShardTest {
 
         commitTransaction(store, writeTransaction);
 
-        final NormalizedNode actual = readStore(store, YangInstanceIdentifier.of());
-
-        assertEquals(expected, actual);
+        assertEquals(expected, readStore(store, YangInstanceIdentifier.of()));
     }
 
     @Test
@@ -1993,7 +1991,7 @@ public class ShardTest extends AbstractShardTest {
             RegisterDataTreeNotificationListenerReply.class);
         assertNotNull("getListenerRegistrationPath", reply.getListenerRegistrationPath());
 
-        writeToStore(followerShard, path, containerNode(TestModel.TEST_QNAME));
+        writeToStore(followerShard, path, TestModel.EMPTY_TEST);
 
         listener.waitForChangeEvents();
     }
index ab4d045b7d916e086fdc9298f7b5ea9ec59686ab..633a626471a86d8e543d78699d2acacc70460156 100644 (file)
@@ -268,9 +268,7 @@ public class ShardTransactionTest extends AbstractActorTest {
         watcher.watch(transaction);
 
         YangInstanceIdentifier path = TestModel.TEST_PATH;
-        ContainerNode node = ImmutableNodes.newContainerBuilder()
-            .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-            .build();
+        ContainerNode node = TestModel.EMPTY_TEST;
 
         doThrow(new TestException()).when(mockModification).write(path, node);
 
index fe92c80f6859aa21610832487cc8953a20f3d49a..f0ccb038e52edf2fb64bcb002bda12a92e19cc08 100644 (file)
@@ -26,13 +26,10 @@ import org.opendaylight.controller.cluster.io.InputOutputStreamFactory;
 import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 
 public class ShardSnapshotActorTest extends AbstractActorTest {
     private static final InputOutputStreamFactory STREAM_FACTORY = InputOutputStreamFactory.simple();
 
-    private static final NormalizedNode DATA = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
-
     private static void testSerializeSnapshot(final String testName, final ShardDataTreeSnapshot snapshot,
             final boolean withInstallSnapshot) throws Exception {
         final TestKit kit = new TestKit(getSystem());
@@ -65,8 +62,8 @@ public class ShardSnapshotActorTest extends AbstractActorTest {
     @Test
     public void testSerializeBoronSnapshot() throws Exception {
         testSerializeSnapshot("testSerializeBoronSnapshotWithInstallSnapshot",
-                new MetadataShardDataTreeSnapshot(DATA), true);
+                new MetadataShardDataTreeSnapshot(TestModel.EMPTY_TEST), true);
         testSerializeSnapshot("testSerializeBoronSnapshotWithoutInstallSnapshot",
-                new MetadataShardDataTreeSnapshot(DATA), false);
+                new MetadataShardDataTreeSnapshot(TestModel.EMPTY_TEST), false);
     }
 }
index fa80b216ccba90e4eb2cfec2e7151ae9d3168d45..361ca469c30f580913ff355337c879ae56fe43c9 100644 (file)
@@ -47,7 +47,7 @@ public class ReadyLocalTransactionSerializerTest extends AbstractTest {
             DataTreeConfiguration.DEFAULT_OPERATIONAL, TestModel.createTestContext());
         DataTreeModification modification = dataTree.takeSnapshot().newModification();
 
-        ContainerNode writeData = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+        ContainerNode writeData = TestModel.EMPTY_TEST;
         modification.write(TestModel.TEST_PATH, writeData);
         MapNode mergeData = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build();
         modification.merge(TestModel.OUTER_LIST_PATH, mergeData);
index dd35c65236dacddfafba8f7b029c894894ac36b9..f85b04a95cbe97cc8af799b9cff816824c9cf913 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.controller.cluster.datastore.modification;
 
 import com.google.common.util.concurrent.MoreExecutors;
 import java.util.Optional;
-import org.eclipse.jdt.annotation.NonNull;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -18,20 +17,13 @@ import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 
 @Deprecated(since = "9.0.0", forRemoval = true)
 public abstract class AbstractModificationTest {
     private static EffectiveModelContext TEST_SCHEMA_CONTEXT;
 
-    static final @NonNull ContainerNode TEST_CONTAINER = ImmutableNodes.newContainerBuilder()
-        .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-        .build();
-
     protected InMemoryDOMDataStore store;
 
     @BeforeClass
index f1cb4870a3ba7c8fcce94846281ff37f7c66b222..cc74077a781763986549c83766741fd0182023ce 100644 (file)
@@ -23,12 +23,12 @@ public class DeleteModificationTest extends AbstractModificationTest {
     public void testApply() throws Exception {
         // Write something into the datastore
         DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction();
-        WriteModification writeModification = new WriteModification(TestModel.TEST_PATH, TEST_CONTAINER);
+        WriteModification writeModification = new WriteModification(TestModel.TEST_PATH, TestModel.EMPTY_TEST);
         writeModification.apply(writeTransaction);
         commitTransaction(writeTransaction);
 
         // Check if it's in the datastore
-        assertEquals(Optional.of(TEST_CONTAINER), readData(TestModel.TEST_PATH));
+        assertEquals(Optional.of(TestModel.EMPTY_TEST), readData(TestModel.TEST_PATH));
 
         // Delete stuff from the datastore
         DOMStoreWriteTransaction deleteTransaction = store.newWriteOnlyTransaction();
index aaf3e36752e99343f5ccf76015ca08c5a88bb8ee..6a187aac73b1c42393efb1a8375181db99763da9 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.controller.cluster.datastore.modification;
 
 import static org.junit.Assert.assertEquals;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.containerNode;
 
 import java.util.Optional;
 import org.apache.commons.lang3.SerializationUtils;
@@ -26,13 +25,12 @@ public class MergeModificationTest extends AbstractModificationTest {
 
         //Write something into the datastore
         DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction();
-        MergeModification writeModification = new MergeModification(TestModel.TEST_PATH,
-                containerNode(TestModel.TEST_QNAME));
+        MergeModification writeModification = new MergeModification(TestModel.TEST_PATH, TestModel.EMPTY_TEST);
         writeModification.apply(writeTransaction);
         commitTransaction(writeTransaction);
 
         //Check if it's in the datastore
-        assertEquals(Optional.of(TEST_CONTAINER), readData(TestModel.TEST_PATH));
+        assertEquals(Optional.of(TestModel.EMPTY_TEST), readData(TestModel.TEST_PATH));
     }
 
     @Test
index fbfd4468e9d173567e89cf4e4822f071b9689b8e..b5f68aa4561a75a74d24237635b41ba06558dc31 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.controller.cluster.datastore.modification;
 
 import static org.junit.Assert.assertEquals;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.containerNode;
 
 import org.apache.commons.lang3.SerializationUtils;
 import org.junit.Test;
@@ -25,8 +24,7 @@ public class MutableCompositeModificationTest extends AbstractModificationTest {
     @Test
     public void testApply() throws Exception {
         MutableCompositeModification compositeModification = new MutableCompositeModification();
-        compositeModification.addModification(new WriteModification(TestModel.TEST_PATH,
-            containerNode(TestModel.TEST_QNAME)));
+        compositeModification.addModification(new WriteModification(TestModel.TEST_PATH, TestModel.EMPTY_TEST));
 
         DOMStoreReadWriteTransaction transaction = store.newReadWriteTransaction();
         compositeModification.apply(transaction);
index 58a61341a6a9bd554bce002e6a1ed557c570f6df..7b7a40572d64b88416f1da3fac4f56f0e312c9eb 100644 (file)
@@ -23,12 +23,12 @@ public class WriteModificationTest extends AbstractModificationTest {
     public void testApply() throws Exception {
         //Write something into the datastore
         DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction();
-        WriteModification writeModification = new WriteModification(TestModel.TEST_PATH, TEST_CONTAINER);
+        WriteModification writeModification = new WriteModification(TestModel.TEST_PATH, TestModel.EMPTY_TEST);
         writeModification.apply(writeTransaction);
         commitTransaction(writeTransaction);
 
         //Check if it's in the datastore
-        assertEquals(Optional.of(TEST_CONTAINER), readData(TestModel.TEST_PATH));
+        assertEquals(Optional.of(TestModel.EMPTY_TEST), readData(TestModel.TEST_PATH));
     }
 
     @Test
index d8bbdcf71d05af6d4af0da4989da708db51b7263..3deb4a96c54136ed216cf3a1dc65e1f813caea21 100644 (file)
@@ -10,8 +10,8 @@ package org.opendaylight.controller.cluster.datastore.utils;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-import com.google.common.collect.ImmutableList;
 import java.util.Collection;
+import java.util.List;
 import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Executors;
@@ -38,18 +38,16 @@ public class NormalizedNodeAggregatorTest {
     @Test
     public void testAggregate() throws InterruptedException, ExecutionException, DataValidationFailedException {
         EffectiveModelContext schemaContext = SchemaContextHelper.full();
-        NormalizedNode expectedNode1 = ImmutableNodes.newContainerBuilder()
-            .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-            .build();
-        NormalizedNode expectedNode2 = ImmutableNodes.newContainerBuilder()
+        final var expectedNode1 = TestModel.EMPTY_TEST;
+        final var expectedNode2 = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(CarsModel.CARS_QNAME))
             .build();
 
         Optional<NormalizedNode> optional = NormalizedNodeAggregator.aggregate(YangInstanceIdentifier.of(),
-                ImmutableList.of(
-                        Optional.<NormalizedNode>of(getRootNode(expectedNode1, schemaContext)),
-                        Optional.<NormalizedNode>of(getRootNode(expectedNode2, schemaContext))),
-                schemaContext, LogicalDatastoreType.CONFIGURATION);
+            List.of(
+                Optional.<NormalizedNode>of(getRootNode(expectedNode1, schemaContext)),
+                Optional.<NormalizedNode>of(getRootNode(expectedNode2, schemaContext))),
+            schemaContext, LogicalDatastoreType.CONFIGURATION);
 
 
         NormalizedNode normalizedNode = optional.orElseThrow();
index 8c563d3f29d9d38b1168ddeca6f629b858b05ea4..23be3634bc6fc4d8feff8a1a32311713f7581dea 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.md.cluster.datastore.model;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
@@ -54,6 +55,10 @@ public final class TestModel {
     public static final QName TWO_QNAME = QName.create(TEST_QNAME,"two");
     public static final QName THREE_QNAME = QName.create(TEST_QNAME,"three");
 
+    public static final @NonNull ContainerNode EMPTY_TEST = ImmutableNodes.newContainerBuilder()
+        .withNodeIdentifier(new NodeIdentifier(TEST_QNAME))
+        .build();
+
     private TestModel() {
         // Hidden on purpose
     }