TransactionManagerImpl implements TransactionManager, TransactionCompletionListener { public Transaction getCurrentTransaction() { Deque<Transaction> stack = transactions.get(); if (stack != null) { return stack.peek(); } else { return null; } } @Inject  TransactionManagerImpl(TransactionFactory factory, TransactionInMemoryCache memCache); Transaction beginTransaction(); Transaction beginTransaction(boolean isolatedTransaction); Transaction getCurrentTransaction(); void transactionComplete(TransactionCompletionEvent event);  }
@Test public void testNonExistingTransaction() { Injector injector = initializeInjector(); final TransactionManager manager = injector.getInstance(TransactionManager.class); mockery.checking(new Expectations() { { } }); Assert.assertNull(manager.getCurrentTransaction()); mockery.assertIsSatisfied(); }