LocalTransactionContext extends AbstractTransactionContext { @Override public <T> void executeRead(final AbstractRead<T> readCmd, final SettableFuture<T> proxyFuture, final Boolean havePermit) { Futures.addCallback(readCmd.apply(getReadDelegate()), new FutureCallback<T>() { @Override public void onSuccess(final T result) { proxyFuture.set(result); } @Override public void onFailure(final Throwable failure) { proxyFuture.setException(failure instanceof Exception ? ReadFailedException.MAPPER.apply((Exception) failure) : failure); } }, MoreExecutors.directExecutor()); } LocalTransactionContext(final DOMStoreTransaction txDelegate, final TransactionIdentifier identifier,
            final LocalTransactionReadySupport readySupport); @Override void executeDelete(final YangInstanceIdentifier path, final Boolean havePermit); @Override void executeMerge(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data,
            final Boolean havePermit); @Override void executeWrite(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data,
            final Boolean havePermit); @Override void executeRead(final AbstractRead<T> readCmd, final SettableFuture<T> proxyFuture,
            final Boolean havePermit); @Override Future<ActorSelection> readyTransaction(final Boolean havePermit,
            final Optional<SortedSet<String>> participatingShardNames); @Override Future<Object> directCommit(final Boolean havePermit); @Override void closeTransaction();  }
@Test public void testRead() { YangInstanceIdentifier yangInstanceIdentifier = YangInstanceIdentifier.empty(); NormalizedNode<?, ?> normalizedNode = mock(NormalizedNode.class); doReturn(FluentFutures.immediateFluentFuture(Optional.of(normalizedNode))).when(readWriteTransaction) .read(yangInstanceIdentifier); localTransactionContext.executeRead(new ReadData(yangInstanceIdentifier, DataStoreVersions.CURRENT_VERSION), SettableFuture.create(), null); verify(readWriteTransaction).read(yangInstanceIdentifier); }
@Test public void testExists() { YangInstanceIdentifier yangInstanceIdentifier = YangInstanceIdentifier.empty(); doReturn(FluentFutures.immediateTrueFluentFuture()).when(readWriteTransaction).exists(yangInstanceIdentifier); localTransactionContext.executeRead(new DataExists(yangInstanceIdentifier, DataStoreVersions.CURRENT_VERSION), SettableFuture.create(), null); verify(readWriteTransaction).exists(yangInstanceIdentifier); }