org.camunda.bpm.engine.test.mock.Mocks Java Examples
The following examples show how to use
org.camunda.bpm.engine.test.mock.Mocks.
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: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testTaskQueryByBusinessKeyExpression() { // given String aBusinessKey = "business key"; Mocks.register("aBusinessKey", aBusinessKey); createDeploymentWithBusinessKey(aBusinessKey); // when TaskQueryImpl extendedQuery = (TaskQueryImpl)taskService.createTaskQuery() .processInstanceBusinessKeyExpression("${ " + Mocks.getMocks().keySet().toArray()[0] + " }"); Filter filter = filterService.newTaskFilter("aFilterName"); filter.setQuery(extendedQuery); filterService.saveFilter(filter); TaskQueryImpl filterQuery = filterService.getFilter(filter.getId()).getQuery(); // then assertEquals(extendedQuery.getExpressions().get("processInstanceBusinessKey"), filterQuery.getExpressions().get("processInstanceBusinessKey")); assertEquals(1, filterService.list(filter.getId()).size()); }
Example #5
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testTaskQueryByBusinessKeyExpressionInAdhocQuery() { // given processEngineConfiguration.setEnableExpressionsInAdhocQueries(true); String aBusinessKey = "business key"; Mocks.register("aBusinessKey", aBusinessKey); createDeploymentWithBusinessKey(aBusinessKey); // when Filter filter = filterService.newTaskFilter("aFilterName"); filter.setQuery(taskService.createTaskQuery()); filterService.saveFilter(filter); TaskQueryImpl extendingQuery = (TaskQueryImpl)taskService.createTaskQuery() .processInstanceBusinessKeyExpression("${ " + Mocks.getMocks().keySet().toArray()[0] + " }"); // then assertEquals(extendingQuery.getExpressions().get("processInstanceBusinessKey"), "${ " + Mocks.getMocks().keySet().toArray()[0] + " }"); assertEquals(1, filterService.list(filter.getId(), extendingQuery).size()); }
Example #6
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testTaskQueryByBusinessKeyLikeExpression() { // given String aBusinessKey = "business key"; Mocks.register("aBusinessKeyLike", "%" + aBusinessKey.substring(5)); createDeploymentWithBusinessKey(aBusinessKey); // when TaskQueryImpl extendedQuery = (TaskQueryImpl)taskService.createTaskQuery() .processInstanceBusinessKeyLikeExpression("${ " + Mocks.getMocks().keySet().toArray()[0] + " }"); Filter filter = filterService.newTaskFilter("aFilterName"); filter.setQuery(extendedQuery); filterService.saveFilter(filter); TaskQueryImpl filterQuery = filterService.getFilter(filter.getId()).getQuery(); // then assertEquals(extendedQuery.getExpressions().get("processInstanceBusinessKeyLike"), filterQuery.getExpressions().get("processInstanceBusinessKeyLike")); assertEquals(1, filterService.list(filter.getId()).size()); }
Example #7
Source File: FilterTaskQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testTaskQueryByBusinessKeyLikeExpressionInAdhocQuery() { // given processEngineConfiguration.setEnableExpressionsInAdhocQueries(true); String aBusinessKey = "business key"; Mocks.register("aBusinessKeyLike", "%" + aBusinessKey.substring(5)); createDeploymentWithBusinessKey(aBusinessKey); // when Filter filter = filterService.newTaskFilter("aFilterName"); filter.setQuery(taskService.createTaskQuery()); filterService.saveFilter(filter); TaskQueryImpl extendingQuery = (TaskQueryImpl)taskService.createTaskQuery() .processInstanceBusinessKeyLikeExpression("${ " + Mocks.getMocks().keySet().toArray()[0] + " }"); // then assertEquals(extendingQuery.getExpressions().get("processInstanceBusinessKeyLike"), "${ " + Mocks.getMocks().keySet().toArray()[0] + " }"); assertEquals(1, filterService.list(filter.getId(), extendingQuery).size()); }
Example #8
Source File: ProcessLocalTest.java From camunda-bpm-identity-keycloak with Apache License 2.0 | 5 votes |
/** * Setup the test case. */ @Before public void setup() { // Initialize and register mocks MockitoAnnotations.initMocks(this); Mocks.register("logger", loggerTask); // Initialize BPM Assert init(rule.getProcessEngine()); }
Example #9
Source File: TaskQueryExpressionTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testQueryByProcessInstanceBusinessKeyExpression() { // given String aBusinessKey = "business key"; Mocks.register("aBusinessKey", aBusinessKey); createBusinessKeyDeployment(aBusinessKey); // when TaskQuery taskQuery = taskQuery() .processInstanceBusinessKeyExpression("${ " + Mocks.getMocks().keySet().toArray()[0] + " }"); // then assertCount(taskQuery, 1); }
Example #10
Source File: TaskQueryExpressionTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void testQueryByProcessInstanceBusinessKeyLikeExpression() { // given String aBusinessKey = "business key"; Mocks.register("aBusinessKeyLike", "%" + aBusinessKey.substring(5)); createBusinessKeyDeployment(aBusinessKey); // when TaskQuery taskQuery = taskQuery() .processInstanceBusinessKeyLikeExpression("${ " + Mocks.getMocks().keySet().toArray()[0] + " }"); // then assertCount(taskQuery, 1); }
Example #11
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 #12
Source File: AbstractTest.java From camunda-bpm-assert-scenario with Apache License 2.0 | 4 votes |
@Before public void setup() { MockitoAnnotations.initMocks(this); Mocks.register("javaDelegate", mock(JavaDelegate.class)); }
Example #13
Source File: AutoMockProcessTest.java From camunda-bpm-mockito with Apache License 2.0 | 4 votes |
@Test @Deployment(resources = "MockProcess.bpmn") public void register_mocks_for_all_listeners_and_delegates() throws Exception { autoMock("MockProcess.bpmn"); assertThat(Mocks.get("loadData")).isNotNull(); assertThat(Mocks.get("saveData")).isNotNull(); final ProcessInstance processInstance = processEngineRule.getRuntimeService().startProcessInstanceByKey("process_mock_dummy"); assertThat(processEngineRule.getTaskService().createTaskQuery().processInstanceId(processInstance.getId()).singleResult()).isNotNull(); completeTask(); verifyMocks(); }
Example #14
Source File: AutoMockProcessTest.java From camunda-bpm-mockito with Apache License 2.0 | 4 votes |
@Test @Deployment(resources = "MockProcess_withoutNS.bpmn") public void register_mocks_for_all_listeners_and_delegates_noNS() throws Exception { autoMock("MockProcess_withoutNS.bpmn"); assertThat(Mocks.get("loadData")).isNotNull(); assertThat(Mocks.get("saveData")).isNotNull(); final ProcessInstance processInstance = processEngineRule.getRuntimeService().startProcessInstanceByKey("process_mock_dummy"); assertThat(processEngineRule.getTaskService().createTaskQuery().processInstanceId(processInstance.getId()).singleResult()).isNotNull(); completeTask(); verifyMocks(); }
Example #15
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 #16
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(); }