### Question:
JPAContext { public void beginTxn() { if (isTxnOpen()) { return; } getEntityManager().getTransaction().begin(); } JPAContext(JPAConfig jpaConfig, boolean readOnly); EntityManager getEntityManager(); void close(); void beginTxn(); void closeTxn(boolean rollback); boolean isTxnOpen(); boolean isReadOnly();  }### Answer:
@Test public void shouldBeginTransaction() { EntityTransaction txn = mockTransaction(context, false); context.beginTxn(); verify(txn).begin(); }
@Test public void shouldNotBeginTransaction() { EntityTransaction txn = mockTransaction(context, true); context.beginTxn(); verify(txn, never()).begin(); }