### Question:
TransactionalDatabaseTemplate implements DatabaseTemplate, TransactionalResource { @Override public void commit() throws TransactionException { final DatabaseTransaction transaction = getCurrentTransaction(); logger.trace("Committing transaction: " + transaction.transactionId()); try { transaction.applyActions(databaseTemplate); currentTransaction.remove(); logger.trace("Transaction successfully committed: " + transaction.transactionId()); } catch (final Throwable e) { throw new TransactionalResourceException("Failed to commit DatabaseTemplate transaction: " + transaction.transactionId(), e); } } TransactionalDatabaseTemplate(final DatabaseTemplate databaseTemplate); @Override void begin(); @Override void commit(); @Override T create(final T item, final PersistenceExceptionHandler<?>... persistenceExceptionHandlers); @Override T update(final T item, final PersistenceExceptionHandler<?>... persistenceExceptionHandlers); @Override void delete(final Item item, final PersistenceExceptionHandler<?>... persistenceExceptionHandlers); @Override T read(final ItemId itemId, final Class<T> itemClass); @Override Collection<T> fetch(final Query query, final Class<T> itemClass); @Override T fetchUnique(final Query query, final Class<T> itemClass); @Override GeneratedKeyHolder generateKeys(final SequenceKeyGenerator sequenceKeyGenerator); @Override void abort();  }### Answer:
@Test public void shouldNotCommit_withNoExistingTransaction() throws Exception { final TransactionalDatabaseTemplate transactionalDatabaseTemplate = new TransactionalDatabaseTemplate( mockDatabaseTemplate); NonExistentTransactionException actualException = null; try { transactionalDatabaseTemplate.commit(); } catch (final NonExistentTransactionException e) { actualException = e; } assertNotNull(actualException); }