@SuppressWarnings("unchecked") @Test public void testExecute() { final EntityManager entityManager = context.mock(EntityManager.class); final PersistenceRequest req = context.mock(PersistenceRequest.class); final Activity msg = context.mock(Activity.class); InsertMapper sut = new InsertMapper(); sut.setEntityManager(entityManager); context.checking(new Expectations() { { allowing(req).getDomainEnity(); will(returnValue(msg)); oneOf(entityManager).persist(msg); oneOf(msg).getId(); will(returnValue(2L)); } }); assertEquals(2L, sut.execute(req).longValue()); context.assertIsSatisfied(); }
@Override public Long execute(final PersistenceRequest<TDomainEntityType> inRequest) { getEntityManager().persist(inRequest.getDomainEnity()); return inRequest.getDomainEnity().getId(); }
InsertMapper extends
        BaseArgDomainMapper<PersistenceRequest<TDomainEntityType>, Long> { @Override public Long execute(final PersistenceRequest<TDomainEntityType> inRequest) { getEntityManager().persist(inRequest.getDomainEnity()); return inRequest.getDomainEnity().getId(); } }
InsertMapper extends
        BaseArgDomainMapper<PersistenceRequest<TDomainEntityType>, Long> { @Override public Long execute(final PersistenceRequest<TDomainEntityType> inRequest) { getEntityManager().persist(inRequest.getDomainEnity()); return inRequest.getDomainEnity().getId(); }  }
InsertMapper extends
        BaseArgDomainMapper<PersistenceRequest<TDomainEntityType>, Long> { @Override public Long execute(final PersistenceRequest<TDomainEntityType> inRequest) { getEntityManager().persist(inRequest.getDomainEnity()); return inRequest.getDomainEnity().getId(); }  @Override Long execute(final PersistenceRequest<TDomainEntityType> inRequest); }
InsertMapper extends
        BaseArgDomainMapper<PersistenceRequest<TDomainEntityType>, Long> { @Override public Long execute(final PersistenceRequest<TDomainEntityType> inRequest) { getEntityManager().persist(inRequest.getDomainEnity()); return inRequest.getDomainEnity().getId(); }  @Override Long execute(final PersistenceRequest<TDomainEntityType> inRequest);  }