提交 c9469fc2 编写于 作者: J Joram Barrez

Fixing various tests with simple fixes. Leaving the hard ones for Tijs.

上级 d7a57ff4
......@@ -85,11 +85,11 @@ public class AbstractBpmnActivityBehavior extends FlowNodeActivityBehavior {
}
@Override
public void trigger(ActivityExecution execution, String signalName, Object signalData) {
if ("compensationDone".equals(signalName)) {
signalCompensationDone(execution, signalData);
public void trigger(ActivityExecution execution, String triggerName, Object triggerData) {
if ("compensationDone".equals(triggerName)) {
signalCompensationDone(execution, triggerData);
} else {
super.trigger(execution, signalName, signalData);
super.trigger(execution, triggerName, triggerData);
}
}
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.behavior;
import org.activiti.bpmn.model.BoundaryEvent;
import org.activiti.bpmn.model.TimerEventDefinition;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.jobexecutor.TriggerTimerEventJobHandler;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.persistence.entity.TimerEntity;
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
import org.activiti.engine.impl.util.TimerUtil;
public class IntermediateTimerCatchEventActivityBehavior extends AbstractBpmnActivityBehavior {
protected TimerEventDefinition timerEventDefinition;
public IntermediateTimerCatchEventActivityBehavior(TimerEventDefinition timerEventDefinition) {
this.timerEventDefinition = timerEventDefinition;
}
public void execute(ActivityExecution execution) {
TimerEntity timer = TimerUtil.createTimerEntityForTimerEventDefinition(timerEventDefinition,
false, (ExecutionEntity) execution, TriggerTimerEventJobHandler.TYPE, execution.getCurrentActivityId());
Context.getCommandContext().getJobEntityManager().schedule(timer);
}
@Override
public void trigger(ActivityExecution execution, String triggerName, Object triggerData) {
leave(execution);
}
}
......@@ -53,6 +53,7 @@ import org.activiti.engine.impl.bpmn.behavior.IntermediateCatchEventActivityBeha
import org.activiti.engine.impl.bpmn.behavior.IntermediateThrowCompensationEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.IntermediateThrowNoneEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.IntermediateThrowSignalEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.IntermediateTimerCatchEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.ManualTaskActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior;
......@@ -175,6 +176,8 @@ public interface ActivityBehaviorFactory {
public abstract IntermediateCatchEventActivityBehavior createIntermediateCatchEventActivityBehavior(IntermediateCatchEvent intermediateCatchEvent);
public abstract IntermediateTimerCatchEventActivityBehavior createIntermediateTimerCatchEventActivityBehavior(IntermediateCatchEvent intermediateCatchEvent, TimerEventDefinition timerEventDefinition);
public abstract IntermediateThrowNoneEventActivityBehavior createIntermediateThrowNoneEventActivityBehavior(ThrowEvent throwEvent);
public abstract IntermediateThrowSignalEventActivityBehavior createIntermediateThrowSignalEventActivityBehavior(ThrowEvent throwEvent, Signal signal,
......@@ -182,6 +185,7 @@ public interface ActivityBehaviorFactory {
public abstract IntermediateThrowCompensationEventActivityBehavior createIntermediateThrowCompensationEventActivityBehavior(ThrowEvent throwEvent,
CompensateEventDefinition compensateEventDefinition);
public abstract NoneEndEventActivityBehavior createNoneEndEventActivityBehavior(EndEvent endEvent);
......
......@@ -60,6 +60,7 @@ import org.activiti.engine.impl.bpmn.behavior.IntermediateCatchEventActivityBeha
import org.activiti.engine.impl.bpmn.behavior.IntermediateThrowCompensationEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.IntermediateThrowNoneEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.IntermediateThrowSignalEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.IntermediateTimerCatchEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.ManualTaskActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior;
......@@ -379,6 +380,11 @@ public class DefaultActivityBehaviorFactory extends AbstractBehaviorFactory impl
public IntermediateCatchEventActivityBehavior createIntermediateCatchEventActivityBehavior(IntermediateCatchEvent intermediateCatchEvent) {
return new IntermediateCatchEventActivityBehavior();
}
@Override
public IntermediateTimerCatchEventActivityBehavior createIntermediateTimerCatchEventActivityBehavior(IntermediateCatchEvent intermediateCatchEvent, TimerEventDefinition timerEventDefinition) {
return new IntermediateTimerCatchEventActivityBehavior(timerEventDefinition);
}
public IntermediateThrowNoneEventActivityBehavior createIntermediateThrowNoneEventActivityBehavior(ThrowEvent throwEvent) {
return new IntermediateThrowNoneEventActivityBehavior();
......
......@@ -12,30 +12,17 @@
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import java.util.ArrayList;
import java.util.List;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.BoundaryEvent;
import org.activiti.bpmn.model.IntermediateCatchEvent;
import org.activiti.bpmn.model.TimerEventDefinition;
import org.activiti.engine.delegate.Expression;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.el.ExpressionManager;
import org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl;
import org.activiti.engine.impl.jobexecutor.TimerDeclarationType;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Joram Barrez
*/
public class TimerEventDefinitionParseHandler extends AbstractBpmnParseHandler<TimerEventDefinition> {
private static final Logger logger = LoggerFactory.getLogger(TimerEventDefinitionParseHandler.class);
public Class<? extends BaseElement> getHandledType() {
return TimerEventDefinition.class;
}
......@@ -44,21 +31,9 @@ public class TimerEventDefinitionParseHandler extends AbstractBpmnParseHandler<T
if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) {
throw new RuntimeException("Need to implement");
// timerActivity.setProperty("type", "intermediateTimer");
// TimerDeclarationImpl timerDeclaration = createTimer(bpmnParse,
// timerEventDefinition, timerActivity,
// TimerCatchIntermediateEventJobHandler.TYPE);
// if (getPrecedingEventBasedGateway(bpmnParse,
// (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement()) !=
// null) {
// addTimerDeclaration(timerActivity.getParent(), timerDeclaration);
// } else {
// addTimerDeclaration(timerActivity, timerDeclaration);
// timerActivity.setScope(true);
// }
IntermediateCatchEvent intermediateCatchEvent = (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement();
intermediateCatchEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateTimerCatchEventActivityBehavior(intermediateCatchEvent, timerEventDefinition));
} else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
......@@ -67,44 +42,4 @@ public class TimerEventDefinitionParseHandler extends AbstractBpmnParseHandler<T
}
}
protected TimerDeclarationImpl createTimer(BpmnParse bpmnParse, TimerEventDefinition timerEventDefinition, ScopeImpl timerActivity, String jobHandlerType) {
TimerDeclarationType type = null;
Expression expression = null;
ExpressionManager expressionManager = bpmnParse.getExpressionManager();
if (StringUtils.isNotEmpty(timerEventDefinition.getTimeDate())) {
// TimeDate
type = TimerDeclarationType.DATE;
expression = expressionManager.createExpression(timerEventDefinition.getTimeDate());
} else if (StringUtils.isNotEmpty(timerEventDefinition.getTimeCycle())) {
// TimeCycle
type = TimerDeclarationType.CYCLE;
expression = expressionManager.createExpression(timerEventDefinition.getTimeCycle());
} else if (StringUtils.isNotEmpty(timerEventDefinition.getTimeDuration())) {
// TimeDuration
type = TimerDeclarationType.DURATION;
expression = expressionManager.createExpression(timerEventDefinition.getTimeDuration());
}
// neither date, cycle or duration configured!
if (expression == null) {
logger.warn("Timer needs configuration (either timeDate, timeCycle or timeDuration is needed) (" + timerActivity.getId() + ")");
}
// Parse the timer declaration
// TODO move the timer declaration into the bpmn activity or next to the TimerSession
TimerDeclarationImpl timerDeclaration = new TimerDeclarationImpl(expression, type, jobHandlerType);
timerDeclaration.setJobHandlerConfiguration(timerActivity.getId());
timerDeclaration.setExclusive(true);
return timerDeclaration;
}
@SuppressWarnings("unchecked")
protected void addTimerDeclaration(ScopeImpl scope, TimerDeclarationImpl timerDeclaration) {
List<TimerDeclarationImpl> timerDeclarations = (List<TimerDeclarationImpl>) scope.getProperty(PROPERTYNAME_TIMER_DECLARATION);
if (timerDeclarations == null) {
timerDeclarations = new ArrayList<TimerDeclarationImpl>();
scope.setProperty(PROPERTYNAME_TIMER_DECLARATION, timerDeclarations);
}
timerDeclarations.add(timerDeclaration);
}
}
......@@ -176,8 +176,9 @@ public class StartProcessInstanceCmd<T> implements Command<ProcessInstance>, Ser
return processInstance;
}
protected ExecutionEntity createProcessInstance(CommandContext commandContext, ProcessDefinitionEntity processDefinitionEntity, String businessKey, String initiatorVariableName,
FlowElement initialFlowElement) {
protected ExecutionEntity createProcessInstance(CommandContext commandContext,
ProcessDefinitionEntity processDefinitionEntity, String businessKey,
String initiatorVariableName, FlowElement initialFlowElement) {
ExecutionEntity processInstance = new ExecutionEntity();
processInstance.setProcessDefinitionId(processDefinitionEntity.getId());
......
......@@ -33,8 +33,8 @@ public class TimerUtil {
* Takes in an optional execution, if missing the
* {@link NoExecutionVariableScope} will be used (eg Timer start event)
*/
public static TimerEntity createTimerEntityForTimerEventDefinition(TimerEventDefinition timerEventDefinition, boolean isInterruptingTimer, ExecutionEntity executionEntity, String jobHandlerType,
String jobHandlerConfig) {
public static TimerEntity createTimerEntityForTimerEventDefinition(TimerEventDefinition timerEventDefinition,
boolean isInterruptingTimer, ExecutionEntity executionEntity, String jobHandlerType, String jobHandlerConfig) {
String businessCalendarRef = null;
Expression expression = null;
......
......@@ -61,6 +61,7 @@ import org.activiti.engine.impl.bpmn.behavior.IntermediateCatchEventActivityBeha
import org.activiti.engine.impl.bpmn.behavior.IntermediateThrowCompensationEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.IntermediateThrowNoneEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.IntermediateThrowSignalEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.IntermediateTimerCatchEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.ManualTaskActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior;
......@@ -290,6 +291,11 @@ public class TestActivityBehaviorFactory extends AbstractBehaviorFactory impleme
public IntermediateCatchEventActivityBehavior createIntermediateCatchEventActivityBehavior(IntermediateCatchEvent intermediateCatchEvent) {
return wrappedActivityBehaviorFactory.createIntermediateCatchEventActivityBehavior(intermediateCatchEvent);
}
@Override
public IntermediateTimerCatchEventActivityBehavior createIntermediateTimerCatchEventActivityBehavior(IntermediateCatchEvent intermediateCatchEvent, TimerEventDefinition timerEventDefinition) {
return wrappedActivityBehaviorFactory.createIntermediateTimerCatchEventActivityBehavior(intermediateCatchEvent, timerEventDefinition);
}
@Override
public IntermediateThrowNoneEventActivityBehavior createIntermediateThrowNoneEventActivityBehavior(ThrowEvent throwEvent) {
......
......@@ -352,7 +352,7 @@
inner join ${prefix}ACT_RU_VARIABLE A${index} on RES.ID_ = A${index}.EXECUTION_ID_
</when>
<otherwise>
inner join ${prefix}ACT_RU_VARIABLE A${index} on RES.PROC_INST_ID_ = A${index}.PROC_INST_ID_
inner join ${prefix}ACT_RU_VARIABLE A${index} on RES.ID_ = A${index}.PROC_INST_ID_
</otherwise>
</choose>
</foreach>
......
......@@ -88,8 +88,7 @@ public class ActivityEventsTest extends PluggableActivitiTestCase {
*/
@Deployment
public void testActivityEvents() throws Exception {
// We're interested in the raw events, alter the listener to keep those
// as well
// We're interested in the raw events, alter the listener to keep those as well
listener.setIgnoreRawActivityEvents(false);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("activityProcess");
......@@ -590,47 +589,42 @@ public class ActivityEventsTest extends PluggableActivitiTestCase {
/**
* Test events related to message events, called from the API.
*/
// @Deployment
@Deployment
public void testActivityMessageBoundaryEventsOnSubProcess() throws Exception {
// Uncomment the annotation and the lines below.
// This test made 400 other test fail ...
assertEquals(1, 2);
// ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("messageOnSubProcess");
// assertNotNull(processInstance);
//
// Execution executionWithMessage = runtimeService.createExecutionQuery().activityId("cloudformtask1").singleResult();
// assertNotNull(executionWithMessage);
//
// runtimeService.messageEventReceived("message_1", executionWithMessage.getId());
// assertEquals(2, listener.getEventsReceived().size());
//
// // First, a message-event is expected
// assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiMessageEvent);
// ActivitiMessageEvent messageEvent = (ActivitiMessageEvent) listener.getEventsReceived().get(0);
// assertEquals(ActivitiEventType.ACTIVITY_MESSAGE_RECEIVED, messageEvent.getType());
// assertEquals("boundaryMessageEventCatching", messageEvent.getActivityId());
// assertEquals(executionWithMessage.getId(), messageEvent.getExecutionId());
// assertEquals(executionWithMessage.getProcessInstanceId(), messageEvent.getProcessInstanceId());
// assertEquals(processInstance.getProcessDefinitionId(), messageEvent.getProcessDefinitionId());
// assertEquals("message_1", messageEvent.getMessageName());
// assertNull(messageEvent.getMessageData());
//
// // Next, an signal-event is expected, as a result of the message
// assertTrue(listener.getEventsReceived().get(1) instanceof ActivitiActivityCancelledEvent);
// ActivitiActivityCancelledEvent signalEvent = (ActivitiActivityCancelledEvent) listener.getEventsReceived().get(1);
// assertEquals(ActivitiEventType.ACTIVITY_CANCELLED, signalEvent.getType());
// assertEquals("cloudformtask1", signalEvent.getActivityId());
// assertEquals(executionWithMessage.getId(), signalEvent.getExecutionId());
// assertEquals(executionWithMessage.getProcessInstanceId(), signalEvent.getProcessInstanceId());
// assertEquals(processInstance.getProcessDefinitionId(), signalEvent.getProcessDefinitionId());
// assertNotNull(signalEvent.getCause());
// assertTrue(signalEvent.getCause() instanceof MessageEventSubscriptionEntity);
// MessageEventSubscriptionEntity cause = (MessageEventSubscriptionEntity) signalEvent.getCause();
// assertEquals("message_1", cause.getEventName());
//
// assertDatabaseEventPresent(ActivitiEventType.ACTIVITY_MESSAGE_RECEIVED);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("messageOnSubProcess");
assertNotNull(processInstance);
Execution executionWithMessage = runtimeService.createExecutionQuery().activityId("cloudformtask1").singleResult();
assertNotNull(executionWithMessage);
runtimeService.messageEventReceived("message_1", executionWithMessage.getId());
assertEquals(2, listener.getEventsReceived().size());
// First, a message-event is expected
assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiMessageEvent);
ActivitiMessageEvent messageEvent = (ActivitiMessageEvent) listener.getEventsReceived().get(0);
assertEquals(ActivitiEventType.ACTIVITY_MESSAGE_RECEIVED, messageEvent.getType());
assertEquals("boundaryMessageEventCatching", messageEvent.getActivityId());
assertEquals(executionWithMessage.getId(), messageEvent.getExecutionId());
assertEquals(executionWithMessage.getProcessInstanceId(), messageEvent.getProcessInstanceId());
assertEquals(processInstance.getProcessDefinitionId(), messageEvent.getProcessDefinitionId());
assertEquals("message_1", messageEvent.getMessageName());
assertNull(messageEvent.getMessageData());
// Next, an signal-event is expected, as a result of the message
assertTrue(listener.getEventsReceived().get(1) instanceof ActivitiActivityCancelledEvent);
ActivitiActivityCancelledEvent signalEvent = (ActivitiActivityCancelledEvent) listener.getEventsReceived().get(1);
assertEquals(ActivitiEventType.ACTIVITY_CANCELLED, signalEvent.getType());
assertEquals("cloudformtask1", signalEvent.getActivityId());
assertEquals(executionWithMessage.getId(), signalEvent.getExecutionId());
assertEquals(executionWithMessage.getProcessInstanceId(), signalEvent.getProcessInstanceId());
assertEquals(processInstance.getProcessDefinitionId(), signalEvent.getProcessDefinitionId());
assertNotNull(signalEvent.getCause());
assertTrue(signalEvent.getCause() instanceof MessageEventSubscriptionEntity);
MessageEventSubscriptionEntity cause = (MessageEventSubscriptionEntity) signalEvent.getCause();
assertEquals("message_1", cause.getEventName());
assertDatabaseEventPresent(ActivitiEventType.ACTIVITY_MESSAGE_RECEIVED);
}
@Deployment
......
......@@ -61,6 +61,9 @@ public class CustomDeploymentCache implements DeploymentCache<ProcessDefinitionC
// For testing purposes only
public ProcessDefinitionEntity getCachedProcessDefinition() {
if (entry == null) {
return null;
}
return entry.getProcessDefinitionEntity();
}
......
......@@ -16,11 +16,11 @@
<property name="databaseSchemaUpdate" value="drop-create" />
<!-- Test logger -->
<property name="configurators">
<!-- <property name="configurators">
<list>
<bean class="org.activiti.engine.test.impl.logger.ProcessExecutionLoggerConfigurator" />
</list>
</property>
</property> -->
<!-- job executor configurations -->
<property name="jobExecutorActivate" value="false" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册