TransactionProxy extends AbstractDOMStoreTransaction<TransactionIdentifier> implements DOMStoreReadWriteTransaction { @Override public final void close() { if (!seal(TransactionState.CLOSED)) { checkState(state == TransactionState.CLOSED, "Transaction %s is ready, it cannot be closed", getIdentifier()); return; } for (TransactionContextWrapper contextWrapper : txContextWrappers.values()) { contextWrapper.maybeExecuteTransactionOperation(new TransactionOperation() { @Override public void invoke(final TransactionContext transactionContext, final Boolean havePermit) { transactionContext.closeTransaction(); } }); } txContextWrappers.clear(); } @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 testClose() { ActorRef actorRef = setupActorContextWithInitialCreateTransaction(getSystem(), READ_WRITE); doReturn(readDataReply(null)).when(mockActorContext).executeOperationAsync( eq(actorSelection(actorRef)), eqReadData(), any(Timeout.class)); TransactionProxy transactionProxy = new TransactionProxy(mockComponentFactory, READ_WRITE); transactionProxy.read(TestModel.TEST_PATH); transactionProxy.close(); verify(mockActorContext).sendOperationAsync( eq(actorSelection(actorRef)), isA(CloseTransaction.class)); }