APIProcessDefinitionConverter extends ListConverter<org.activiti.engine.repository.ProcessDefinition, ProcessDefinition> implements ModelConverter<org.activiti.engine.repository.ProcessDefinition, ProcessDefinition> { 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; } APIProcessDefinitionConverter(RepositoryService repositoryService); ProcessDefinition from(org.activiti.engine.repository.ProcessDefinition internalProcessDefinition);  }
@Test public void should_convertFromProcessDefinition_when_allFieldsAreSet() { ProcessDefinition convertedProcessDefinition = processDefinitionConverter.from( processDefinitionBuilderBuilder() .withId("anId") .withKey("processKey") .withName("Process Name") .withDescription("process description") .withVersion(3) .withAppVersion(1) .build() ); assertThat(convertedProcessDefinition) .isNotNull() .extracting(ProcessDefinition::getId, ProcessDefinition::getKey, ProcessDefinition::getName, ProcessDefinition::getDescription, ProcessDefinition::getVersion, ProcessDefinition::getAppVersion, ProcessDefinition::getFormKey) .containsExactly( "anId", "processKey", "Process Name", "process description", 3, "1", "AFormKey"); }
@Test public void should_convertProcessDefinition_when_appVersionNull() { ProcessDefinition convertedProcessDefinition = processDefinitionConverter.from( processDefinitionBuilderBuilder() .withKey("processKey") .withAppVersion(null) .build()); assertThat(convertedProcessDefinition) .isNotNull() .extracting(ProcessDefinition::getAppVersion) .isNull(); }