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;
}
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());
}
Aggregations