Search in sources :

Example 1 with JPATest

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

the class JPATestRunner method rules.

@Override
protected List<MethodRule> rules(Object test) {
    verify(test instanceof JPATest, "In order to use the %s for %s, it should (directly or indirectly) implement %s", JPATestRunner.class.getSimpleName(), test.getClass(), JPATest.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 {
                    ((JPATest) target).setEntityManager(entityManager);
                    base.evaluate();
                }
            };
        }
    });
    return rules;
}
Also used : JPATest(com.querydsl.jpa.JPATest) MethodRule(org.junit.rules.MethodRule) Statement(org.junit.runners.model.Statement) FrameworkMethod(org.junit.runners.model.FrameworkMethod)

Aggregations

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