Search in sources :

Example 1 with HibernateTest

use of com.querydsl.jpa.HibernateTest in project querydsl by querydsl.

the class HibernateTestRunner method rules.

@Override
protected List<MethodRule> rules(Object test) {
    verify(test instanceof HibernateTest, "In order to use the %s for %s, it should (directly or indirectly) implement %s", HibernateTestRunner.class.getSimpleName(), test.getClass(), HibernateTest.class);
    List<MethodRule> rules = super.rules(test);
    rules.add(new MethodRule() {

        @Override
        public Statement apply(final Statement base, FrameworkMethod method, final Object target) {
            return new Statement() {

                @Override
                public void evaluate() throws Throwable {
                    ((HibernateTest) target).setSession(session);
                    base.evaluate();
                }
            };
        }
    });
    return rules;
}
Also used : MethodRule(org.junit.rules.MethodRule) Statement(org.junit.runners.model.Statement) HibernateTest(com.querydsl.jpa.HibernateTest) FrameworkMethod(org.junit.runners.model.FrameworkMethod)

Aggregations

HibernateTest (com.querydsl.jpa.HibernateTest)1 MethodRule (org.junit.rules.MethodRule)1 FrameworkMethod (org.junit.runners.model.FrameworkMethod)1 Statement (org.junit.runners.model.Statement)1