Search in sources :

Example 16 with EventSubscriptionEntity

use of org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity in project Activiti by Activiti.

the class MessageStartEventTest method testDeploymentCreatesSubscriptions.

public void testDeploymentCreatesSubscriptions() {
    String deploymentId = repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/bpmn/event/message/MessageStartEventTest.testSingleMessageStartEvent.bpmn20.xml").deploy().getId();
    List<EventSubscriptionEntity> eventSubscriptions = new EventSubscriptionQueryImpl(processEngineConfiguration.getCommandExecutor()).list();
    assertEquals(1, eventSubscriptions.size());
    repositoryService.deleteDeployment(deploymentId);
}
Also used : EventSubscriptionQueryImpl(org.activiti.engine.impl.EventSubscriptionQueryImpl) EventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity)

Example 17 with EventSubscriptionEntity

use of org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity in project Activiti by Activiti.

the class EventBasedGatewayTest method testCatchSignalAndMessageAndTimer.

@Deployment
public void testCatchSignalAndMessageAndTimer() {
    runtimeService.startProcessInstanceByKey("catchSignal");
    assertEquals(2, createEventSubscriptionQuery().count());
    EventSubscriptionQueryImpl messageEventSubscriptionQuery = createEventSubscriptionQuery().eventType("message");
    assertEquals(1, messageEventSubscriptionQuery.count());
    assertEquals(1, createEventSubscriptionQuery().eventType("signal").count());
    assertEquals(1, runtimeService.createProcessInstanceQuery().count());
    assertEquals(1, managementService.createJobQuery().count());
    // we can query for an execution with has both a signal AND message subscription
    Execution execution = runtimeService.createExecutionQuery().messageEventSubscriptionName("newInvoice").signalEventSubscriptionName("alert").singleResult();
    assertNotNull(execution);
    processEngineConfiguration.getClock().setCurrentTime(new Date(processEngineConfiguration.getClock().getCurrentTime().getTime() + 10000));
    try {
        EventSubscriptionEntity messageEventSubscription = messageEventSubscriptionQuery.singleResult();
        runtimeService.messageEventReceived(messageEventSubscription.getEventName(), messageEventSubscription.getExecutionId());
        assertEquals(0, createEventSubscriptionQuery().count());
        assertEquals(1, runtimeService.createProcessInstanceQuery().count());
        assertEquals(0, managementService.createJobQuery().count());
        Task task = taskService.createTaskQuery().taskName("afterMessage").singleResult();
        assertNotNull(task);
        taskService.complete(task.getId());
    } finally {
        processEngineConfiguration.getClock().setCurrentTime(new Date());
    }
}
Also used : Task(org.activiti.engine.task.Task) Execution(org.activiti.engine.runtime.Execution) EventSubscriptionQueryImpl(org.activiti.engine.impl.EventSubscriptionQueryImpl) Date(java.util.Date) EventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity) Deployment(org.activiti.engine.test.Deployment)

Aggregations

EventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity)17 MessageEventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity)8 SignalEventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity)8 CommandContext (org.activiti.engine.impl.interceptor.CommandContext)7 Deployment (org.activiti.engine.test.Deployment)5 Execution (org.activiti.engine.runtime.Execution)4 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)4 Task (org.activiti.engine.task.Task)4 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)3 EventSubscriptionQueryImpl (org.activiti.engine.impl.EventSubscriptionQueryImpl)3 ActivitiException (org.activiti.engine.ActivitiException)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 List (java.util.List)1 EventSubscriptionDeclaration (org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration)1 CompensateEventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.CompensateEventSubscriptionEntity)1 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)1 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1