Transactional { public Transactional<O> wrap(Action<O> action) { if (action == null) { throw new IllegalArgumentException("action is null"); } if (this.action != null) { throw new IllegalStateException("action already set"); } this.action = action; return this; } Transactional(EntityManager entityManager); Transactional<O> wrap(Action<O> action); Transactional<O> onCommit(Listener listener); Transactional<O> onRollback(Listener listener); Transactional<O> onComplete(Listener listener); Transactional<O> commitIf(Validator<O> validator); Transactional<O> rollbackIf(Validator<O> validator); Transactional<O> commitOnException(); Transactional<O> allowExistingTransactions(); O execute(Object... args);  }
@Test public void testActionAssignmentOnlyOnce() throws Exception { Transactional transactional = this.buildTransactional(); transactional.wrap(args -> "action"); assertThrows(IllegalStateException.class, () -> transactional.wrap(args -> "action")); }