TransactionProxy extends AbstractDOMStoreTransaction<TransactionIdentifier> implements DOMStoreReadWriteTransaction { @Override public void write(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) { checkModificationState("write", path); if (path.isEmpty()) { writeAllData(checkRootData(data)); } else { executeModification(new WriteOperation(path, data)); } } @VisibleForTesting  TransactionProxy(final AbstractTransactionContextFactory<?> txContextFactory, final TransactionType type); @Override FluentFuture<Boolean> exists(final YangInstanceIdentifier path); @Override FluentFuture<Optional<NormalizedNode<?, ?>>> read(final YangInstanceIdentifier path); @Override void delete(final YangInstanceIdentifier path); @Override void merge(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data); @Override void write(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data); @Override final void close(); @Override final AbstractThreePhaseCommitCohort<?> ready();  }
@Test public void testWrite() { dataStoreContextBuilder.shardBatchedModificationCount(1); ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), WRITE_ONLY); NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME); expectBatchedModifications(actorRef, 1); TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, WRITE_ONLY); transactionProxy.write(TestModel.TEST_PATH, nodeToWrite); verifyOneBatchedModification(actorRef, new WriteModification(TestModel.TEST_PATH, nodeToWrite), false); }
@Test(expected = IllegalStateException.class) public void testWritePreConditionCheck() { TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, READ_ONLY); transactionProxy.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); }
@Test public void testWriteCompletionForLocalShard() { completeOperationLocal(transactionProxy -> { NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME); transactionProxy.write(TestModel.TEST_PATH, nodeToWrite); transactionProxy.write(TestModel.TEST_PATH, nodeToWrite); }, createDataTree()); }
@Test public void testWriteThrottlingWhenShardFound() { throttleOperation(transactionProxy -> { NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME); expectIncompleteBatchedModifications(); transactionProxy.write(TestModel.TEST_PATH, nodeToWrite); transactionProxy.write(TestModel.TEST_PATH, nodeToWrite); }); }
@Test public void testWriteThrottlingWhenShardNotFound() { completeOperation(transactionProxy -> { NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME); expectBatchedModifications(2); transactionProxy.write(TestModel.TEST_PATH, nodeToWrite); transactionProxy.write(TestModel.TEST_PATH, nodeToWrite); }, false); }
@Test public void testWriteCompletion() { completeOperation(transactionProxy -> { NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME); expectBatchedModifications(2); transactionProxy.write(TestModel.TEST_PATH, nodeToWrite); transactionProxy.write(TestModel.TEST_PATH, nodeToWrite); }); }