Search in sources :

Example 1 with BPMNSignalReceivedEvent

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

the class ProcessRuntimeBPMNSignalReceivedIT method shouldGetSignalReceivedEventWithVariables.

@Test
public void shouldGetSignalReceivedEventWithVariables() {
    // given
    securityUtil.logInAs("user");
    // when
    ProcessInstance process = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(PROCESS_WITH_BOUNDARY_SIGNAL).withVariable("name", "peter").build());
    SignalPayload signalPayload = ProcessPayloadBuilder.signal().withName("go").withVariable("signal_variable", "test").build();
    processRuntime.signal(signalPayload);
    // then
    assertThat(listener.getSignalReceivedEvents()).isNotEmpty().hasSize(1);
    BPMNSignalReceivedEvent event = listener.getSignalReceivedEvents().iterator().next();
    assertThat(event.getEntity()).isNotNull();
    assertThat(event.getProcessInstanceId()).isEqualTo(process.getId());
    assertThat(event.getEntity().getSignalPayload()).isNotNull();
    assertThat(event.getEntity().getSignalPayload().getName()).isEqualTo("go");
    assertThat(event.getEntity().getSignalPayload().getVariables().size()).isEqualTo(1);
    assertThat(event.getEntity().getSignalPayload().getVariables().get("signal_variable")).isEqualTo("test");
}
Also used : BPMNSignalReceivedEvent(org.activiti.api.process.model.events.BPMNSignalReceivedEvent) 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 2 with BPMNSignalReceivedEvent

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

the class SignalThrowCatchTest method testProcessWithIntermediateCatchEventSignal.

@Test
public void testProcessWithIntermediateCatchEventSignal() {
    securityUtil.logInAs("user1");
    ProcessInstance processInstance = startIntermediateCatchEventSignalProcess();
    assertThat(RuntimeTestConfiguration.collectedEvents).extracting(RuntimeEvent::getEventType).containsExactly(ProcessRuntimeEvent.ProcessEvents.PROCESS_CREATED, ProcessRuntimeEvent.ProcessEvents.PROCESS_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, BPMNSequenceFlowTakenEvent.SequenceFlowEvents.SEQUENCE_FLOW_TAKEN, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED);
    BPMNActivityImpl signalCatchEvent = (BPMNActivityImpl) RuntimeTestConfiguration.collectedEvents.get(5).getEntity();
    assertThat(signalCatchEvent.getActivityType()).isEqualTo("intermediateCatchEvent");
    clearEvents();
    SignalPayload signalPayload = ProcessPayloadBuilder.signal().withName("Test").withVariable("signal_variable", "test").build();
    processRuntime.signal(signalPayload);
    assertThat(RuntimeTestConfiguration.collectedEvents).extracting(RuntimeEvent::getEventType).containsExactly(BPMNSignalEvent.SignalEvents.SIGNAL_RECEIVED, VariableEvent.VariableEvents.VARIABLE_CREATED, BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, BPMNSequenceFlowTakenEvent.SequenceFlowEvents.SEQUENCE_FLOW_TAKEN, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED);
    BPMNSignalReceivedEvent event = (BPMNSignalReceivedEvent) RuntimeTestConfiguration.collectedEvents.get(0);
    assertThat(event.getEntity()).isNotNull();
    assertThat(event.getProcessInstanceId()).isEqualTo(processInstance.getId());
    assertThat(event.getEntity().getSignalPayload()).isNotNull();
    assertThat(event.getEntity().getSignalPayload().getName()).isEqualTo(signalPayload.getName());
    assertThat(event.getEntity().getSignalPayload().getVariables()).hasSize(signalPayload.getVariables().size());
    assertThat(event.getEntity().getSignalPayload().getVariables().get("signal_variable")).isEqualTo("test");
}
Also used : BPMNActivityImpl(org.activiti.api.runtime.model.impl.BPMNActivityImpl) BPMNSignalReceivedEvent(org.activiti.api.process.model.events.BPMNSignalReceivedEvent) 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 3 with BPMNSignalReceivedEvent

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

the class SignalThrowCatchTest method testProcessStartedBySignal.

@Test
public void testProcessStartedBySignal() {
    securityUtil.logInAs("user1");
    SignalPayload signalPayload = ProcessPayloadBuilder.signal().withName("SignalStart").withVariable("signal_variable", "test").build();
    processRuntime.signal(signalPayload);
    assertThat(RuntimeTestConfiguration.collectedEvents).extracting(RuntimeEvent::getEventType).containsExactly(ProcessRuntimeEvent.ProcessEvents.PROCESS_CREATED, BPMNSignalEvent.SignalEvents.SIGNAL_RECEIVED, VariableEvent.VariableEvents.VARIABLE_CREATED, ProcessRuntimeEvent.ProcessEvents.PROCESS_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, BPMNSequenceFlowTakenEvent.SequenceFlowEvents.SEQUENCE_FLOW_TAKEN, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED);
    BPMNSignalReceivedEvent event = (BPMNSignalReceivedEvent) RuntimeTestConfiguration.collectedEvents.get(1);
    assertThat(event.getEntity()).isNotNull();
    assertThat(event.getEntity().getSignalPayload()).isNotNull();
    assertThat(event.getEntity().getSignalPayload().getName()).isEqualTo(signalPayload.getName());
    assertThat(event.getEntity().getSignalPayload().getVariables()).hasSize(signalPayload.getVariables().size());
    assertThat(event.getEntity().getSignalPayload().getVariables().get("signal_variable")).isEqualTo("test");
    clearEvents();
}
Also used : BPMNSignalReceivedEvent(org.activiti.api.process.model.events.BPMNSignalReceivedEvent) SignalPayload(org.activiti.api.process.model.payloads.SignalPayload) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with BPMNSignalReceivedEvent

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

the class SignalThrowCatchTest method testProcessWithBoundaryEventSignal.

@Test
public void testProcessWithBoundaryEventSignal() {
    securityUtil.logInAs("user1");
    ProcessInstance processInstance = startBoundaryEventSignalProcess();
    assertThat(RuntimeTestConfiguration.collectedEvents).extracting(RuntimeEvent::getEventType).containsExactly(ProcessRuntimeEvent.ProcessEvents.PROCESS_CREATED, ProcessRuntimeEvent.ProcessEvents.PROCESS_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, BPMNSequenceFlowTakenEvent.SequenceFlowEvents.SEQUENCE_FLOW_TAKEN, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, TaskRuntimeEvent.TaskEvents.TASK_CREATED);
    BPMNActivityImpl signalCatchEvent = (BPMNActivityImpl) RuntimeTestConfiguration.collectedEvents.get(5).getEntity();
    assertThat(signalCatchEvent.getActivityType()).isEqualTo("userTask");
    assertThat(signalCatchEvent.getActivityName()).isEqualTo("Boundary container");
    clearEvents();
    SignalPayload signalPayload = ProcessPayloadBuilder.signal().withName("Test").withVariable("signal_variable", "test").build();
    processRuntime.signal(signalPayload);
    assertThat(RuntimeTestConfiguration.collectedEvents).extracting(RuntimeEvent::getEventType).containsExactlyInAnyOrder(BPMNSignalEvent.SignalEvents.SIGNAL_RECEIVED, VariableEvent.VariableEvents.VARIABLE_CREATED, TaskRuntimeEvent.TaskEvents.TASK_CANCELLED, BPMNActivityEvent.ActivityEvents.ACTIVITY_CANCELLED, BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED, BPMNSequenceFlowTakenEvent.SequenceFlowEvents.SEQUENCE_FLOW_TAKEN, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, VariableEvent.VariableEvents.VARIABLE_CREATED, TaskRuntimeEvent.TaskEvents.TASK_CREATED);
    BPMNSignalReceivedEvent event = (BPMNSignalReceivedEvent) RuntimeTestConfiguration.collectedEvents.get(0);
    assertThat(event.getEntity()).isNotNull();
    assertThat(event.getProcessInstanceId()).isEqualTo(processInstance.getId());
    assertThat(event.getEntity().getSignalPayload()).isNotNull();
    assertThat(event.getEntity().getSignalPayload().getName()).isEqualTo(signalPayload.getName());
    assertThat(event.getEntity().getSignalPayload().getVariables()).hasSize(signalPayload.getVariables().size());
    assertThat(event.getEntity().getSignalPayload().getVariables().get("signal_variable")).isEqualTo("test");
    clearEvents();
}
Also used : BPMNActivityImpl(org.activiti.api.runtime.model.impl.BPMNActivityImpl) BPMNSignalReceivedEvent(org.activiti.api.process.model.events.BPMNSignalReceivedEvent) 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 5 with BPMNSignalReceivedEvent

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

the class ToSignalReceivedConverterTest method fromShouldReturnConvertedEventAndSetProcessInstanceIdAndProcessDefinitionId.

@Test
public void fromShouldReturnConvertedEventAndSetProcessInstanceIdAndProcessDefinitionId() {
    // given
    ActivitiSignalEventImpl internalEvent = new ActivitiSignalEventImpl(ActivitiEventType.ACTIVITY_SIGNALED);
    internalEvent.setProcessDefinitionId("procDefId");
    internalEvent.setProcessInstanceId("procInstId");
    BPMNSignalImpl bpmnSignal = new BPMNSignalImpl();
    given(toSignalConverter.from(internalEvent)).willReturn(bpmnSignal);
    // when
    BPMNSignalReceivedEvent bpmnSignalReceivedEvent = toSignalReceivedConverter.from(internalEvent).orElse(null);
    // then
    assertThat(bpmnSignalReceivedEvent).isNotNull();
    assertThat(bpmnSignalReceivedEvent.getEntity()).isEqualTo(bpmnSignal);
    assertThat(bpmnSignalReceivedEvent.getProcessDefinitionId()).isEqualTo("procDefId");
    assertThat(bpmnSignalReceivedEvent.getProcessInstanceId()).isEqualTo("procInstId");
}
Also used : ActivitiSignalEventImpl(org.activiti.engine.delegate.event.impl.ActivitiSignalEventImpl) BPMNSignalReceivedEvent(org.activiti.api.process.model.events.BPMNSignalReceivedEvent) BPMNSignalImpl(org.activiti.api.runtime.model.impl.BPMNSignalImpl) Test(org.junit.jupiter.api.Test)

Aggregations

BPMNSignalReceivedEvent (org.activiti.api.process.model.events.BPMNSignalReceivedEvent)7 Test (org.junit.jupiter.api.Test)7 SignalPayload (org.activiti.api.process.model.payloads.SignalPayload)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 ProcessInstance (org.activiti.api.process.model.ProcessInstance)5 ProcessDefinition (org.activiti.api.process.model.ProcessDefinition)2 ProcessInstanceStatus (org.activiti.api.process.model.ProcessInstance.ProcessInstanceStatus)2 ProcessPayloadBuilder (org.activiti.api.process.model.builders.ProcessPayloadBuilder)2 BPMNSignalEvent (org.activiti.api.process.model.events.BPMNSignalEvent)2 ProcessRuntime (org.activiti.api.process.runtime.ProcessRuntime)2 BPMNActivityImpl (org.activiti.api.runtime.model.impl.BPMNActivityImpl)2 Page (org.activiti.api.runtime.shared.query.Page)2 Pageable (org.activiti.api.runtime.shared.query.Pageable)2 DummyBPMNSignalReceivedListener (org.activiti.spring.boot.process.listener.DummyBPMNSignalReceivedListener)2 SecurityUtil (org.activiti.spring.boot.security.util.SecurityUtil)2 ProcessCleanUpUtil (org.activiti.spring.boot.test.util.ProcessCleanUpUtil)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Assertions.tuple (org.assertj.core.api.Assertions.tuple)2 Tuple (org.assertj.core.groups.Tuple)2 AfterEach (org.junit.jupiter.api.AfterEach)2