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);
}
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);
}
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());
}
}
Aggregations