List of usage examples for org.apache.commons.lang.time DateUtils addMinutes
public static Date addMinutes(Date date, int amount)
From source file:org.camunda.bpm.engine.test.bpmn.parse.RetryIntervalsConfigurationTest.java
@Test public void testRetryGlobalConfigurationWithExecutionListener() throws ParseException { // given/* w ww .j a va 2s .com*/ engineRule.getProcessEngineConfiguration().setFailedJobRetryTimeCycle("PT5M"); BpmnModelInstance bpmnModelInstance = Bpmn.createExecutableProcess(PROCESS_ID).startEvent().serviceTask() .camundaClass(FAILING_CLASS).camundaAsyncBefore() .camundaExecutionListenerClass(RecorderExecutionListener.EVENTNAME_START, RecorderExecutionListener.class.getName()) .endEvent().done(); testRule.deploy(bpmnModelInstance); ClockUtil.setCurrentTime(SIMPLE_DATE_FORMAT.parse("2017-01-01T09:55:00")); ProcessInstance pi = runtimeService.startProcessInstanceByKey(PROCESS_ID); Date currentTime = SIMPLE_DATE_FORMAT.parse("2017-01-01T10:00:00"); ClockUtil.setCurrentTime(currentTime); String processInstanceId = pi.getProcessInstanceId(); int jobRetries = executeJob(processInstanceId); assertEquals(1, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 5); assertLockExpirationTime(currentTime); ClockUtil.setCurrentTime(currentTime); jobRetries = executeJob(processInstanceId); assertEquals(0, jobRetries); }
From source file:org.camunda.bpm.engine.test.bpmn.parse.RetryIntervalsConfigurationTest.java
@Test public void testRetryMixConfiguration() throws ParseException { // given/* ww w . j a v a2 s. c o m*/ BpmnModelInstance bpmnModelInstance = prepareProcessFailingServiceTaskWithRetryCycle("R3/PT1M"); testRule.deploy(bpmnModelInstance); ClockUtil.setCurrentTime(SIMPLE_DATE_FORMAT.parse("2017-01-01T09:55:00")); ProcessInstance pi = runtimeService.startProcessInstanceByKey(PROCESS_ID); assertNotNull(pi); Date currentTime = SIMPLE_DATE_FORMAT.parse("2017-01-01T10:00:00"); ClockUtil.setCurrentTime(currentTime); String processInstanceId = pi.getProcessInstanceId(); int jobRetries; for (int i = 0; i < 3; i++) { jobRetries = executeJob(processInstanceId); assertEquals(2 - i, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 1); assertLockExpirationTime(currentTime); ClockUtil.setCurrentTime(currentTime); } }
From source file:org.camunda.bpm.engine.test.bpmn.parse.RetryIntervalsConfigurationTest.java
@Test public void testRetryIntervals() throws ParseException { // given//from w w w .ja va 2 s .co m BpmnModelInstance bpmnModelInstance = prepareProcessFailingServiceTaskWithRetryCycle("PT3M, PT10M,PT8M"); testRule.deploy(bpmnModelInstance); ClockUtil.setCurrentTime(SIMPLE_DATE_FORMAT.parse("2017-01-01T09:55:00")); ProcessInstance pi = runtimeService.startProcessInstanceByKey(PROCESS_ID); assertNotNull(pi); Date currentTime = SIMPLE_DATE_FORMAT.parse("2017-01-01T10:00:00"); ClockUtil.setCurrentTime(currentTime); String processInstanceId = pi.getProcessInstanceId(); int jobRetries = executeJob(processInstanceId); assertEquals(3, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 3); assertLockExpirationTime(currentTime); ClockUtil.setCurrentTime(currentTime); jobRetries = executeJob(processInstanceId); assertEquals(2, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 10); assertLockExpirationTime(currentTime); ClockUtil.setCurrentTime(currentTime); jobRetries = executeJob(processInstanceId); assertEquals(1, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 8); assertLockExpirationTime(currentTime); ClockUtil.setCurrentTime(currentTime); jobRetries = executeJob(processInstanceId); assertEquals(0, jobRetries); }
From source file:org.camunda.bpm.engine.test.bpmn.parse.RetryIntervalsConfigurationTest.java
@Test public void testSingleRetryInterval() throws ParseException { // given/* w w w. j a v a2 s. co m*/ BpmnModelInstance bpmnModelInstance = prepareProcessFailingServiceTaskWithRetryCycle("PT8M "); testRule.deploy(bpmnModelInstance); ClockUtil.setCurrentTime(SIMPLE_DATE_FORMAT.parse("2017-01-01T09:55:00")); ProcessInstance pi = runtimeService.startProcessInstanceByKey(PROCESS_ID); assertNotNull(pi); Date currentTime = SIMPLE_DATE_FORMAT.parse("2017-01-01T10:00:00"); ClockUtil.setCurrentTime(currentTime); String processInstanceId = pi.getProcessInstanceId(); int jobRetries = executeJob(processInstanceId); assertEquals(1, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 8); assertLockExpirationTime(currentTime); ClockUtil.setCurrentTime(currentTime); jobRetries = executeJob(processInstanceId); assertEquals(0, jobRetries); }
From source file:org.camunda.bpm.engine.test.bpmn.parse.RetryIntervalsConfigurationTest.java
@Test public void testIntervalsAfterUpdateRetries() throws ParseException { // given//from ww w.j av a 2 s .com BpmnModelInstance bpmnModelInstance = prepareProcessFailingServiceTaskWithRetryCycle("PT3M, PT10M,PT8M"); testRule.deploy(bpmnModelInstance); ClockUtil.setCurrentTime(SIMPLE_DATE_FORMAT.parse("2017-01-01T09:55:00")); ProcessInstance pi = runtimeService.startProcessInstanceByKey(PROCESS_ID); assertNotNull(pi); Date currentTime = SIMPLE_DATE_FORMAT.parse("2017-01-01T10:00:00"); ClockUtil.setCurrentTime(currentTime); String processInstanceId = pi.getProcessInstanceId(); int jobRetries = executeJob(processInstanceId); assertEquals(3, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 3); assertLockExpirationTime(currentTime); ClockUtil.setCurrentTime(currentTime); Job job = managementService.createJobQuery().processInstanceId(processInstanceId).singleResult(); managementService.setJobRetries(Arrays.asList(job.getId()), 5); jobRetries = executeJob(processInstanceId); assertEquals(4, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 3); assertLockExpirationTime(currentTime); ClockUtil.setCurrentTime(currentTime); jobRetries = executeJob(processInstanceId); assertEquals(3, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 3); assertLockExpirationTime(currentTime); ClockUtil.setCurrentTime(currentTime); jobRetries = executeJob(processInstanceId); assertEquals(2, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 10); assertLockExpirationTime(currentTime); ClockUtil.setCurrentTime(currentTime); jobRetries = executeJob(processInstanceId); assertEquals(1, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 8); assertLockExpirationTime(currentTime); ClockUtil.setCurrentTime(currentTime); jobRetries = executeJob(processInstanceId); assertEquals(0, jobRetries); }
From source file:org.camunda.bpm.engine.test.bpmn.parse.RetryIntervalsConfigurationTest.java
@Test public void testMixConfigurationWithinOneProcess() throws ParseException { // given//from w w w. jav a 2s .co m BpmnModelInstance bpmnModelInstance = Bpmn.createExecutableProcess(PROCESS_ID).startEvent() .serviceTask("Task1").camundaClass(ServiceTaskDelegate.class.getName()).camundaAsyncBefore() .serviceTask("Task2").camundaClass(FAILING_CLASS).camundaAsyncBefore() .camundaFailedJobRetryTimeCycle("PT3M, PT10M,PT8M").endEvent().done(); testRule.deploy(bpmnModelInstance); ClockUtil.setCurrentTime(SIMPLE_DATE_FORMAT.parse("2017-01-01T09:55:00")); ProcessInstance pi = runtimeService.startProcessInstanceByKey(PROCESS_ID); assertNotNull(pi); Date currentTime = SIMPLE_DATE_FORMAT.parse("2017-01-01T10:00:00"); ClockUtil.setCurrentTime(currentTime); String processInstanceId = pi.getProcessInstanceId(); // try to execute the first service task without success int jobRetries = executeJob(processInstanceId); assertEquals(3, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 5); assertLockExpirationTime(currentTime); ClockUtil.setCurrentTime(currentTime); ServiceTaskDelegate.firstAttempt = false; // finish the first service task jobRetries = executeJob(processInstanceId); assertEquals(3, jobRetries); // try to execute the second service task without success jobRetries = executeJob(processInstanceId); assertEquals(3, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 3); assertLockExpirationTime(currentTime); ClockUtil.setCurrentTime(currentTime); }
From source file:org.camunda.bpm.engine.test.bpmn.parse.RetryIntervalsConfigurationTest.java
@Test public void testlocalConfigurationWithNestedChangingExpression() throws ParseException { BpmnModelInstance bpmnModelInstance = Bpmn.createExecutableProcess("process").startEvent().serviceTask() .camundaClass("foo").camundaAsyncBefore().camundaFailedJobRetryTimeCycle("${var}").endEvent() .done();//ww w .j av a 2s . c om SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); Date startDate = simpleDateFormat.parse("2017-01-01T09:55:00"); ClockUtil.setCurrentTime(startDate); testRule.deploy(bpmnModelInstance); VariableMap params = Variables.createVariables(); params.putValue("var", "${nestedVar1},PT15M,${nestedVar3}"); params.putValue("nestedVar", "PT13M"); params.putValue("nestedVar1", "PT5M"); params.putValue("nestedVar3", "PT25M"); ProcessInstance pi = runtimeService.startProcessInstanceByKey("process", params); ClockUtil.setCurrentTime(SIMPLE_DATE_FORMAT.parse("2017-01-01T09:55:00")); assertNotNull(pi); Date currentTime = SIMPLE_DATE_FORMAT.parse("2017-01-01T10:00:00"); ClockUtil.setCurrentTime(currentTime); String processInstanceId = pi.getProcessInstanceId(); int jobRetries = executeJob(processInstanceId); assertEquals(3, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 5); assertLockExpirationTime(currentTime); ClockUtil.setCurrentTime(currentTime); jobRetries = executeJob(processInstanceId); assertEquals(2, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 15); assertLockExpirationTime(currentTime); ClockUtil.setCurrentTime(currentTime); runtimeService.setVariable(pi.getProcessInstanceId(), "var", "${nestedVar}"); jobRetries = executeJob(processInstanceId); assertEquals(1, jobRetries); currentTime = DateUtils.addMinutes(currentTime, 13); assertLockExpirationTime(currentTime); ClockUtil.setCurrentTime(currentTime); jobRetries = executeJob(processInstanceId); assertEquals(0, jobRetries); }
From source file:org.camunda.bpm.example.test.FailedJobRetryProfileTest.java
private void assertLockExpirationTime(int minutesOffset) throws ParseException { currentTime = DateUtils.addMinutes(currentTime, minutesOffset); Date lockExpirationTime = ((JobEntity) managementService.createJobQuery().singleResult()) .getLockExpirationTime();//from w ww .ja va 2s . c om assertEquals(currentTime, lockExpirationTime); ClockUtil.setCurrentTime(currentTime); }
From source file:org.entando.entando.aps.system.services.cache.CacheInfoManager.java
public void setExpirationTime(String targhetCache, String key, int expiresInMinute) { Date expirationTime = DateUtils.addMinutes(new Date(), expiresInMinute); this.setExpirationTime(targhetCache, key, expirationTime); }
From source file:org.geoserver.taskmanager.schedule.BatchJobServiceTest.java
@Test public void testBatchJobService() throws SchedulerException { JobKey jobKey = new JobKey(batch.getFullName()); TriggerKey triggerKey = new TriggerKey(batch.getFullName()); //not scheduled yet assertTrue(scheduler.checkExists(jobKey)); assertFalse(scheduler.checkExists(triggerKey)); //give it a frequency batch.setFrequency("0 0 * * * ?"); batch.setEnabled(true);/*from w ww.j a va2s . co m*/ bjService.saveAndSchedule(batch); assertTrue(scheduler.checkExists(jobKey)); assertTrue(scheduler.checkExists(triggerKey)); Trigger trigger = scheduler.getTrigger(triggerKey); Date nextFireTime = DateUtils.ceiling(new Date(), Calendar.HOUR); assertEquals(nextFireTime, trigger.getNextFireTime()); //change the frequency batch.setFrequency("0 30 * * * ?"); bjService.saveAndSchedule(batch); assertTrue(scheduler.checkExists(jobKey)); assertTrue(scheduler.checkExists(triggerKey)); trigger = scheduler.getTrigger(triggerKey); nextFireTime = DateUtils.addMinutes(DateUtils.round(new Date(), Calendar.HOUR), 30); assertEquals(nextFireTime, trigger.getNextFireTime()); //de-activate it batch.setEnabled(false); bjService.saveAndSchedule(batch); assertTrue(scheduler.checkExists(jobKey)); assertFalse(scheduler.checkExists(triggerKey)); //delete it batch.setActive(false); bjService.saveAndSchedule(batch); assertFalse(scheduler.checkExists(jobKey)); assertFalse(scheduler.checkExists(triggerKey)); }