use of org.activiti.cloud.services.api.model.ProcessDefinitionMeta in project activiti-cloud by Activiti.
the class ProcessDefinitionMetaResourceAssemblerTest method toResourceShouldReturnResourceWithSelfLinkContainingResourceId.
@Test
public void toResourceShouldReturnResourceWithSelfLinkContainingResourceId() {
ProcessDefinitionMeta model = mock(ProcessDefinitionMeta.class);
when(model.getId()).thenReturn("my-identifier");
Resource<ProcessDefinitionMeta> resource = resourceAssembler.toResource(model);
Link selfResourceLink = resource.getLink("self");
assertThat(selfResourceLink).isNotNull();
assertThat(selfResourceLink.getHref()).contains("my-identifier");
Link metaResourceLink = resource.getLink("meta");
assertThat(metaResourceLink).isNotNull();
assertThat(metaResourceLink.getHref()).contains("my-identifier");
}
use of org.activiti.cloud.services.api.model.ProcessDefinitionMeta 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.cloud.services.api.model.ProcessDefinitionMeta in project activiti-cloud by Activiti.
the class ProcessDefinitionIT method shouldReturnProcessDefinitionMetadataForPoolLane.
@Test
public void shouldReturnProcessDefinitionMetadataForPoolLane() {
// given
ParameterizedTypeReference<ProcessDefinitionMeta> responseType = new ParameterizedTypeReference<ProcessDefinitionMeta>() {
};
ProcessDefinition aProcessDefinition = getProcessDefinition(PROCESS_POOL_LANE);
// 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(6);
assertThat(entity.getBody().getUsers()).hasSize(4);
assertThat(entity.getBody().getGroups()).hasSize(4);
assertThat(entity.getBody().getUserTasks()).hasSize(3);
assertThat(entity.getBody().getServiceTasks()).hasSize(3);
}
use of org.activiti.cloud.services.api.model.ProcessDefinitionMeta in project activiti-cloud by Activiti.
the class ProcessDefinitionMetaControllerImpl method getProcessDefinitionMetadata.
@Override
public Resource<ProcessDefinitionMeta> getProcessDefinitionMetadata(@PathVariable String id) {
org.activiti.engine.repository.ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(id).singleResult();
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("Unable to find process definition for the given id:'" + id + "'");
}
List<Process> processes = repositoryService.getBpmnModel(id).getProcesses();
Set<ProcessDefinitionVariable> variables = new HashSet<>();
Set<String> users = new HashSet<>();
Set<String> groups = new HashSet<>();
Set<ProcessDefinitionUserTask> userTasks = new HashSet<>();
Set<ProcessDefinitionServiceTask> serviceTasks = new HashSet<>();
for (Process process : processes) {
variables.addAll(getVariables(process));
List<FlowElement> flowElementList = (List<FlowElement>) process.getFlowElements();
for (FlowElement flowElement : flowElementList) {
if (flowElement.getClass().equals(UserTask.class)) {
UserTask userTask = (UserTask) flowElement;
ProcessDefinitionUserTask task = new ProcessDefinitionUserTask(userTask.getName(), userTask.getDocumentation());
userTasks.add(task);
users.addAll(userTask.getCandidateUsers());
groups.addAll(userTask.getCandidateGroups());
}
if (flowElement.getClass().equals(ServiceTask.class)) {
ServiceTask serviceTask = (ServiceTask) flowElement;
ProcessDefinitionServiceTask task = new ProcessDefinitionServiceTask(serviceTask.getName(), serviceTask.getImplementation());
serviceTasks.add(task);
}
}
}
return resourceAssembler.toResource(new ProcessDefinitionMeta(processDefinition.getId(), processDefinition.getName(), processDefinition.getDescription(), processDefinition.getVersion(), users, groups, variables, userTasks, serviceTasks));
}
Aggregations