@SuppressWarnings("unchecked") @Test public void testExecuteWithWrappedUpdater() { final Sequence sequence = context.sequence("sequence-name"); final EntityManager entityManager = context.mock(EntityManager.class); final PersistenceRequest req = context.mock(PersistenceRequest.class); final UpdateMapper wrappedUpdater = context.mock(UpdateMapper.class); UpdateMapper sut = new UpdateMapper(wrappedUpdater); sut.setEntityManager(entityManager); context.checking(new Expectations() { { oneOf(entityManager).flush(); inSequence(sequence); oneOf(wrappedUpdater).execute(req); inSequence(sequence); } }); assertTrue(sut.execute(req)); context.assertIsSatisfied(); }
public Boolean execute(final PersistenceRequest inRequest) { try { flush(); } catch (OptimisticLockException e) { throw new OutOfDateObjectException("The object could not be modified because another thread has modified " + "it since it was retrieved", e); } if (wrappedUpdater != null) { wrappedUpdater.execute(inRequest); } return true; }
UpdateMapper extends
        BaseArgDomainMapper<PersistenceRequest, Boolean> { public Boolean execute(final PersistenceRequest inRequest) { try { flush(); } catch (OptimisticLockException e) { throw new OutOfDateObjectException("The object could not be modified because another thread has modified " + "it since it was retrieved", e); } if (wrappedUpdater != null) { wrappedUpdater.execute(inRequest); } return true; } }
UpdateMapper extends
        BaseArgDomainMapper<PersistenceRequest, Boolean> { public Boolean execute(final PersistenceRequest inRequest) { try { flush(); } catch (OptimisticLockException e) { throw new OutOfDateObjectException("The object could not be modified because another thread has modified " + "it since it was retrieved", e); } if (wrappedUpdater != null) { wrappedUpdater.execute(inRequest); } return true; } UpdateMapper();  UpdateMapper(final DomainMapper<PersistenceRequest, Boolean> inWrappedUpdater); }
UpdateMapper extends
        BaseArgDomainMapper<PersistenceRequest, Boolean> { public Boolean execute(final PersistenceRequest inRequest) { try { flush(); } catch (OptimisticLockException e) { throw new OutOfDateObjectException("The object could not be modified because another thread has modified " + "it since it was retrieved", e); } if (wrappedUpdater != null) { wrappedUpdater.execute(inRequest); } return true; } UpdateMapper();  UpdateMapper(final DomainMapper<PersistenceRequest, Boolean> inWrappedUpdater); Boolean execute(final PersistenceRequest inRequest); }
UpdateMapper extends
        BaseArgDomainMapper<PersistenceRequest, Boolean> { public Boolean execute(final PersistenceRequest inRequest) { try { flush(); } catch (OptimisticLockException e) { throw new OutOfDateObjectException("The object could not be modified because another thread has modified " + "it since it was retrieved", e); } if (wrappedUpdater != null) { wrappedUpdater.execute(inRequest); } return true; } UpdateMapper();  UpdateMapper(final DomainMapper<PersistenceRequest, Boolean> inWrappedUpdater); Boolean execute(final PersistenceRequest inRequest);  }