@Test public void testQueryByUnknownActivityId() { ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery() .activityIdIn("unknown"); assertNoProcessInstancesReturned(query); }
@Test public void testActivityIdListPostParameter() { Map<String, Object> queryParameters = new HashMap<String, Object>(); queryParameters.put("activityIdIn", MockProvider.EXAMPLE_ACTIVITY_ID_LIST.split(",")); given() .contentType(POST_JSON_CONTENT_TYPE) .body(queryParameters) .then().expect() .statusCode(Status.OK.getStatusCode()) .when() .post(PROCESS_INSTANCE_QUERY_URL); verify(mockedQuery).activityIdIn(MockProvider.EXAMPLE_ACTIVITY_ID, MockProvider.ANOTHER_EXAMPLE_ACTIVITY_ID); verify(mockedQuery).list(); }
@Test public void testQueryByNullActivityIds() { try { runtimeService.createProcessInstanceQuery() .activityIdIn((String[]) null); fail("exception expected"); } catch (NullValueException e) { assertThat(e.getMessage(), containsString("activity ids is null")); } }
@Test public void testQueryByNullActivityId() { try { runtimeService.createProcessInstanceQuery() .activityIdIn((String) null); fail("exception expected"); } catch (NullValueException e) { assertThat(e.getMessage(), containsString("activity ids contains null value")); } }
@Test public void testActivityIdListParameter() { given() .queryParam("activityIdIn", MockProvider.EXAMPLE_ACTIVITY_ID_LIST) .then().expect() .statusCode(Status.OK.getStatusCode()) .when() .get(PROCESS_INSTANCE_QUERY_URL); verify(mockedQuery).activityIdIn(MockProvider.EXAMPLE_ACTIVITY_ID, MockProvider.ANOTHER_EXAMPLE_ACTIVITY_ID); verify(mockedQuery).list(); }
@Test public void testQueryByActivityIdDuringCompensation() { // given ProcessDefinition testProcess = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL); // when ProcessInstance processInstance = runtimeService.startProcessInstanceById(testProcess.getId()); testHelper.completeTask("userTask1"); testHelper.completeTask("userTask2"); // then ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().activityIdIn("subProcess"); assertReturnedProcessInstances(query, processInstance); query = runtimeService.createProcessInstanceQuery().activityIdIn("compensationEvent"); assertReturnedProcessInstances(query, processInstance); query = runtimeService.createProcessInstanceQuery().activityIdIn("compensationHandler"); assertReturnedProcessInstances(query, processInstance); }
@Test public void shouldResolveByteArray_CreateAttachmentByProcessInstance() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String calledProcessInstanceId = runtimeService.createProcessInstanceQuery() .activityIdIn("userTask") .singleResult() .getId(); // when AttachmentEntity attachment = (AttachmentEntity) taskService.createAttachment(null, null, calledProcessInstanceId, null, null, new ByteArrayInputStream("hello world".getBytes())); ByteArrayEntity byteArray = findByteArrayById(attachment.getContentId()); // assume assertThat(byteArray, notNullValue()); // then assertThat(byteArray.getRootProcessInstanceId(), is(processInstance.getProcessInstanceId())); }
@Test public void testQueryByNonLeafActivityId() { // given ProcessDefinition processDefinition = testHelper.deployAndGetDefinition(FORK_JOIN_SUB_PROCESS_MODEL); // when runtimeService.startProcessInstanceById(processDefinition.getId()); // then ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().activityIdIn("subProcess", "fork"); assertNoProcessInstancesReturned(query); }
@Test public void shouldResolveCommentByProcessInstanceId() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String processInstanceId = runtimeService.createProcessInstanceQuery() .activityIdIn("userTask") .singleResult() .getId(); // when taskService.createComment(null, processInstanceId, "aMessage"); Comment comment = taskService.getProcessInstanceComments(processInstanceId).get(0); // assume assertThat(comment, notNullValue()); // then assertThat(comment.getRootProcessInstanceId(), is(processInstance.getRootProcessInstanceId())); }
@Test public void shouldResolveByteArray_CreateAttachmentByProcessInstance() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String calledProcessInstanceId = runtimeService.createProcessInstanceQuery() .activityIdIn("userTask") .singleResult() .getId(); // when AttachmentEntity attachment = (AttachmentEntity) taskService.createAttachment(null, null, calledProcessInstanceId, null, null, new ByteArrayInputStream("hello world".getBytes())); ByteArrayEntity byteArray = findByteArrayById(attachment.getContentId()); // assume assertThat(byteArray, notNullValue()); Date removalTime = addDays(START_DATE, 5); // then assertThat(byteArray.getRemovalTime(), is(removalTime)); }
@Test public void shouldNotResolveCommentByWrongTaskIdAndProcessInstanceId() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String processInstanceId = runtimeService.createProcessInstanceQuery() .activityIdIn("userTask") .singleResult() .getId(); // when taskService.createComment("aNonExistentTaskId", processInstanceId, "aMessage"); Comment comment = taskService.getProcessInstanceComments(processInstanceId).get(0); // assume assertThat(comment, notNullValue()); // then assertThat(comment.getRootProcessInstanceId(), nullValue()); }
@Test public void testQueryByActivityIdBeforeCompensation() { // given ProcessDefinition testProcess = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL); // when runtimeService.startProcessInstanceById(testProcess.getId()); testHelper.completeTask("userTask1"); // then ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().activityIdIn("subProcess"); assertNoProcessInstancesReturned(query); }
@Test public void shouldResolveAttachmentByProcessInstanceId() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String processInstanceId = runtimeService.createProcessInstanceQuery() .activityIdIn("userTask") .singleResult() .getId(); // when String attachmentId = taskService.createAttachment(null, null, processInstanceId, null, null, "http://camunda.com").getId(); Attachment attachment = taskService.getAttachment(attachmentId); // assume assertThat(attachment, notNullValue()); // then assertThat(attachment.getRootProcessInstanceId(), is(processInstance.getRootProcessInstanceId())); }
@Test public void shouldNotResolveCommentByWrongTaskIdAndProcessInstanceId() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String processInstanceId = runtimeService.createProcessInstanceQuery() .activityIdIn("userTask") .singleResult() .getId(); // when taskService.createComment("aNonExistentTaskId", processInstanceId, "aMessage"); Comment comment = taskService.getProcessInstanceComments(processInstanceId).get(0); // assume assertThat(comment, notNullValue()); // then assertThat(comment.getRemovalTime(), nullValue()); }
public void testStartProcessInstanceWithVersionTagBinding() { // given BpmnModelInstance callingProcess = createCallingProcess("callingProcess", "ver_tag_1"); deploymentForTenant(TENANT_ONE, callingProcess); deploymentForTenant(TENANT_ONE, "org/camunda/bpm/engine/test/bpmn/callactivity/subProcessWithVersionTag.bpmn20.xml"); deploymentForTenant(TENANT_TWO, callingProcess); deploymentForTenant(TENANT_TWO, "org/camunda/bpm/engine/test/bpmn/callactivity/subProcessWithVersionTag2.bpmn20.xml"); // when runtimeService.createProcessInstanceByKey("callingProcess").processDefinitionTenantId(TENANT_ONE).execute(); runtimeService.createProcessInstanceByKey("callingProcess").processDefinitionTenantId(TENANT_TWO).execute(); // then ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().processDefinitionKey("subProcess"); assertThat(query.activityIdIn("Task_1").tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(query.activityIdIn("Task_2").tenantIdIn(TENANT_TWO).count(), is(1L)); }
@Test public void shouldResolveAttachmentByProcessInstanceId() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String processInstanceId = runtimeService.createProcessInstanceQuery() .activityIdIn("userTask") .singleResult() .getId(); // when String attachmentId = taskService.createAttachment(null, null, processInstanceId, null, null, "http://camunda.com").getId(); Attachment attachment = taskService.getAttachment(attachmentId); // assume assertThat(attachment, notNullValue()); Date removalTime = addDays(START_DATE, 5); // then assertThat(attachment.getRemovalTime(), is(removalTime)); }
@Test public void shouldResolveUserOperationLog_CreateAttachment() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); // when identityService.setAuthenticatedUserId("aUserId"); taskService.createAttachment(null, null, runtimeService.createProcessInstanceQuery().activityIdIn("userTask").singleResult().getId(), null, null, "http://camunda.com"); identityService.clearAuthentication(); UserOperationLogEntry userOperationLog = historyService.createUserOperationLogQuery().singleResult(); // assume assertThat(userOperationLog, notNullValue()); // then assertThat(userOperationLog.getRootProcessInstanceId(), is(processInstance.getProcessInstanceId())); }
@Test public void shouldResolveUserOperationLog_CreateAttachment() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); // when identityService.setAuthenticatedUserId("aUserId"); taskService.createAttachment(null, null, runtimeService.createProcessInstanceQuery().activityIdIn("userTask").singleResult().getId(), null, null, "http://camunda.com"); identityService.clearAuthentication(); UserOperationLogEntry userOperationLog = historyService.createUserOperationLogQuery().singleResult(); // assume assertThat(userOperationLog, notNullValue()); Date removalTime = addDays(START_DATE, 5); // then assertThat(userOperationLog.getRemovalTime(), is(removalTime)); }
@Test public void shouldNotResolveAttachmentByWrongTaskIdAndProcessInstanceId() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String processInstanceId = runtimeService.createProcessInstanceQuery() .activityIdIn("userTask") .singleResult() .getId(); // when String attachmentId = taskService.createAttachment(null, "aWrongTaskId", processInstanceId, null, null, "http://camunda.com").getId(); Attachment attachment = taskService.getAttachment(attachmentId); // assume assertThat(attachment, notNullValue()); // then assertThat(attachment.getRemovalTime(), nullValue()); }
@Test public void shouldNotResolveAttachmentByWrongTaskIdAndProcessInstanceId() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String processInstanceId = runtimeService.createProcessInstanceQuery() .activityIdIn("userTask") .singleResult() .getId(); // when String attachmentId = taskService.createAttachment(null, "aWrongTaskId", processInstanceId, null, null, "http://camunda.com").getId(); Attachment attachment = taskService.getAttachment(attachmentId); // assume assertThat(attachment, notNullValue()); // then assertThat(attachment.getRootProcessInstanceId(), nullValue()); }