Search in sources :

Example 6 with SignalPayload

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

the class ProcessRuntimeIT method signalAdmin.

@Test
public void signalAdmin() {
    // when
    SignalPayload signalPayload = new SignalPayload("The Signal", null);
    processAdminRuntimeMock.signal(signalPayload);
    verify(eventPublisher).publishEvent(signalPayload);
    Page<ProcessInstance> processInstancePage = processAdminRuntimeMock.processInstances(PAGEABLE);
    // then
    assertThat(processInstancePage).isNotNull();
    assertThat(processInstancePage.getContent()).hasSize(1);
    assertThat(processInstancePage.getContent().get(0).getProcessDefinitionKey()).isEqualTo("processWithSignalStart1");
    processAdminRuntimeMock.delete(ProcessPayloadBuilder.delete(processInstancePage.getContent().get(0).getId()));
}
Also used : ProcessInstance(org.activiti.api.process.model.ProcessInstance) SignalPayload(org.activiti.api.process.model.payloads.SignalPayload) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with SignalPayload

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

the class ToSignalConverter method from.

@SuppressWarnings("unchecked")
public BPMNSignal from(ActivitiSignalEvent internalEvent) {
    BPMNSignalImpl signal = new BPMNSignalImpl(internalEvent.getActivityId());
    signal.setProcessDefinitionId(internalEvent.getProcessDefinitionId());
    signal.setProcessInstanceId(internalEvent.getProcessInstanceId());
    SignalPayload signalPayload = ProcessPayloadBuilder.signal().withName(internalEvent.getSignalName()).build();
    if (internalEvent.getSignalData() != null) {
        Map<String, Object> sourceVariables = (Map<String, Object>) internalEvent.getSignalData();
        signalPayload.setVariables(new HashMap<>(sourceVariables));
    }
    signal.setSignalPayload(signalPayload);
    return signal;
}
Also used : BPMNSignalImpl(org.activiti.api.runtime.model.impl.BPMNSignalImpl) SignalPayload(org.activiti.api.process.model.payloads.SignalPayload) Map(java.util.Map) HashMap(java.util.HashMap)

Example 8 with SignalPayload

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

the class ProcessRuntimeBPMNSignalReceivedIT method shouldGetSignalReceivedEventsForProcessWithSignalStart.

@Test
public void shouldGetSignalReceivedEventsForProcessWithSignalStart() {
    // In this test processWithSignalStart1 should be started
    // given
    securityUtil.logInAs("user");
    Page<ProcessDefinition> processDefinitionPage = processRuntime.processDefinitions(Pageable.of(0, 10), ProcessPayloadBuilder.processDefinitions().withProcessDefinitionKey("processWithSignalStart1").build());
    assertThat(processDefinitionPage.getContent()).hasSize(1);
    // when
    SignalPayload signalPayload = new SignalPayload("The Signal", null);
    processRuntime.signal(signalPayload);
    // then
    String processDefinitionId = processDefinitionPage.getContent().get(0).getId();
    assertThat(listener.getSignalReceivedEvents()).extracting(BPMNSignalReceivedEvent::getEventType, BPMNSignalReceivedEvent::getProcessDefinitionId, event -> event.getEntity().getSignalPayload().getName(), event -> event.getEntity().getElementId(), event -> event.getEntity().getProcessDefinitionId()).contains(Tuple.tuple(BPMNSignalEvent.SignalEvents.SIGNAL_RECEIVED, processDefinitionId, "The Signal", "theStart", processDefinitionId));
}
Also used : ProcessInstance(org.activiti.api.process.model.ProcessInstance) BeforeEach(org.junit.jupiter.api.BeforeEach) Pageable(org.activiti.api.runtime.shared.query.Pageable) Tuple(org.assertj.core.groups.Tuple) Assertions.tuple(org.assertj.core.api.Assertions.tuple) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SecurityUtil(org.activiti.spring.boot.security.util.SecurityUtil) Autowired(org.springframework.beans.factory.annotation.Autowired) Import(org.springframework.context.annotation.Import) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) Page(org.activiti.api.runtime.shared.query.Page) ProcessPayloadBuilder(org.activiti.api.process.model.builders.ProcessPayloadBuilder) BPMNSignalReceivedEvent(org.activiti.api.process.model.events.BPMNSignalReceivedEvent) ProcessRuntime(org.activiti.api.process.runtime.ProcessRuntime) Test(org.junit.jupiter.api.Test) BPMNSignalEvent(org.activiti.api.process.model.events.BPMNSignalEvent) AfterEach(org.junit.jupiter.api.AfterEach) SignalPayload(org.activiti.api.process.model.payloads.SignalPayload) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ProcessCleanUpUtil(org.activiti.spring.boot.test.util.ProcessCleanUpUtil) ProcessInstanceStatus(org.activiti.api.process.model.ProcessInstance.ProcessInstanceStatus) DummyBPMNSignalReceivedListener(org.activiti.spring.boot.process.listener.DummyBPMNSignalReceivedListener) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) SignalPayload(org.activiti.api.process.model.payloads.SignalPayload) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

SignalPayload (org.activiti.api.process.model.payloads.SignalPayload)8 Test (org.junit.jupiter.api.Test)7 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 ProcessInstance (org.activiti.api.process.model.ProcessInstance)6 BPMNSignalReceivedEvent (org.activiti.api.process.model.events.BPMNSignalReceivedEvent)5 BPMNActivityImpl (org.activiti.api.runtime.model.impl.BPMNActivityImpl)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 VariableInstance (org.activiti.api.model.shared.model.VariableInstance)1 ProcessDefinition (org.activiti.api.process.model.ProcessDefinition)1 ProcessInstanceStatus (org.activiti.api.process.model.ProcessInstance.ProcessInstanceStatus)1 ProcessPayloadBuilder (org.activiti.api.process.model.builders.ProcessPayloadBuilder)1 BPMNSignalEvent (org.activiti.api.process.model.events.BPMNSignalEvent)1 ProcessRuntime (org.activiti.api.process.runtime.ProcessRuntime)1 BPMNSignalImpl (org.activiti.api.runtime.model.impl.BPMNSignalImpl)1 Page (org.activiti.api.runtime.shared.query.Page)1 Pageable (org.activiti.api.runtime.shared.query.Pageable)1 DummyBPMNSignalReceivedListener (org.activiti.spring.boot.process.listener.DummyBPMNSignalReceivedListener)1 SecurityUtil (org.activiti.spring.boot.security.util.SecurityUtil)1 ProcessCleanUpUtil (org.activiti.spring.boot.test.util.ProcessCleanUpUtil)1