Java Code Examples for org.camunda.bpm.engine.test.mock.Mocks#reset()
The following examples show how to use
org.camunda.bpm.engine.test.mock.Mocks#reset() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MocksTest.java From camunda-bpm-platform with Apache License 2.0 | 7 votes |
private void testMockAvailability() { //given final String testStr = "testValue"; Mocks.register("myMock", new Object() { public String getTest() { return testStr; } public void testMethod(DelegateExecution execution, String str) { execution.setVariable("testVar", str); } }); //when ProcessInstance pi = runtimeService.startProcessInstanceByKey("mocksTest"); Mocks.reset(); //then assertEquals(testStr, runtimeService.getVariable(pi.getId(), "testVar")); }
Example 2
Source File: TaskQueryExpressionTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@After public void tearDown() { Mocks.reset(); for (Group group : identityService.createGroupQuery().list()) { identityService.deleteGroup(group.getId()); } for (User user : identityService.createUserQuery().list()) { identityService.deleteUser(user.getId()); } for (Task task : taskService.createTaskQuery().list()) { if (task.getProcessInstanceId() == null) { taskService.deleteTask(task.getId(), true); } } identityService.clearAuthentication(); }
Example 3
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public void tearDown() { processEngineConfiguration.setEnableExpressionsInAdhocQueries(false); Mocks.reset(); for (Filter filter : filterService.createTaskFilterQuery().list()) { filterService.deleteFilter(filter.getId()); } for (Group group : identityService.createGroupQuery().list()) { identityService.deleteGroup(group.getId()); } for (User user : identityService.createUserQuery().list()) { identityService.deleteUser(user.getId()); } for (Task task : taskService.createTaskQuery().list()) { if (task.getProcessInstanceId() == null) { taskService.deleteTask(task.getId(), true); } } }
Example 4
Source File: StartTimerEventTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testInterruptingWithDurationExpression() { // given Mocks.register("duration", "PT60S"); ProcessBuilder processBuilder = Bpmn.createExecutableProcess("process"); BpmnModelInstance modelInstance = processBuilder .startEvent().timerWithDuration("${duration}") .userTask("aTaskName") .endEvent() .done(); deploymentId = repositoryService.createDeployment() .addModelInstance("process.bpmn", modelInstance).deploy() .getId(); // when String jobId = managementService.createJobQuery() .singleResult() .getId(); managementService.executeJob(jobId); // then assertEquals(1, taskService.createTaskQuery().taskName("aTaskName").list().size()); // cleanup Mocks.reset(); }
Example 5
Source File: StartTimerEventTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void testRecalculateTimeCycleExpressionCurrentDateBased() throws Exception { // given Mocks.register("cycle", "R/PT15M"); ProcessBuilder processBuilder = Bpmn.createExecutableProcess("process"); BpmnModelInstance modelInstance = processBuilder .startEvent().timerWithCycle("${cycle}") .userTask("aTaskName") .endEvent() .done(); deploymentId = repositoryService.createDeployment() .addModelInstance("process.bpmn", modelInstance).deploy() .getId(); JobQuery jobQuery = managementService.createJobQuery(); assertEquals(1, jobQuery.count()); Job job = jobQuery.singleResult(); String jobId = job.getId(); Date oldDuedate = job.getDuedate(); // when moveByMinutes(1); managementService.recalculateJobDuedate(jobId, false); // then Job jobUpdated = jobQuery.singleResult(); assertEquals(jobId, jobUpdated.getId()); assertNotEquals(oldDuedate, jobUpdated.getDuedate()); assertTrue(oldDuedate.before(jobUpdated.getDuedate())); // when Mocks.register("cycle", "R/PT10M"); managementService.recalculateJobDuedate(jobId, false); // then jobUpdated = jobQuery.singleResult(); assertEquals(jobId, jobUpdated.getId()); assertNotEquals(oldDuedate, jobUpdated.getDuedate()); assertTrue(oldDuedate.after(jobUpdated.getDuedate())); Mocks.reset(); }
Example 6
Source File: StartTimerEventTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void testRecalculateTimeCycleExpressionCreationDateBased() throws Exception { // given Mocks.register("cycle", "R/PT15M"); ProcessBuilder processBuilder = Bpmn.createExecutableProcess("process"); BpmnModelInstance modelInstance = processBuilder .startEvent().timerWithCycle("${cycle}") .userTask("aTaskName") .endEvent() .done(); deploymentId = repositoryService.createDeployment() .addModelInstance("process.bpmn", modelInstance).deploy() .getId(); JobQuery jobQuery = managementService.createJobQuery(); assertEquals(1, jobQuery.count()); Job job = jobQuery.singleResult(); String jobId = job.getId(); Date oldDuedate = job.getDuedate(); // when moveByMinutes(1); managementService.recalculateJobDuedate(jobId, true); // then Job jobUpdated = jobQuery.singleResult(); assertEquals(jobId, jobUpdated.getId()); Date expectedDate = LocalDateTime.fromDateFields(jobUpdated.getCreateTime()).plusMinutes(15).toDate(); assertEquals(expectedDate, jobUpdated.getDuedate()); // when Mocks.register("cycle", "R/PT10M"); managementService.recalculateJobDuedate(jobId, true); // then jobUpdated = jobQuery.singleResult(); assertEquals(jobId, jobUpdated.getId()); assertNotEquals(oldDuedate, jobUpdated.getDuedate()); assertTrue(oldDuedate.after(jobUpdated.getDuedate())); expectedDate = LocalDateTime.fromDateFields(jobUpdated.getCreateTime()).plusMinutes(10).toDate(); assertEquals(expectedDate, jobUpdated.getDuedate()); Mocks.reset(); }