@Test public void testApplyWithNewReadWriteTransactionCommitFailedException() throws Exception { testableDataBroker.failCommits(new TransactionCommitFailedException("bada boum bam!")); Future<?> future = managedNewTransactionRunner.applyWithNewReadWriteTransactionAndSubmit(OPERATIONAL, writeTx -> { writeTx.put(TEST_PATH, newTestDataObject()); return 1; }); ExecutionException ex = assertThrows(ExecutionException.class, () -> future.get()); assertThat(ex.getCause(), instanceOf(TransactionCommitFailedException.class)); assertEquals(Optional.empty(), syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); }
@Override @CheckReturnValue public <D extends Datastore, E extends Exception, R> FluentFuture<R> applyWithNewReadWriteTransactionAndSubmit( final Class<D> datastoreType, final InterruptibleCheckedFunction<TypedReadWriteTransaction<D>, R, E> txFunction) { return super.applyWithNewTransactionAndSubmit(datastoreType, getTransactionFactory()::newReadWriteTransaction, WriteTrackingTypedReadWriteTransactionImpl::new, txFunction::apply, this::commit); }
ManagedNewTransactionRunnerImpl extends ManagedTransactionFactoryImpl<DataBroker> implements ManagedNewTransactionRunner { @Override @CheckReturnValue public <D extends Datastore, E extends Exception, R> FluentFuture<R> applyWithNewReadWriteTransactionAndSubmit( final Class<D> datastoreType, final InterruptibleCheckedFunction<TypedReadWriteTransaction<D>, R, E> txFunction) { return super.applyWithNewTransactionAndSubmit(datastoreType, getTransactionFactory()::newReadWriteTransaction, WriteTrackingTypedReadWriteTransactionImpl::new, txFunction::apply, this::commit); } }
ManagedNewTransactionRunnerImpl extends ManagedTransactionFactoryImpl<DataBroker> implements ManagedNewTransactionRunner { @Override @CheckReturnValue public <D extends Datastore, E extends Exception, R> FluentFuture<R> applyWithNewReadWriteTransactionAndSubmit( final Class<D> datastoreType, final InterruptibleCheckedFunction<TypedReadWriteTransaction<D>, R, E> txFunction) { return super.applyWithNewTransactionAndSubmit(datastoreType, getTransactionFactory()::newReadWriteTransaction, WriteTrackingTypedReadWriteTransactionImpl::new, txFunction::apply, this::commit); } @Inject  ManagedNewTransactionRunnerImpl(final DataBroker broker); }
ManagedNewTransactionRunnerImpl extends ManagedTransactionFactoryImpl<DataBroker> implements ManagedNewTransactionRunner { @Override @CheckReturnValue public <D extends Datastore, E extends Exception, R> FluentFuture<R> applyWithNewReadWriteTransactionAndSubmit( final Class<D> datastoreType, final InterruptibleCheckedFunction<TypedReadWriteTransaction<D>, R, E> txFunction) { return super.applyWithNewTransactionAndSubmit(datastoreType, getTransactionFactory()::newReadWriteTransaction, WriteTrackingTypedReadWriteTransactionImpl::new, txFunction::apply, this::commit); } @Inject  ManagedNewTransactionRunnerImpl(final DataBroker broker); @Override @CheckReturnValue FluentFuture<R> applyWithNewReadWriteTransactionAndSubmit(
            final Class<D> datastoreType,
            final InterruptibleCheckedFunction<TypedReadWriteTransaction<D>, R, E> txFunction); @Override @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE") R applyWithNewTransactionChainAndClose(final Function<ManagedTransactionChain, R> chainConsumer); @Override @CheckReturnValue FluentFuture<? extends Object> callWithNewReadWriteTransactionAndSubmit(final Class<D> datastoreType,
            final InterruptibleCheckedConsumer<TypedReadWriteTransaction<D>, E> txConsumer); @Override @CheckReturnValue FluentFuture<? extends Object> callWithNewWriteOnlyTransactionAndSubmit(final Class<D> datastoreType,
                    final InterruptibleCheckedConsumer<TypedWriteTransaction<D>, E> txConsumer); }
ManagedNewTransactionRunnerImpl extends ManagedTransactionFactoryImpl<DataBroker> implements ManagedNewTransactionRunner { @Override @CheckReturnValue public <D extends Datastore, E extends Exception, R> FluentFuture<R> applyWithNewReadWriteTransactionAndSubmit( final Class<D> datastoreType, final InterruptibleCheckedFunction<TypedReadWriteTransaction<D>, R, E> txFunction) { return super.applyWithNewTransactionAndSubmit(datastoreType, getTransactionFactory()::newReadWriteTransaction, WriteTrackingTypedReadWriteTransactionImpl::new, txFunction::apply, this::commit); } @Inject  ManagedNewTransactionRunnerImpl(final DataBroker broker); @Override @CheckReturnValue FluentFuture<R> applyWithNewReadWriteTransactionAndSubmit(
            final Class<D> datastoreType,
            final InterruptibleCheckedFunction<TypedReadWriteTransaction<D>, R, E> txFunction); @Override @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE") R applyWithNewTransactionChainAndClose(final Function<ManagedTransactionChain, R> chainConsumer); @Override @CheckReturnValue FluentFuture<? extends Object> callWithNewReadWriteTransactionAndSubmit(final Class<D> datastoreType,
            final InterruptibleCheckedConsumer<TypedReadWriteTransaction<D>, E> txConsumer); @Override @CheckReturnValue FluentFuture<? extends Object> callWithNewWriteOnlyTransactionAndSubmit(final Class<D> datastoreType,
                    final InterruptibleCheckedConsumer<TypedWriteTransaction<D>, E> txConsumer);  }