use of io.crnk.core.engine.transaction.TransactionRunner in project crnk-framework by crnk-project.
the class CdiTransactionRunnerTest method setup.
@Before
public void setup() {
DefaultServiceDiscoveryFactory factory = new DefaultServiceDiscoveryFactory();
ServiceDiscovery instance = factory.getInstance();
List<TransactionRunner> runners = instance.getInstancesByType(TransactionRunner.class);
Assert.assertEquals(1, runners.size());
runner = runners.get(0);
}
use of io.crnk.core.engine.transaction.TransactionRunner in project crnk-framework by crnk-project.
the class TransactionOperationFilter method filter.
@Override
public List<OperationResponse> filter(final OperationFilterContext context, final OperationFilterChain chain) {
ServiceDiscovery serviceDiscovery = context.getServiceDiscovery();
List<TransactionRunner> transactionRunners = serviceDiscovery.getInstancesByType(TransactionRunner.class);
PreconditionUtil.assertEquals("expected single transaction runner", 1, transactionRunners.size());
TransactionRunner transactionRunner = transactionRunners.get(0);
return transactionRunner.doInTransaction(new Callable<List<OperationResponse>>() {
@Override
public List<OperationResponse> call() throws Exception {
return chain.doFilter(context);
}
});
}
use of io.crnk.core.engine.transaction.TransactionRunner in project crnk-framework by crnk-project.
the class QueryFactoryDiscoveryTest method checkJpaModuleIntegration.
@Test
public void checkJpaModuleIntegration() {
TransactionRunner transactionRunner = Mockito.mock(TransactionRunner.class);
EntityManager em = Mockito.mock(EntityManager.class);
JpaModule module = JpaModule.newServerModule(em, transactionRunner);
Assert.assertEquals(QuerydslQueryFactory.class, module.getQueryFactory().getClass());
}
use of io.crnk.core.engine.transaction.TransactionRunner in project crnk-framework by crnk-project.
the class JpaModuleTest method cannotPerformDuplicateRegistration.
@Test(expected = IllegalStateException.class)
public void cannotPerformDuplicateRegistration() {
TransactionRunner transactionRunner = Mockito.mock(TransactionRunner.class);
EntityManager em = Mockito.mock(EntityManager.class);
JpaModule module = JpaModule.newServerModule(em, transactionRunner);
module.addRepository(JpaRepositoryConfig.create(TestEntity.class));
module.addRepository(JpaRepositoryConfig.create(TestEntity.class));
}
Aggregations