Search in sources :

Example 6 with BPMNSignalReceivedEvent

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

the class ProcessRuntimeBPMNSignalReceivedIT method shouldGetOneSignalReceivedEventPerWaitingSignalsForNonStartSignals.

@Test
public void shouldGetOneSignalReceivedEventPerWaitingSignalsForNonStartSignals() {
    // given
    securityUtil.logInAs("user");
    ProcessInstance boundarySignalProcInst1 = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(PROCESS_WITH_BOUNDARY_SIGNAL).build());
    ProcessInstance boundarySignalProcInst2 = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey(PROCESS_WITH_BOUNDARY_SIGNAL).build());
    // when
    ProcessInstance process = processRuntime.start(ProcessPayloadBuilder.start().withProcessDefinitionKey("signalThrowEventProcess").build());
    // then
    assertThat(listener.getSignalReceivedEvents()).isNotEmpty().hasSize(2);
    assertThat(listener.getSignalReceivedEvents()).extracting(BPMNSignalReceivedEvent::getEventType, BPMNSignalReceivedEvent::getProcessDefinitionId, BPMNSignalReceivedEvent::getProcessInstanceId, event -> event.getEntity().getSignalPayload().getName(), event -> event.getEntity().getElementId(), event -> event.getEntity().getProcessDefinitionId(), event -> event.getEntity().getProcessInstanceId()).contains(tuple(BPMNSignalEvent.SignalEvents.SIGNAL_RECEIVED, boundarySignalProcInst1.getProcessDefinitionId(), boundarySignalProcInst1.getId(), "go", "sid-6220E76D-719E-4C05-A664-BC186E50D477", boundarySignalProcInst1.getProcessDefinitionId(), boundarySignalProcInst1.getId()), tuple(BPMNSignalEvent.SignalEvents.SIGNAL_RECEIVED, boundarySignalProcInst2.getProcessDefinitionId(), boundarySignalProcInst2.getId(), "go", "sid-6220E76D-719E-4C05-A664-BC186E50D477", boundarySignalProcInst2.getProcessDefinitionId(), boundarySignalProcInst2.getId()));
    assertThat(process.getStatus()).isEqualTo(ProcessInstanceStatus.COMPLETED);
}
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) ProcessInstance(org.activiti.api.process.model.ProcessInstance) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with BPMNSignalReceivedEvent

use of org.activiti.api.process.model.events.BPMNSignalReceivedEvent 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

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