use of org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent in project activiti-cloud by Activiti.
the class AuditSteps method checkTaskVariableEvent.
@Step
public void checkTaskVariableEvent(String processInstanceId, String taskId, String variableName, VariableEvent.VariableEvents eventType) throws Exception {
Collection<CloudRuntimeEvent> events = getEventsByProcessInstanceIdAndEventType(processInstanceId, eventType.name());
await().untilAsserted(() -> {
assertThat(events).isNotEmpty();
assertThat(events).extracting(e -> e.getEventType()).containsOnly(eventType);
List<CloudRuntimeEvent> varEvents = events.stream().filter(e -> variableName.equals(((CloudVariableEvent) e).getEntity().getName()) && taskId.equals(((CloudVariableEvent) e).getEntity().getTaskId())).collect(Collectors.toList());
// could be more than one if there are multiple vars with same name
assertThat(varEvents.size()).isGreaterThanOrEqualTo(1);
CloudRuntimeEvent resultingEvent = varEvents.get(0);
assertThat(resultingEvent).isNotNull();
assertThat(resultingEvent).isInstanceOf(CloudVariableEvent.class);
assertThat(((CloudVariableEvent) resultingEvent).getEntity().getName()).isEqualTo(variableName);
assertThat(resultingEvent.getServiceName()).isNotEmpty();
assertThat(resultingEvent.getServiceFullName()).isNotEmpty();
});
}
use of org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent in project activiti-cloud by Activiti.
the class AuditSteps method checkProcessInstanceVariableEvent.
@Step
public void checkProcessInstanceVariableEvent(String processInstanceId, String variableName, VariableEvent.VariableEvents eventType) throws Exception {
await().untilAsserted(() -> {
Collection<CloudRuntimeEvent> events = getEventsByProcessInstanceIdAndEventType(processInstanceId, eventType.name());
assertThat(events).isNotEmpty();
assertThat(events).extracting(e -> e.getEventType()).containsOnly(eventType);
List<CloudRuntimeEvent> processInstanceTasks = events.stream().filter(e -> variableName.equals(((CloudVariableEvent) e).getEntity().getName()) && processInstanceId.equals(((CloudVariableEvent) e).getEntity().getProcessInstanceId()) && !((CloudVariableEvent) e).getEntity().isTaskVariable()).collect(Collectors.toList());
// could be more than one if there are multiple vars
assertThat(processInstanceTasks).hasSize(1);
CloudRuntimeEvent resultingEvent = processInstanceTasks.get(0);
assertThat(resultingEvent).isNotNull();
assertThat(resultingEvent).isInstanceOf(CloudVariableEvent.class);
assertThat(((CloudVariableEvent) resultingEvent).getEntity().getName()).isEqualTo(variableName);
assertThat(resultingEvent.getServiceName()).isNotEmpty();
assertThat(resultingEvent.getServiceFullName()).isNotEmpty();
});
}
use of org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent in project activiti-cloud by Activiti.
the class AuditSteps method checkProcessInstanceEvent.
@Step
public void checkProcessInstanceEvent(String processInstanceId, ProcessRuntimeEvent.ProcessEvents eventType, long timeoutSeconds) throws Exception {
Collection<CloudRuntimeEvent> events = getEventsByProcessInstanceIdAndEventType(processInstanceId, eventType.name());
await().atMost(timeoutSeconds, TimeUnit.SECONDS).untilAsserted(() -> {
assertThat(events).isNotEmpty();
CloudRuntimeEvent resultingEvent = events.iterator().next();
assertThat(resultingEvent).isNotNull();
assertThat(resultingEvent).isInstanceOf(CloudProcessRuntimeEvent.class);
assertThat(resultingEvent.getServiceName()).isNotEmpty();
assertThat(resultingEvent.getServiceFullName()).isNotEmpty();
});
}
use of org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent in project activiti-cloud by Activiti.
the class AuditEventsControllerImpl method findAll.
@RequestMapping(method = RequestMethod.GET)
public PagedResources<Resource<CloudRuntimeEvent<?, CloudRuntimeEventType>>> findAll(@RequestParam(value = "search", required = false) String search, Pageable pageable) {
Specification<AuditEventEntity> spec = createSearchSpec(search);
spec = securityPoliciesApplicationService.createSpecWithSecurity(spec, SecurityPolicyAccess.READ);
Page<AuditEventEntity> allAuditInPage = eventsRepository.findAll(spec, pageable);
List<CloudRuntimeEvent<?, CloudRuntimeEventType>> events = new ArrayList<>();
for (AuditEventEntity aee : allAuditInPage.getContent()) {
EventToEntityConverter converterByEventTypeName = eventConverters.getConverterByEventTypeName(aee.getEventType());
if (converterByEventTypeName != null) {
events.add(converterByEventTypeName.convertToAPI(aee));
} else {
LOGGER.warn("Converter not found for Event Type: " + aee.getEventType());
}
}
return pagedResourcesAssembler.toResource(pageable, new PageImpl<>(events, pageable, allAuditInPage.getTotalElements()), eventResourceAssembler);
}
use of org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent in project activiti-cloud by Activiti.
the class AuditEventsControllerImpl method findById.
@RequestMapping(value = "/{eventId}", method = RequestMethod.GET)
public Resource<CloudRuntimeEvent<?, CloudRuntimeEventType>> findById(@PathVariable String eventId) {
Optional<AuditEventEntity> findResult = eventsRepository.findByEventId(eventId);
if (!findResult.isPresent()) {
throw new NotFoundException("Unable to find event for the given id:'" + eventId + "'");
}
AuditEventEntity auditEventEntity = findResult.get();
if (!securityPoliciesApplicationService.canRead(auditEventEntity.getProcessDefinitionId(), auditEventEntity.getServiceFullName())) {
throw new ActivitiForbiddenException("Operation not permitted for " + auditEventEntity.getProcessDefinitionId());
}
CloudRuntimeEvent cloudRuntimeEvent = eventConverters.getConverterByEventTypeName(auditEventEntity.getEventType()).convertToAPI(auditEventEntity);
return eventResourceAssembler.toResource(cloudRuntimeEvent);
}
Aggregations