### Question:
SimpleTransactionExecutor implements TransactionExecutor { @Override public <T> T executeInTransaction(TransactionCallback<T> callback) { return executeInTransaction(callback, RethrowException.getInstance()); } SimpleTransactionExecutor(GraphDatabaseService database); @Override T executeInTransaction(TransactionCallback<T> callback); @Override T executeInTransaction(TransactionCallback<T> callback, ExceptionHandlingStrategy exceptionHandlingStrategy);  }### Answer:
@Test public void nodeShouldBeSuccessfullyCreatedInTransaction() { executor.executeInTransaction(new VoidReturningCallback() { @Override public void doInTx(GraphDatabaseService database) { database.createNode(); } }); try (Transaction tx = database.beginTx()) { assertEquals(2, countNodes(database)); } }
@Test public void nodeShouldBeSuccessfullyDeletedInTransaction() { executor.executeInTransaction(new VoidReturningCallback() { @Override protected void doInTx(GraphDatabaseService database) { database.getNodeById(0).delete(); } }); try (Transaction tx = database.beginTx()) { assertEquals(0, countNodes(database)); } }
@Test(expected = ConstraintViolationException.class) public void deletingNodeWithRelationshipsShouldThrowException() { createNodeAndRelationship(); executor.executeInTransaction(database -> { database.getNodeById(0).delete(); return null; }); }
@Test public void deletingNodeWithRelationshipsShouldNotSucceed() { createNodeAndRelationship(); try (Transaction tx = database.beginTx()) { assertEquals(2, countNodes(database)); } executor.executeInTransaction(db -> { db.getNodeById(0).delete(); return null; }, KeepCalmAndCarryOn.getInstance()); try (Transaction tx = database.beginTx()) { assertEquals(2, countNodes(database)); } }