@Test public void testSuccess() { mockery.checking(new Expectations() { { oneOf(transactionManager).getTransaction(with(any(DefaultTransactionDefinition.class))); will(returnValue(transaction)); oneOf(dao).execute(with(same(request))); will(returnValue(response)); oneOf(transactionManager).commit(with(same(transaction))); } }); Object result = sut.execute(request); mockery.assertIsSatisfied(); assertSame(response, result); }
@Override public RS execute(final RQ inRequest) { DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setReadOnly(true); TransactionStatus currentStatus = transManager.getTransaction(transDef); try { RS result = dao.execute(inRequest); transManager.commit(currentStatus); return result; } catch (RuntimeException ex) { transManager.rollback(currentStatus); throw ex; } }
MapperTransactionDecorator implements DomainMapper<RQ, RS> { @Override public RS execute(final RQ inRequest) { DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setReadOnly(true); TransactionStatus currentStatus = transManager.getTransaction(transDef); try { RS result = dao.execute(inRequest); transManager.commit(currentStatus); return result; } catch (RuntimeException ex) { transManager.rollback(currentStatus); throw ex; } } }
MapperTransactionDecorator implements DomainMapper<RQ, RS> { @Override public RS execute(final RQ inRequest) { DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setReadOnly(true); TransactionStatus currentStatus = transManager.getTransaction(transDef); try { RS result = dao.execute(inRequest); transManager.commit(currentStatus); return result; } catch (RuntimeException ex) { transManager.rollback(currentStatus); throw ex; } } MapperTransactionDecorator(final DomainMapper<RQ, RS> inDao, final PlatformTransactionManager inTransManager); }
MapperTransactionDecorator implements DomainMapper<RQ, RS> { @Override public RS execute(final RQ inRequest) { DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setReadOnly(true); TransactionStatus currentStatus = transManager.getTransaction(transDef); try { RS result = dao.execute(inRequest); transManager.commit(currentStatus); return result; } catch (RuntimeException ex) { transManager.rollback(currentStatus); throw ex; } } MapperTransactionDecorator(final DomainMapper<RQ, RS> inDao, final PlatformTransactionManager inTransManager); @Override RS execute(final RQ inRequest); }
MapperTransactionDecorator implements DomainMapper<RQ, RS> { @Override public RS execute(final RQ inRequest) { DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setReadOnly(true); TransactionStatus currentStatus = transManager.getTransaction(transDef); try { RS result = dao.execute(inRequest); transManager.commit(currentStatus); return result; } catch (RuntimeException ex) { transManager.rollback(currentStatus); throw ex; } } MapperTransactionDecorator(final DomainMapper<RQ, RS> inDao, final PlatformTransactionManager inTransManager); @Override RS execute(final RQ inRequest);  }