PentahoTransactionManager extends LocalTransactionManager { public TransactionDefinition getTransactionDefinition() { return activeTransactionDefinition.get(); }  TransactionDefinition getTransactionDefinition(); boolean isCreatingTransaction();  }
@Test public void getTransactionDefinition() throws Exception { PentahoTransactionManager transactionManager = new PentahoTransactionManager(); SessionFactory sessionFactory = mock( SessionFactory.class ); XASession xaSession = mock( XASession.class ); when( xaSession.getXAResource() ).thenReturn( mock( XAResource.class ) ); transactionManager.setSessionFactory( sessionFactory ); TransactionDefinition transactionDefinition = mock( TransactionDefinition.class ); when( transactionDefinition.getIsolationLevel() ).thenReturn( -1 ); AtomicBoolean wasAvailable = new AtomicBoolean( false ); when( sessionFactory.getSession() ).then( invocation -> { assertEquals( transactionDefinition, transactionManager.getTransactionDefinition() ); wasAvailable.set( true ); return xaSession; } ); transactionManager.getTransaction( transactionDefinition ); assertTrue( wasAvailable.get() ); assertNull( transactionManager.getTransactionDefinition() ); }