### Question:
TransactionalMessageSender implements MessageSender<TypedMessage>, TransactionalResource { @Override public void begin() throws TransactionException { if (currentTransaction.get() != null) { throw new NestedTransactionException(currentTransaction.get()); } currentTransaction.set(new MessagingTransaction()); logger.trace("Beginning transaction: " + currentTransaction.get().transactionId()); } TransactionalMessageSender(final MessageSender<TypedMessage> messageSender); @Override void begin(); @Override void commit(); @Override void send(final TypedMessage typedMessage); @Override void sendDelayedMessage(final TypedMessage typedMessage, final int delay); @Override void abort();  }### Answer:
@Test public void shouldBeginTransaction_withNoExistingTransaction() throws Exception { final TransactionalMessageSender transactionalMessageSender = new TransactionalMessageSender(mockMessageSender); Exception actualException = null; try { transactionalMessageSender.begin(); } catch (final Exception e) { actualException = e; } assertNull(actualException); }
@Test public void shouldNotBeginTransaction_withExistingTransaction() throws Exception { final TransactionalMessageSender transactionalMessageSender = new TransactionalMessageSender(mockMessageSender); transactionalMessageSender.begin(); NestedTransactionException actualException = null; try { transactionalMessageSender.begin(); } catch (final NestedTransactionException e) { actualException = e; } assertNotNull(actualException); }