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