Transactional { public Transactional<O> rollbackIf(Validator<O> validator) { if (validator == null) { throw new IllegalArgumentException("validator is null"); } this.validators.add(output -> !validator.validate(output)); 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 testSetRollbackValidator() { Transactional transactional = this.buildTransactional(); transactional.rollbackIf(output -> true); }
@Test public void testSetMultipleRollbackValidators() { Transactional transactional = this.buildTransactional(); transactional.rollbackIf(output -> true); transactional.rollbackIf(output -> true); }
@Test public void testSetSameRollbackValidatorRepeatedly() { Transactional transactional = this.buildTransactional(); Transactional.Validator validator = output -> true; transactional.rollbackIf(validator); transactional.rollbackIf(validator); }
@Test public void testCannotSetNullRollbackValidator() { Transactional transactional = this.buildTransactional(); assertThrows(IllegalArgumentException.class, () -> transactional.rollbackIf(null)); }