protected boolean isRootProcessInstance(Object entity) { if (entity instanceof ProcessInstance) { ProcessInstance processInstance = (ProcessInstance) entity; return processInstance.getId().equals(processInstance.getRootProcessInstanceId()); } return false; } }
@Test public void shouldPointToItself() { // given testRule.deploy(CALLED_PROCESS); // when ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLED_PROCESS_KEY); // assume assertThat(processInstance.getRootProcessInstanceId(), notNullValue()); // then assertThat(processInstance.getRootProcessInstanceId(), is(processInstance.getProcessInstanceId())); }
@Test public void shouldPointToItselfBySubmittingStartForm() { // given DeploymentWithDefinitions deployment = testRule.deploy(CALLED_PROCESS); String processDefinitionId = deployment.getDeployedProcessDefinitions().get(0).getId(); Map<String, Object> properties = new HashMap<>(); // when ProcessInstance processInstance = formService.submitStartForm(processDefinitionId, properties); // assume assertThat(processInstance.getRootProcessInstanceId(), notNullValue()); // then assertThat(processInstance.getRootProcessInstanceId(), is(processInstance.getProcessInstanceId())); }
@Test public void shouldPointToItselfByStartingAtActivity() { // given testRule.deploy(CALLED_PROCESS); // when ProcessInstance processInstance = runtimeService.createProcessInstanceByKey(CALLED_PROCESS_KEY) .startAfterActivity("userTask") .execute(); // assume assertThat(processInstance.getRootProcessInstanceId(), notNullValue()); // then assertThat(processInstance.getRootProcessInstanceId(), is(processInstance.getProcessInstanceId())); }
@Test public void shouldPointToRoot() { // given testRule.deploy(CALLED_PROCESS); testRule.deploy(CALLED_AND_CALLING_PROCESS); testRule.deploy(CALLING_PROCESS); // when runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); ProcessInstance calledProcessInstance = runtimeService.createProcessInstanceQuery() .processDefinitionKey(CALLED_PROCESS_KEY) .singleResult(); ProcessInstance calledAndCallingProcessInstance = runtimeService.createProcessInstanceQuery() .processDefinitionKey(CALLED_AND_CALLING_PROCESS_KEY) .singleResult(); ProcessInstance callingProcessInstance = runtimeService.createProcessInstanceQuery() .processDefinitionKey(CALLING_PROCESS_KEY) .singleResult(); // assume assertThat(runtimeService.createProcessInstanceQuery().count(), is(3L)); assertThat(callingProcessInstance.getRootProcessInstanceId(), notNullValue()); // then assertThat(callingProcessInstance.getRootProcessInstanceId(), is(callingProcessInstance.getProcessInstanceId())); assertThat(calledProcessInstance.getRootProcessInstanceId(), is(callingProcessInstance.getProcessInstanceId())); assertThat(calledAndCallingProcessInstance.getRootProcessInstanceId(), is(callingProcessInstance.getProcessInstanceId())); }
@Test public void shouldResolveCommentByTaskId() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String taskId = taskService.createTaskQuery().singleResult().getId(); // when taskService.createComment(taskId, null, "aMessage"); Comment comment = taskService.getTaskComments(taskId).get(0); // assume assertThat(comment, notNullValue()); // then assertThat(comment.getRootProcessInstanceId(), is(processInstance.getRootProcessInstanceId())); }
assertThat(callingProcessInstance.getRootProcessInstanceId(), is(callingProcessInstance.getProcessInstanceId())); assertThat(calledProcessInstances.get(0).getRootProcessInstanceId(), is(callingProcessInstance.getProcessInstanceId())); assertThat(calledProcessInstances.get(1).getRootProcessInstanceId(), is(callingProcessInstance.getProcessInstanceId())); assertThat(calledAndCallingProcessInstances.get(0).getRootProcessInstanceId(), is(callingProcessInstance.getProcessInstanceId())); assertThat(calledAndCallingProcessInstances.get(1).getRootProcessInstanceId(), is(callingProcessInstance.getProcessInstanceId()));
@Test public void shouldResolveCommentByTaskIdAndWrongProcessInstanceId() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String taskId = taskService.createTaskQuery().singleResult().getId(); // when taskService.createComment(taskId, "aNonExistentProcessInstanceId", "aMessage"); Comment comment = taskService.getTaskComments(taskId).get(0); // assume assertThat(comment, notNullValue()); // then assertThat(comment.getRootProcessInstanceId(), is(processInstance.getRootProcessInstanceId())); }
@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 shouldResolveAttachmentByTaskId() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String taskId = taskService.createTaskQuery().singleResult().getId(); // when String attachmentId = taskService.createAttachment(null, taskId, null, 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 shouldResolveAttachmentByTaskIdAndWrongProcessInstanceId() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String taskId = taskService.createTaskQuery() .singleResult() .getId(); // when String attachmentId = taskService.createAttachment(null, taskId, "aWrongProcessInstanceId", 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 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 shouldResolveExternalTaskLog() { // given testRule.deploy(Bpmn.createExecutableProcess("calledProcess") .startEvent() .serviceTask().camundaExternalTask("anExternalTaskTopic") .endEvent().done()); testRule.deploy(Bpmn.createExecutableProcess("callingProcess") .startEvent() .callActivity() .calledElement("calledProcess") .endEvent().done()); // when ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callingProcess"); HistoricExternalTaskLog ExternalTaskLog = historyService.createHistoricExternalTaskLogQuery().singleResult(); // assume assertThat(ExternalTaskLog, notNullValue()); // then assertThat(ExternalTaskLog.getRootProcessInstanceId(), is(processInstance.getRootProcessInstanceId())); }
protected boolean isRootProcessInstance(Object entity) { if (entity instanceof ProcessInstance) { ProcessInstance processInstance = (ProcessInstance) entity; return processInstance.getId().equals(processInstance.getRootProcessInstanceId()); } return false; } }
@Test public void shouldPointToItself() { // given testRule.deploy(CALLED_PROCESS); // when ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLED_PROCESS_KEY); // assume assertThat(processInstance.getRootProcessInstanceId(), notNullValue()); // then assertThat(processInstance.getRootProcessInstanceId(), is(processInstance.getProcessInstanceId())); }
@Test public void shouldPointToItselfBySubmittingStartForm() { // given DeploymentWithDefinitions deployment = testRule.deploy(CALLED_PROCESS); String processDefinitionId = deployment.getDeployedProcessDefinitions().get(0).getId(); Map<String, Object> properties = new HashMap<>(); // when ProcessInstance processInstance = formService.submitStartForm(processDefinitionId, properties); // assume assertThat(processInstance.getRootProcessInstanceId(), notNullValue()); // then assertThat(processInstance.getRootProcessInstanceId(), is(processInstance.getProcessInstanceId())); }
@Test public void shouldPointToItselfByStartingAtActivity() { // given testRule.deploy(CALLED_PROCESS); // when ProcessInstance processInstance = runtimeService.createProcessInstanceByKey(CALLED_PROCESS_KEY) .startAfterActivity("userTask") .execute(); // assume assertThat(processInstance.getRootProcessInstanceId(), notNullValue()); // then assertThat(processInstance.getRootProcessInstanceId(), is(processInstance.getProcessInstanceId())); }
@Test public void shouldResolveCommentByTaskId() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String taskId = taskService.createTaskQuery().singleResult().getId(); // when taskService.createComment(taskId, null, "aMessage"); Comment comment = taskService.getTaskComments(taskId).get(0); // assume assertThat(comment, notNullValue()); // then assertThat(comment.getRootProcessInstanceId(), is(processInstance.getRootProcessInstanceId())); }
@Test public void shouldResolveCommentByTaskIdAndWrongProcessInstanceId() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String taskId = taskService.createTaskQuery().singleResult().getId(); // when taskService.createComment(taskId, "aNonExistentProcessInstanceId", "aMessage"); Comment comment = taskService.getTaskComments(taskId).get(0); // assume assertThat(comment, notNullValue()); // then assertThat(comment.getRootProcessInstanceId(), is(processInstance.getRootProcessInstanceId())); }
@Test public void shouldResolveAttachmentByTaskId() { // given testRule.deploy(CALLING_PROCESS); testRule.deploy(CALLED_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY); String taskId = taskService.createTaskQuery().singleResult().getId(); // when String attachmentId = taskService.createAttachment(null, taskId, null, null, null, "http://camunda.com").getId(); Attachment attachment = taskService.getAttachment(attachmentId); // assume assertThat(attachment, notNullValue()); // then assertThat(attachment.getRootProcessInstanceId(), is(processInstance.getRootProcessInstanceId())); }