Search in sources :

Example 1 with EventSubscriptionQueryImpl

use of org.activiti.engine.impl.EventSubscriptionQueryImpl in project Activiti by Activiti.

the class MessageStartEventTest method testUpdateProcessVersionCancelsSubscriptions.

public void testUpdateProcessVersionCancelsSubscriptions() {
    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();
    List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().list();
    assertEquals(1, eventSubscriptions.size());
    assertEquals(1, processDefinitions.size());
    String newDeploymentId = repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/bpmn/event/message/MessageStartEventTest.testSingleMessageStartEvent.bpmn20.xml").deploy().getId();
    List<EventSubscriptionEntity> newEventSubscriptions = new EventSubscriptionQueryImpl(processEngineConfiguration.getCommandExecutor()).list();
    List<ProcessDefinition> newProcessDefinitions = repositoryService.createProcessDefinitionQuery().list();
    assertEquals(1, newEventSubscriptions.size());
    assertEquals(2, newProcessDefinitions.size());
    int version1Count = 0;
    int version2Count = 0;
    for (ProcessDefinition processDefinition : newProcessDefinitions) {
        if (processDefinition.getVersion() == 1) {
            for (EventSubscriptionEntity subscription : newEventSubscriptions) {
                if (subscription.getConfiguration().equals(processDefinition.getId())) {
                    version1Count++;
                }
            }
        } else {
            for (EventSubscriptionEntity subscription : newEventSubscriptions) {
                if (subscription.getConfiguration().equals(processDefinition.getId())) {
                    version2Count++;
                }
            }
        }
    }
    assertEquals(0, version1Count);
    assertEquals(1, version2Count);
    assertFalse(eventSubscriptions.equals(newEventSubscriptions));
    repositoryService.deleteDeployment(deploymentId);
    repositoryService.deleteDeployment(newDeploymentId);
}
Also used : EventSubscriptionQueryImpl(org.activiti.engine.impl.EventSubscriptionQueryImpl) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) EventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity)

Example 2 with EventSubscriptionQueryImpl

use of org.activiti.engine.impl.EventSubscriptionQueryImpl 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 3 with EventSubscriptionQueryImpl

use of org.activiti.engine.impl.EventSubscriptionQueryImpl 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

EventSubscriptionQueryImpl (org.activiti.engine.impl.EventSubscriptionQueryImpl)3 EventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity)3 Date (java.util.Date)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1 Execution (org.activiti.engine.runtime.Execution)1 Task (org.activiti.engine.task.Task)1 Deployment (org.activiti.engine.test.Deployment)1