Search in sources :

Example 11 with ProcessDefinition

use of org.activiti.api.process.model.ProcessDefinition in project activiti-cloud by Activiti.

the class ProcessDefinitionIT method shouldRetrieveDiagram.

@Test
public void shouldRetrieveDiagram() throws Exception {
    ProcessDefinition aProcessDefinition = getProcessDefinition(PROCESS_POOL_LANE);
    // when
    String responseData = executeRequest(PROCESS_DEFINITIONS_URL + aProcessDefinition.getId() + "/model", HttpMethod.GET, "image/svg+xml");
    // then
    assertThat(responseData).isNotNull();
    final InputStream byteArrayInputStream = new ByteArrayInputStream(TestResourceUtil.getProcessXml(aProcessDefinition.getId().split(":")[0]).getBytes());
    BpmnModel sourceModel = new BpmnXMLConverter().convertToBpmnModel(() -> byteArrayInputStream, false, false);
    String activityFontName = processDiagramGenerator.getDefaultActivityFontName();
    String labelFontName = processDiagramGenerator.getDefaultLabelFontName();
    String annotationFontName = processDiagramGenerator.getDefaultAnnotationFontName();
    try (InputStream is = processDiagramGenerator.generateDiagram(sourceModel, activityFontName, labelFontName, annotationFontName)) {
        String sourceSvg = new String(IoUtil.readInputStream(is, null), "UTF-8");
        assertThat(responseData).isEqualTo(sourceSvg);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) CloudProcessDefinition(org.activiti.cloud.api.process.model.CloudProcessDefinition) BpmnModel(org.activiti.bpmn.model.BpmnModel) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with ProcessDefinition

use of org.activiti.api.process.model.ProcessDefinition in project activiti-cloud by Activiti.

the class ProcessDefinitionIT method getProcessDefinition.

private ProcessDefinition getProcessDefinition(String name) {
    ResponseEntity<PagedResources<CloudProcessDefinition>> processDefinitionsEntity = getProcessDefinitions(PROCESS_DEFINITIONS_URL);
    Iterator<CloudProcessDefinition> it = processDefinitionsEntity.getBody().getContent().iterator();
    ProcessDefinition aProcessDefinition;
    do {
        aProcessDefinition = it.next();
    } while (!aProcessDefinition.getName().equals(name));
    return aProcessDefinition;
}
Also used : PagedResources(org.springframework.hateoas.PagedResources) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) CloudProcessDefinition(org.activiti.cloud.api.process.model.CloudProcessDefinition) CloudProcessDefinition(org.activiti.cloud.api.process.model.CloudProcessDefinition)

Example 13 with ProcessDefinition

use of org.activiti.api.process.model.ProcessDefinition in project activiti-cloud by Activiti.

the class ProcessDefinitionIT method shouldReturnProcessDefinitionById.

@Test
public void shouldReturnProcessDefinitionById() {
    // given
    ParameterizedTypeReference<CloudProcessDefinition> responseType = new ParameterizedTypeReference<CloudProcessDefinition>() {
    };
    ResponseEntity<PagedResources<CloudProcessDefinition>> processDefinitionsEntity = getProcessDefinitions(PROCESS_DEFINITIONS_URL);
    assertThat(processDefinitionsEntity).isNotNull();
    assertThat(processDefinitionsEntity.getBody()).isNotNull();
    assertThat(processDefinitionsEntity.getBody().getContent()).isNotEmpty();
    ProcessDefinition aProcessDefinition = processDefinitionsEntity.getBody().getContent().iterator().next();
    // when
    ResponseEntity<CloudProcessDefinition> entity = restTemplate.exchange(PROCESS_DEFINITIONS_URL + aProcessDefinition.getId(), HttpMethod.GET, null, responseType);
    // then
    assertThat(entity).isNotNull();
    assertThat(entity.getBody()).isNotNull();
    assertThat(entity.getBody().getId()).isEqualTo(aProcessDefinition.getId());
}
Also used : ParameterizedTypeReference(org.springframework.core.ParameterizedTypeReference) PagedResources(org.springframework.hateoas.PagedResources) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) CloudProcessDefinition(org.activiti.cloud.api.process.model.CloudProcessDefinition) CloudProcessDefinition(org.activiti.cloud.api.process.model.CloudProcessDefinition) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 14 with ProcessDefinition

use of org.activiti.api.process.model.ProcessDefinition in project activiti-cloud by Activiti.

the class ProcessDefinitionIT method shouldReturnProcessDefinitionMetadata.

@Test
public void shouldReturnProcessDefinitionMetadata() {
    // given
    ParameterizedTypeReference<ProcessDefinitionMeta> responseType = new ParameterizedTypeReference<ProcessDefinitionMeta>() {
    };
    ProcessDefinition aProcessDefinition = getProcessDefinition(PROCESS_WITH_VARIABLES_2);
    // when
    ResponseEntity<ProcessDefinitionMeta> entity = restTemplate.exchange(PROCESS_DEFINITIONS_URL + aProcessDefinition.getId() + "/meta", HttpMethod.GET, null, responseType);
    // then
    assertThat(entity).isNotNull();
    assertThat(entity.getBody()).isNotNull();
    assertThat(entity.getBody().getVariables()).hasSize(3);
    assertThat(entity.getBody().getUsers()).hasSize(4);
    assertThat(entity.getBody().getGroups()).hasSize(4);
    assertThat(entity.getBody().getUserTasks()).hasSize(2);
    assertThat(entity.getBody().getServiceTasks()).hasSize(2);
}
Also used : ParameterizedTypeReference(org.springframework.core.ParameterizedTypeReference) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) CloudProcessDefinition(org.activiti.cloud.api.process.model.CloudProcessDefinition) ProcessDefinitionMeta(org.activiti.cloud.services.api.model.ProcessDefinitionMeta) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 15 with ProcessDefinition

use of org.activiti.api.process.model.ProcessDefinition in project Activiti by Activiti.

the class APIProcessDefinitionConverterTest method should_convertFromProcessDefinition_when_allFieldsAreSet.

@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");
}
Also used : ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) Test(org.junit.jupiter.api.Test)

Aggregations

ProcessDefinition (org.activiti.api.process.model.ProcessDefinition)46 Test (org.junit.jupiter.api.Test)25 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)19 CloudProcessDefinition (org.activiti.cloud.api.process.model.CloudProcessDefinition)15 BeforeEach (org.junit.jupiter.api.BeforeEach)9 PagedResources (org.springframework.hateoas.PagedResources)8 ProcessInstance (org.activiti.api.process.model.ProcessInstance)5 UpdateProcessPayload (org.activiti.api.process.model.payloads.UpdateProcessPayload)4 ProcessRuntimeConfiguration (org.activiti.api.process.runtime.conf.ProcessRuntimeConfiguration)4 PageImpl (org.activiti.runtime.api.query.impl.PageImpl)4 InputStream (java.io.InputStream)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 ProcessPayloadBuilder (org.activiti.api.process.model.builders.ProcessPayloadBuilder)3 SignalPayload (org.activiti.api.process.model.payloads.SignalPayload)3 ProcessRuntime (org.activiti.api.process.runtime.ProcessRuntime)3 Page (org.activiti.api.runtime.shared.query.Page)3 Pageable (org.activiti.api.runtime.shared.query.Pageable)3 RepositoryService (org.activiti.engine.RepositoryService)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2