+ public void testOnReceiveBatchedModificationsReadyWithImmediateCommit() {
+ final ActorRef transaction = newTransactionActor(WO, readWriteTransaction(),
+ "testOnReceiveBatchedModificationsReadyWithImmediateCommit");
+
+ TestKit watcher = new TestKit(getSystem());
+ watcher.watch(transaction);
+
+ YangInstanceIdentifier writePath = TestModel.TEST_PATH;
+ NormalizedNode<?, ?> writeData = ImmutableContainerNodeBuilder.create()
+ .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
+ .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();
+
+ BatchedModifications batched = new BatchedModifications(nextTransactionId(),
+ DataStoreVersions.CURRENT_VERSION);
+ batched.addModification(new WriteModification(writePath, writeData));
+ batched.setReady();
+ batched.setDoCommitOnReady(true);
+ batched.setTotalMessagesSent(1);
+
+ transaction.tell(batched, testKit.getRef());
+ testKit.expectMsgClass(Duration.ofSeconds(5), CommitTransactionReply.class);
+ watcher.expectMsgClass(Duration.ofSeconds(5), Terminated.class);
+ }
+
+ @Test(expected = TestException.class)
+ public void testOnReceiveBatchedModificationsFailure() throws Exception {
+ ShardDataTreeTransactionParent parent = mock(ShardDataTreeTransactionParent.class);
+ DataTreeModification mockModification = mock(DataTreeModification.class);
+ ReadWriteShardDataTreeTransaction mockWriteTx = new ReadWriteShardDataTreeTransaction(parent,
+ nextTransactionId(), mockModification);
+ final ActorRef transaction = newTransactionActor(RW, mockWriteTx,
+ "testOnReceiveBatchedModificationsFailure");
+
+ TestKit watcher = new TestKit(getSystem());
+ watcher.watch(transaction);
+
+ YangInstanceIdentifier path = TestModel.TEST_PATH;
+ ContainerNode node = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+
+ doThrow(new TestException()).when(mockModification).write(path, node);
+
+ final TransactionIdentifier tx1 = nextTransactionId();
+ BatchedModifications batched = new BatchedModifications(tx1, DataStoreVersions.CURRENT_VERSION);
+ batched.addModification(new WriteModification(path, node));
+
+ transaction.tell(batched, testKit.getRef());
+ testKit.expectMsgClass(Duration.ofSeconds(5), akka.actor.Status.Failure.class);
+
+ batched = new BatchedModifications(tx1, DataStoreVersions.CURRENT_VERSION);
+ batched.setReady();
+ batched.setTotalMessagesSent(2);