@Test public void testRestoreProcessInstance() { //given parent execution List<ExecutionEntity> entities = new ArrayList<ExecutionEntity>(); ExecutionEntity parent = new ExecutionEntity(); parent.setId("parent"); entities.add(parent); //when restore process instance is called parent.restoreProcessInstance(entities, null, null, null, null, null, null); //then no problem should occure //when child is added and restore is called again ExecutionEntity entity = new ExecutionEntity(); entity.setId("child"); entity.setParentId(parent.getId()); entities.add(entity); parent.restoreProcessInstance(entities, null, null, null, null, null, null); //then again no problem should occure //when parent is deleted from the list entities.remove(parent); //then exception is thrown because child reference to parent which does not exist anymore thrown.expect(ProcessEngineException.class); thrown.expectMessage("Cannot resolve parent with id 'parent' of execution 'child', perhaps it was deleted in the meantime"); parent.restoreProcessInstance(entities, null, null, null, null, null, null); }
public void execute(DelegateExecution execution) throws Exception { String existingId = execution.getId(); // insert an execution referencing the current execution ExecutionEntity newExecution = new ExecutionEntity(); newExecution.setId("someId"); newExecution.setParentId(existingId); DbEntityOperation insertOperation = new DbEntityOperation(); insertOperation.setOperationType(DbOperationType.INSERT); insertOperation.setEntity(newExecution); Context.getCommandContext() .getDbSqlSession() .executeDbOperation(insertOperation); }
@Test public void testRestoreProcessInstance() { //given parent execution List<ExecutionEntity> entities = new ArrayList<ExecutionEntity>(); ExecutionEntity parent = new ExecutionEntity(); parent.setId("parent"); entities.add(parent); //when restore process instance is called parent.restoreProcessInstance(entities, null, null, null, null, null, null); //then no problem should occure //when child is added and restore is called again ExecutionEntity entity = new ExecutionEntity(); entity.setId("child"); entity.setParentId(parent.getId()); entities.add(entity); parent.restoreProcessInstance(entities, null, null, null, null, null, null); //then again no problem should occure //when parent is deleted from the list entities.remove(parent); //then exception is thrown because child reference to parent which does not exist anymore thrown.expect(ProcessEngineException.class); thrown.expectMessage("Cannot resolve parent with id 'parent' of execution 'child', perhaps it was deleted in the meantime"); parent.restoreProcessInstance(entities, null, null, null, null, null, null); }
public void execute(DelegateExecution execution) throws Exception { String existingId = execution.getId(); // insert an execution referencing the current execution ExecutionEntity newExecution = new ExecutionEntity(); newExecution.setId("someId"); newExecution.setParentId(existingId); DbEntityOperation insertOperation = new DbEntityOperation(); insertOperation.setOperationType(DbOperationType.INSERT); insertOperation.setEntity(newExecution); Context.getCommandContext() .getDbSqlSession() .executeDbOperation(insertOperation); }