Search in sources :

Example 1 with ProcessDefinitionImpl

use of org.activiti.api.runtime.model.impl.ProcessDefinitionImpl in project Activiti by Activiti.

the class APIProcessDefinitionConverter method from.

public ProcessDefinition from(org.activiti.engine.repository.ProcessDefinition internalProcessDefinition) {
    ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();
    processDefinition.setId(internalProcessDefinition.getId());
    processDefinition.setName(internalProcessDefinition.getName());
    processDefinition.setDescription(internalProcessDefinition.getDescription());
    processDefinition.setVersion(internalProcessDefinition.getVersion());
    processDefinition.setKey(internalProcessDefinition.getKey());
    processDefinition.setAppVersion(Objects.toString(internalProcessDefinition.getAppVersion(), null));
    BpmnModel model = repositoryService.getBpmnModel(internalProcessDefinition.getId());
    processDefinition.setFormKey(model.getStartFormKey(internalProcessDefinition.getKey()));
    return processDefinition;
}
Also used : ProcessDefinitionImpl(org.activiti.api.runtime.model.impl.ProcessDefinitionImpl) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 2 with ProcessDefinitionImpl

use of org.activiti.api.runtime.model.impl.ProcessDefinitionImpl in project Activiti by Activiti.

the class ProcessRuntimeImplTest method should_createAProcessInstance_whenCreateIsCalled.

@Test
public void should_createAProcessInstance_whenCreateIsCalled() {
    // given
    String processDefinitionId = "processDefinitionId";
    ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();
    processDefinition.setId(processDefinitionId);
    processDefinition.setKey("key");
    CreateProcessInstancePayload createPayload = ProcessPayloadBuilder.create().withProcessDefinitionId(processDefinitionId).withProcessDefinitionKey("key").withName("test-create").build();
    doReturn(processDefinition).when(processRuntime).getProcessDefinitionAndCheckUserHasRights(createPayload.getProcessDefinitionId(), createPayload.getProcessDefinitionKey());
    ProcessInstanceBuilder processInstanceBuilder = mock(ProcessInstanceBuilder.class, Answers.RETURNS_SELF);
    given(runtimeService.createProcessInstanceBuilder()).willReturn(processInstanceBuilder);
    org.activiti.engine.runtime.ProcessInstance internalProcessInstance = mock(org.activiti.engine.runtime.ProcessInstance.class);
    given(processInstanceBuilder.create()).willReturn(internalProcessInstance);
    ProcessInstanceImpl apiProcessInstance = new ProcessInstanceImpl();
    given(processInstanceConverter.from(internalProcessInstance)).willReturn(apiProcessInstance);
    // when
    ProcessInstance createdProcessInstance = processRuntime.create(createPayload);
    // then
    assertThat(createdProcessInstance).isEqualTo(apiProcessInstance);
    verify(processInstanceBuilder).processDefinitionId(processDefinition.getId());
    verify(processInstanceBuilder).processDefinitionKey(processDefinition.getKey());
    verify(processInstanceBuilder).name(createPayload.getName());
}
Also used : ProcessInstanceBuilder(org.activiti.engine.runtime.ProcessInstanceBuilder) ProcessDefinitionImpl(org.activiti.api.runtime.model.impl.ProcessDefinitionImpl) ProcessInstanceImpl(org.activiti.api.runtime.model.impl.ProcessInstanceImpl) ProcessInstance(org.activiti.api.process.model.ProcessInstance) CreateProcessInstancePayload(org.activiti.api.process.model.payloads.CreateProcessInstancePayload) Test(org.junit.jupiter.api.Test)

Aggregations

ProcessDefinitionImpl (org.activiti.api.runtime.model.impl.ProcessDefinitionImpl)2 ProcessInstance (org.activiti.api.process.model.ProcessInstance)1 CreateProcessInstancePayload (org.activiti.api.process.model.payloads.CreateProcessInstancePayload)1 ProcessInstanceImpl (org.activiti.api.runtime.model.impl.ProcessInstanceImpl)1 BpmnModel (org.activiti.bpmn.model.BpmnModel)1 ProcessInstanceBuilder (org.activiti.engine.runtime.ProcessInstanceBuilder)1 Test (org.junit.jupiter.api.Test)1