public boolean rollbackOn(Throwable ex) {

        RollbackRule winner = null;
        int deepest = Integer.MAX_VALUE;

        if (CollectionUtils.isNotEmpty(rollbackRules)) {
            winner = NoRollbackRule.DEFAULT_NO_ROLLBACK_RULE;
            for (RollbackRule rule : this.rollbackRules) {
                int depth = rule.getDepth(ex);
                if (depth >= 0 && depth < deepest) {
                    deepest = depth;
                    winner = rule;
                }
            }
        }

        return !(winner instanceof NoRollbackRule);
    }
@Test
    public void testRollBackOn() {
        TransactionInfo txInfo = new TransactionInfo();

        //default true
        assertThat(txInfo.rollbackOn(new IllegalArgumentException())).isTrue();
        assertThat(txInfo.rollbackOn(new Exception())).isTrue();
        assertThat(txInfo.rollbackOn(new IOException())).isTrue();
        assertThat(txInfo.rollbackOn(new NullPointerException())).isTrue();

        Set<RollbackRule> sets = getRollbackRules();
        txInfo.setRollbackRules(sets);

        assertThat(txInfo.rollbackOn(new IllegalArgumentException())).isTrue();
        assertThat(txInfo.rollbackOn(new IllegalStateException())).isTrue();
        assertThat(txInfo.rollbackOn(new IOException())).isFalse();
        assertThat(txInfo.rollbackOn(new NullPointerException())).isFalse();

        // not found return false
        assertThat(txInfo.rollbackOn(new MyRuntimeException("test"))).isFalse();
        assertThat(txInfo.rollbackOn(new RuntimeException())).isFalse();
        assertThat(txInfo.rollbackOn(new Throwable())).isFalse();
    }