### Question:
JPAContext { public boolean isTxnOpen() { return entityManager != null && entityManager.isOpen() && entityManager.getTransaction() != null && entityManager.getTransaction().isActive(); } JPAContext(JPAConfig jpaConfig, boolean readOnly); EntityManager getEntityManager(); void close(); void beginTxn(); void closeTxn(boolean rollback); boolean isTxnOpen(); boolean isReadOnly();  }### Answer:
@Test public void shouldSayTxnOpen() { mockTransaction(context, true); assertTrue(context.isTxnOpen()); }
@Test public void shouldSayTxnNotOpenWhenInactive() { mockTransaction(context, false); assertFalse(context.isTxnOpen()); }