use of org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity in project Activiti by Activiti.
the class EventSubscriptionQueryTest method testQueryByEventType.
public void testQueryByEventType() {
processEngineConfiguration.getCommandExecutor().execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
MessageEventSubscriptionEntity messageEventSubscriptionEntity1 = new MessageEventSubscriptionEntity();
messageEventSubscriptionEntity1.setEventName("messageName");
messageEventSubscriptionEntity1.insert();
MessageEventSubscriptionEntity messageEventSubscriptionEntity2 = new MessageEventSubscriptionEntity();
messageEventSubscriptionEntity2.setEventName("messageName");
messageEventSubscriptionEntity2.insert();
SignalEventSubscriptionEntity signalEventSubscriptionEntity3 = new SignalEventSubscriptionEntity();
signalEventSubscriptionEntity3.setEventName("messageName2");
signalEventSubscriptionEntity3.insert();
return null;
}
});
List<EventSubscriptionEntity> list = newEventSubscriptionQuery().eventType("signal").list();
assertEquals(1, list.size());
list = newEventSubscriptionQuery().eventType("message").list();
assertEquals(2, list.size());
cleanDb();
}
use of org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity in project Activiti by Activiti.
the class EventSubscriptionQueryTest method testQueryByEventName.
public void testQueryByEventName() {
processEngineConfiguration.getCommandExecutor().execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
MessageEventSubscriptionEntity messageEventSubscriptionEntity1 = new MessageEventSubscriptionEntity();
messageEventSubscriptionEntity1.setEventName("messageName");
messageEventSubscriptionEntity1.insert();
MessageEventSubscriptionEntity messageEventSubscriptionEntity2 = new MessageEventSubscriptionEntity();
messageEventSubscriptionEntity2.setEventName("messageName");
messageEventSubscriptionEntity2.insert();
MessageEventSubscriptionEntity messageEventSubscriptionEntity3 = new MessageEventSubscriptionEntity();
messageEventSubscriptionEntity3.setEventName("messageName2");
messageEventSubscriptionEntity3.insert();
return null;
}
});
List<EventSubscriptionEntity> list = newEventSubscriptionQuery().eventName("messageName").list();
assertEquals(2, list.size());
list = newEventSubscriptionQuery().eventName("messageName2").list();
assertEquals(1, list.size());
cleanDb();
}
use of org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity in project Activiti by Activiti.
the class TransactionSubProcessTest method testMultiInstanceTx.
/*
* The cancel end event cancels all instances, compensation is performed for all instances
*
* see spec page 470:
* "If the cancelActivity attribute is set, the Activity the Event is attached to is then
* cancelled (in case of a multi-instance, all its instances are cancelled);"
*/
@Deployment
public void testMultiInstanceTx() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("transactionProcess");
// there are now 5 instances of the transaction:
List<EventSubscriptionEntity> EventSubscriptionEntitys = createEventSubscriptionQuery().eventType("compensate").list();
// there are 10 compensation event subscriptions
assertEquals(10, EventSubscriptionEntitys.size());
// the event subscriptions are all under the same execution (the execution of the multi-instance wrapper)
String executionId = EventSubscriptionEntitys.get(0).getExecutionId();
for (EventSubscriptionEntity EventSubscriptionEntity : EventSubscriptionEntitys) {
if (!executionId.equals(EventSubscriptionEntity.getExecutionId())) {
fail("subscriptions not under same execution");
}
}
Task task = taskService.createTaskQuery().listPage(0, 1).get(0);
// canceling one instance triggers compensation for all other instances:
taskService.setVariable(task.getId(), "confirmed", false);
taskService.complete(task.getId());
assertEquals(0, createEventSubscriptionQuery().count());
assertEquals(5, runtimeService.getVariable(processInstance.getId(), "undoBookHotel"));
assertEquals(5, runtimeService.getVariable(processInstance.getId(), "undoBookFlight"));
runtimeService.signal(runtimeService.createExecutionQuery().activityId("afterCancellation").singleResult().getId());
assertProcessEnded(processInstance.getId());
}
use of org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity in project Activiti by Activiti.
the class TransactionSubProcessTest method testMultiInstanceTxSuccessful.
@Deployment(resources = { "org/activiti/engine/test/bpmn/subprocess/transaction/TransactionSubProcessTest.testMultiInstanceTx.bpmn20.xml" })
public void testMultiInstanceTxSuccessful() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("transactionProcess");
// there are now 5 instances of the transaction:
List<EventSubscriptionEntity> EventSubscriptionEntitys = createEventSubscriptionQuery().eventType("compensate").list();
// there are 10 compensation event subscriptions
assertEquals(10, EventSubscriptionEntitys.size());
// the event subscriptions are all under the same execution (the execution of the multi-instance wrapper)
String executionId = EventSubscriptionEntitys.get(0).getExecutionId();
for (EventSubscriptionEntity EventSubscriptionEntity : EventSubscriptionEntitys) {
if (!executionId.equals(EventSubscriptionEntity.getExecutionId())) {
fail("subscriptions not under same execution");
}
}
// first complete the inner user-tasks
List<Task> tasks = taskService.createTaskQuery().list();
for (Task task : tasks) {
taskService.setVariable(task.getId(), "confirmed", true);
taskService.complete(task.getId());
}
// now complete the inner receive tasks
List<Execution> executions = runtimeService.createExecutionQuery().activityId("receive").list();
for (Execution execution : executions) {
runtimeService.signal(execution.getId());
}
runtimeService.signal(runtimeService.createExecutionQuery().activityId("afterSuccess").singleResult().getId());
assertEquals(0, createEventSubscriptionQuery().count());
assertProcessEnded(processInstance.getId());
}
use of org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity 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);
}
Aggregations