@Produces @Named @BusinessKey public String businessKey(ProcessInstance processInstance) { return processInstance.getBusinessKey(); }
@Override public String getProperty(ProcessInstance obj) { return obj.getBusinessKey(); } });
public static ProcessInstance createAnotherMockInstance() { ProcessInstance mock = mock(ProcessInstance.class); when(mock.getId()).thenReturn(ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID); when(mock.getBusinessKey()).thenReturn(EXAMPLE_PROCESS_INSTANCE_BUSINESS_KEY); when(mock.getProcessDefinitionId()).thenReturn(EXAMPLE_PROCESS_DEFINITION_ID); when(mock.getProcessInstanceId()).thenReturn(ANOTHER_EXAMPLE_PROCESS_INSTANCE_ID); when(mock.isSuspended()).thenReturn(EXAMPLE_PROCESS_INSTANCE_IS_SUSPENDED); when(mock.isEnded()).thenReturn(EXAMPLE_PROCESS_INSTANCE_IS_ENDED); return mock; }
public static ProcessInstance createMockInstance(String tenantId) { ProcessInstance mock = mock(ProcessInstance.class); when(mock.getId()).thenReturn(EXAMPLE_PROCESS_INSTANCE_ID); when(mock.getBusinessKey()).thenReturn(EXAMPLE_PROCESS_INSTANCE_BUSINESS_KEY); when(mock.getCaseInstanceId()).thenReturn(EXAMPLE_CASE_INSTANCE_ID); when(mock.getProcessDefinitionId()).thenReturn(EXAMPLE_PROCESS_DEFINITION_ID); when(mock.getProcessInstanceId()).thenReturn(EXAMPLE_PROCESS_INSTANCE_ID); when(mock.isSuspended()).thenReturn(EXAMPLE_PROCESS_INSTANCE_IS_SUSPENDED); when(mock.isEnded()).thenReturn(EXAMPLE_PROCESS_INSTANCE_IS_ENDED); when(mock.getTenantId()).thenReturn(tenantId); return mock; }
public ProcessInstanceDto(ProcessInstance instance) { this.id = instance.getId(); this.definitionId = instance.getProcessDefinitionId(); this.businessKey = instance.getBusinessKey(); this.caseInstanceId = instance.getCaseInstanceId(); this.ended = instance.isEnded(); this.suspended = instance.isSuspended(); this.tenantId = instance.getTenantId(); }
public ProcessInstanceDto(ProcessInstance instance) { this.id = instance.getId(); this.definitionId = instance.getProcessDefinitionId(); this.businessKey = instance.getBusinessKey(); this.caseInstanceId = instance.getCaseInstanceId(); this.ended = instance.isEnded(); this.suspended = instance.isSuspended(); this.tenantId = instance.getTenantId(); }
public void testStartProcessInstanceAndSetBusinessKey() { runtimeService.createProcessInstanceByKey(PROCESS_DEFINITION_KEY).businessKey("businessKey").execute(); ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult(); assertThat(processInstance, is(notNullValue())); assertThat(processInstance.getBusinessKey(), is("businessKey")); }
@Deployment @Test public void testSubmitStartFormDataWithBusinessKey() { Map<String, String> properties = new HashMap<String, String>(); properties.put("duration", "45"); properties.put("speaker", "Mike"); String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId(); ProcessInstance processInstance = formService.submitStartFormData(procDefId, "123", properties); assertEquals("123", processInstance.getBusinessKey()); assertEquals(processInstance.getId(), runtimeService.createProcessInstanceQuery().processInstanceBusinessKey("123").singleResult().getId()); }
@Deployment @Test public void testSubmitStartFormWithBusinessKey() { Map<String, Object> properties = new HashMap<String, Object>(); properties.put("duration", 45L); properties.put("speaker", "Mike"); String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId(); ProcessInstance processInstance = formService.submitStartForm(procDefId, "123", properties); assertEquals("123", processInstance.getBusinessKey()); assertEquals(processInstance.getId(), runtimeService.createProcessInstanceQuery().processInstanceBusinessKey("123").singleResult().getId()); Map<String, Object> variables = runtimeService.getVariables(processInstance.getId()); assertEquals("Mike", variables.get("SpeakerName")); assertEquals(45L, variables.get("duration")); }
@Deployment @Test public void testSubmitStartFormWithFormFieldMarkedAsBusinessKey() { String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId(); ProcessInstance pi = formService.submitStartForm(procDefId, "foo", Variables.createVariables().putValue("secondParam", "bar")); assertEquals("foo", pi.getBusinessKey()); List<VariableInstance> result = runtimeService.createVariableInstanceQuery().list(); assertEquals(1, result.size()); assertTrue(result.get(0).getName().equals("secondParam")); }
@Deployment @Test public void testSubmitStartFormWithoutProperties() { Map<String, Object> properties = new HashMap<String, Object>(); properties.put("duration", 45L); properties.put("speaker", "Mike"); String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId(); ProcessInstance processInstance = formService.submitStartForm(procDefId, "123", properties); assertEquals("123", processInstance.getBusinessKey()); assertEquals(processInstance.getId(), runtimeService.createProcessInstanceQuery().processInstanceBusinessKey("123").singleResult().getId()); Map<String, Object> variables = runtimeService.getVariables(processInstance.getId()); assertEquals("Mike", variables.get("speaker")); assertEquals(45L, variables.get("duration")); }
@Deployment(resources={"org/camunda/bpm/engine/test/api/runtime/MessageCorrelationTest.testMessageStartEventCorrelation.bpmn20.xml"}) @Test public void testMessageStartEventCorrelationWithBusinessKey() { final String businessKey = "aBusinessKey"; runtimeService.correlateMessage("newInvoiceMessage", businessKey); ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult(); assertNotNull(processInstance); assertEquals(businessKey, processInstance.getBusinessKey()); }
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS) public void testSingleActivityInstantiationSetBusinessKey() { // when ProcessInstance instance = runtimeService .createProcessInstanceByKey("exclusiveGateway") .businessKey("businessKey") .startBeforeActivity("task1") .execute(); // then assertNotNull(instance); assertEquals("businessKey", instance.getBusinessKey()); }
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" }) public void testQueryByProcessInstanceBusinessKey() { // given ProcessInstance piBusinessKey1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", "BUSINESS-KEY-1"); HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery(); // then assertEquals(1, query.processInstanceBusinessKey(piBusinessKey1.getBusinessKey()).count()); assertEquals(0, query.processInstanceBusinessKey("unexistingBusinessKey").count()); }
@Deployment(resources={"org/camunda/bpm/engine/test/api/runtime/MessageCorrelationTest.testMessageStartEventCorrelation.bpmn20.xml"}) @Test public void testMessageStartEventCorrelationWithBusinessKeyUsingFluentCorrelateAll() { final String businessKey = "aBusinessKey"; runtimeService.createMessageCorrelation("newInvoiceMessage") .processInstanceBusinessKey(businessKey) .correlateAll(); ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult(); assertNotNull(processInstance); assertEquals(businessKey, processInstance.getBusinessKey()); }
@Deployment(resources={"org/camunda/bpm/engine/test/api/runtime/MessageCorrelationTest.testMessageStartEventCorrelation.bpmn20.xml"}) @Test public void testMessageStartEventCorrelationWithBusinessKeyUsingFluentCorrelateSingle() { final String businessKey = "aBusinessKey"; runtimeService.createMessageCorrelation("newInvoiceMessage") .processInstanceBusinessKey(businessKey) .correlate(); ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult(); assertNotNull(processInstance); assertEquals(businessKey, processInstance.getBusinessKey()); }
@Deployment(resources={"org/camunda/bpm/engine/test/api/runtime/MessageCorrelationTest.testMessageStartEventCorrelation.bpmn20.xml"}) @Test public void testMessageStartEventCorrelationWithBusinessKeyUsingFluentCorrelateStartMessage() { final String businessKey = "aBusinessKey"; runtimeService.createMessageCorrelation("newInvoiceMessage") .processInstanceBusinessKey(businessKey) .correlateStartMessage(); ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult(); assertNotNull(processInstance); assertEquals(businessKey, processInstance.getBusinessKey()); }
protected void checkBusinessKeyChanged(String newBusinessKeyValue) { ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processDefinitionKey(PROCESS_KEY).singleResult(); assertNotNull(processInstance); assertEquals(newBusinessKeyValue, processInstance.getBusinessKey()); HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery().singleResult(); assertNotNull(historicInstance); assertEquals(newBusinessKeyValue, historicInstance.getBusinessKey()); }
@Test public void shouldRestartProcessInstanceWithBusinessKey() { // given ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process", "businessKey", (String) null); runtimeService.deleteProcessInstance(processInstance.getId(), "test"); // when runtimeService.restartProcessInstances(processDefinition.getId()) .startBeforeActivity("userTask1") .processInstanceIds(processInstance.getId()) .execute(); // then ProcessInstance restartedProcessInstance = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).active().singleResult(); assertNotNull(restartedProcessInstance.getBusinessKey()); assertEquals("businessKey", restartedProcessInstance.getBusinessKey()); }
@Test public void shouldRestartProcessInstanceWithoutBusinessKey() { // given ProcessDefinition processDefinition = testRule.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("Process", "businessKey", (String) null); runtimeService.deleteProcessInstance(processInstance.getId(), "test"); // when runtimeService.restartProcessInstances(processDefinition.getId()) .startBeforeActivity("userTask1") .processInstanceIds(processInstance.getId()) .withoutBusinessKey() .execute(); // then ProcessInstance restartedProcessInstance = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinition.getId()).active().singleResult(); assertNull(restartedProcessInstance.getBusinessKey()); }