@Test public void testCreateTransactionCreateNewTransactionIfOldNotActive() throws ODataJPATransactionException { when(transaction.isActive()).thenReturn(false); cut = new JPAODataDefaultTransactionFactory(em); cut.createTransaction(); assertNotNull(cut.createTransaction()); }
@Override public JPAODataTransaction createTransaction() throws ODataJPATransactionException { try { if (currentTransaction != null && currentTransaction.isActive()) throw new ODataJPATransactionException(CANNOT_CREATE_NEW_TRANSACTION); currentTransaction = new JPAODataEntityTransaction(em.getTransaction()); return currentTransaction; } catch (Exception e) { throw new ODataJPATransactionException(CANNOT_CREATE_NEW_TRANSACTION); } }
JPAODataDefaultTransactionFactory implements JPAODataTransactionFactory { @Override public JPAODataTransaction createTransaction() throws ODataJPATransactionException { try { if (currentTransaction != null && currentTransaction.isActive()) throw new ODataJPATransactionException(CANNOT_CREATE_NEW_TRANSACTION); currentTransaction = new JPAODataEntityTransaction(em.getTransaction()); return currentTransaction; } catch (Exception e) { throw new ODataJPATransactionException(CANNOT_CREATE_NEW_TRANSACTION); } } }
JPAODataDefaultTransactionFactory implements JPAODataTransactionFactory { @Override public JPAODataTransaction createTransaction() throws ODataJPATransactionException { try { if (currentTransaction != null && currentTransaction.isActive()) throw new ODataJPATransactionException(CANNOT_CREATE_NEW_TRANSACTION); currentTransaction = new JPAODataEntityTransaction(em.getTransaction()); return currentTransaction; } catch (Exception e) { throw new ODataJPATransactionException(CANNOT_CREATE_NEW_TRANSACTION); } } JPAODataDefaultTransactionFactory(@Nonnull final EntityManager em); }
JPAODataDefaultTransactionFactory implements JPAODataTransactionFactory { @Override public JPAODataTransaction createTransaction() throws ODataJPATransactionException { try { if (currentTransaction != null && currentTransaction.isActive()) throw new ODataJPATransactionException(CANNOT_CREATE_NEW_TRANSACTION); currentTransaction = new JPAODataEntityTransaction(em.getTransaction()); return currentTransaction; } catch (Exception e) { throw new ODataJPATransactionException(CANNOT_CREATE_NEW_TRANSACTION); } } JPAODataDefaultTransactionFactory(@Nonnull final EntityManager em); @Override JPAODataTransaction createTransaction(); @Override boolean hasActiveTransaction(); }
JPAODataDefaultTransactionFactory implements JPAODataTransactionFactory { @Override public JPAODataTransaction createTransaction() throws ODataJPATransactionException { try { if (currentTransaction != null && currentTransaction.isActive()) throw new ODataJPATransactionException(CANNOT_CREATE_NEW_TRANSACTION); currentTransaction = new JPAODataEntityTransaction(em.getTransaction()); return currentTransaction; } catch (Exception e) { throw new ODataJPATransactionException(CANNOT_CREATE_NEW_TRANSACTION); } } JPAODataDefaultTransactionFactory(@Nonnull final EntityManager em); @Override JPAODataTransaction createTransaction(); @Override boolean hasActiveTransaction();  }