@Test public void testCommitRethrowsException() throws ODataJPATransactionException { when(em.getTransaction()).thenReturn(transaction); doThrow(RuntimeException.class).when(transaction).commit(); cut = new JPAODataDefaultTransactionFactory(em); final JPAODataTransaction act = cut.createTransaction(); assertThrows(ODataJPATransactionException.class, () -> act.commit()); }
@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();  }