@Test public void testRun_WithValidInput_UpdatesEntityProperly() throws Exception { this.target.run(this.em,new CompleteJobTransactionInput(this.existingEntityId, this.existingJobId)); verify(this.testEntity, times(1)).setLastJob(this.testLastJobRecord); }
public Void run(EntityManager em, CompleteJobTransactionInput param) throws Exception { T entity = em.find(this.entityType, param.getEntityId()); if (entity == null) { throw new IllegalArgumentException(String.format("Entity with Id '%d' does not exist.", param.getEntityId())); } JobRecord jobRecord = em.find(JobRecord.class, param.getJobId()); if (jobRecord == null) { throw new IllegalArgumentException(String.format("Job record with id '%d' does not exist.", param.getJobId())); } entity.setLastJob(em.find(JobRecord.class, param.getJobId())); OSCEntityManager.update(em, entity, this.txBroadcastUtil); return null; }
CompleteJobTransaction { public Void run(EntityManager em, CompleteJobTransactionInput param) throws Exception { T entity = em.find(this.entityType, param.getEntityId()); if (entity == null) { throw new IllegalArgumentException(String.format("Entity with Id '%d' does not exist.", param.getEntityId())); } JobRecord jobRecord = em.find(JobRecord.class, param.getJobId()); if (jobRecord == null) { throw new IllegalArgumentException(String.format("Job record with id '%d' does not exist.", param.getJobId())); } entity.setLastJob(em.find(JobRecord.class, param.getJobId())); OSCEntityManager.update(em, entity, this.txBroadcastUtil); return null; } }
CompleteJobTransaction { public Void run(EntityManager em, CompleteJobTransactionInput param) throws Exception { T entity = em.find(this.entityType, param.getEntityId()); if (entity == null) { throw new IllegalArgumentException(String.format("Entity with Id '%d' does not exist.", param.getEntityId())); } JobRecord jobRecord = em.find(JobRecord.class, param.getJobId()); if (jobRecord == null) { throw new IllegalArgumentException(String.format("Job record with id '%d' does not exist.", param.getJobId())); } entity.setLastJob(em.find(JobRecord.class, param.getJobId())); OSCEntityManager.update(em, entity, this.txBroadcastUtil); return null; } CompleteJobTransaction(Class<T> entityType, TransactionalBroadcastUtil txBroadcastUtil); }
CompleteJobTransaction { public Void run(EntityManager em, CompleteJobTransactionInput param) throws Exception { T entity = em.find(this.entityType, param.getEntityId()); if (entity == null) { throw new IllegalArgumentException(String.format("Entity with Id '%d' does not exist.", param.getEntityId())); } JobRecord jobRecord = em.find(JobRecord.class, param.getJobId()); if (jobRecord == null) { throw new IllegalArgumentException(String.format("Job record with id '%d' does not exist.", param.getJobId())); } entity.setLastJob(em.find(JobRecord.class, param.getJobId())); OSCEntityManager.update(em, entity, this.txBroadcastUtil); return null; } CompleteJobTransaction(Class<T> entityType, TransactionalBroadcastUtil txBroadcastUtil); Void run(EntityManager em, CompleteJobTransactionInput param); }
CompleteJobTransaction { public Void run(EntityManager em, CompleteJobTransactionInput param) throws Exception { T entity = em.find(this.entityType, param.getEntityId()); if (entity == null) { throw new IllegalArgumentException(String.format("Entity with Id '%d' does not exist.", param.getEntityId())); } JobRecord jobRecord = em.find(JobRecord.class, param.getJobId()); if (jobRecord == null) { throw new IllegalArgumentException(String.format("Job record with id '%d' does not exist.", param.getJobId())); } entity.setLastJob(em.find(JobRecord.class, param.getJobId())); OSCEntityManager.update(em, entity, this.txBroadcastUtil); return null; } CompleteJobTransaction(Class<T> entityType, TransactionalBroadcastUtil txBroadcastUtil); Void run(EntityManager em, CompleteJobTransactionInput param);  }