ProcessInstanceAdminServiceImpl implements ProcessInstanceAdminService { @Override public void updateTimer(long processInstanceId, long timerId, long delay, long period, int repeatLimit) throws NodeInstanceNotFoundException, ProcessInstanceNotFoundException { ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId); if (pi == null) { throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " not found"); } processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(processInstanceId), new UpdateTimerCommand(processInstanceId, timerId, delay, period, repeatLimit)); } ProcessInstanceAdminServiceImpl(); void setProcessService(ProcessService processService); void setRuntimeDataService(RuntimeDataService runtimeDataService); void setIdentityProvider(IdentityProvider identityProvider); void setCommandService(TransactionalCommandService commandService); @Override Collection<ProcessNode> getProcessNodes(long processInstanceId); @Override void cancelNodeInstance(long processInstanceId, long nodeInstanceId); @Override void retriggerNodeInstance(long processInstanceId, long nodeInstanceId); @Override void updateTimer(long processInstanceId, long timerId, long delay, long period, int repeatLimit); @Override void updateTimerRelative(long processInstanceId, long timerId, long delay, long period, int repeatLimit); @Override Collection<TimerInstance> getTimerInstances(long processInstanceId); @Override void triggerNode(long processInstanceId, long nodeId); @Override Collection<NodeInstanceDesc> getActiveNodeInstances(long processInstanceId); @Override void acknowledgeError(String... errorId); @Override ExecutionError getError(String errorId); @Override List<ExecutionError> getErrors(boolean includeAcknowledged, QueryContext queryContext); @Override List<ExecutionError> getErrorsByProcessId(String deploymentId, String processId, boolean includeAcknowledged, QueryContext queryContext); @Override List<ExecutionError> getErrorsByProcessInstanceId(long processInstanceId, boolean includeAcknowledged, QueryContext queryContext); @Override List<ExecutionError> getErrorsByProcessInstanceId(long processInstanceId, String nodeName, boolean includeAcknowledged, QueryContext queryContext); @Override List<ExecutionError> getErrorsByDeploymentId(String containerId, boolean includeAcknowledged, QueryContext queryContext);  }
@Test(timeout=10000) public void testUpdateTimer() throws Exception { processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "IntermediateCatchEvent"); assertNotNull(processInstanceId); long scheduleTime = System.currentTimeMillis(); Collection<NodeInstanceDesc> activeNodes = processAdminService.getActiveNodeInstances(processInstanceId); assertNotNull(activeNodes); assertEquals(1, activeNodes.size()); NodeInstanceDesc active = activeNodes.iterator().next(); assertEquals("timer", active.getName()); Collection<TimerInstance> timers = processAdminService.getTimerInstances(processInstanceId); assertNotNull(timers); assertEquals(1, timers.size()); TimerInstance timer = timers.iterator().next(); assertNotNull(timer.getActivationTime()); assertNotNull(timer.getDelay()); assertNotNull(timer.getNextFireTime()); assertNotNull(timer.getProcessInstanceId()); assertNotNull(timer.getSessionId()); assertNotNull(timer.getTimerId()); assertNotNull(timer.getId()); assertNotNull(timer.getTimerName()); Thread.sleep(1000); processAdminService.updateTimer(processInstanceId, timer.getId(), 3, 0, 0); CountDownListenerFactory.getExisting("processAdminService").waitTillCompleted(); long fireTime = System.currentTimeMillis(); long expirationTime = fireTime - scheduleTime; assertTrue(expirationTime < 4000); ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId); assertEquals(ProcessInstance.STATE_COMPLETED, pi.getState().intValue()); processInstanceId = null; }