use of org.activiti.engine.impl.persistence.entity.ExecutionEntityImpl in project Activiti by Activiti.
the class ExecutionElResolverTest method resolve_should_returnVariableScopeExecutionWhenItsTaskEntity.
@Test
public void resolve_should_returnVariableScopeExecutionWhenItsTaskEntity() {
// given
ExecutionEntityImpl execution = new ExecutionEntityImpl();
TaskEntityImpl variableScope = new TaskEntityImpl();
variableScope.setExecution(execution);
// when
Object result = resolver.resolve(EXECUTION_KEY, variableScope);
// then
assertThat(result).isEqualTo(execution);
}
use of org.activiti.engine.impl.persistence.entity.ExecutionEntityImpl in project Activiti by Activiti.
the class ProcessRuntimeImplTest method should_startAnAlreadyCreatedProcessInstance_whenCalled.
@Test
public void should_startAnAlreadyCreatedProcessInstance_whenCalled() {
// given
String processInstanceId = "process-instance-id";
ProcessInstanceQuery processQuery = mock(ProcessInstanceQuery.class);
doReturn(processQuery).when(processQuery).processInstanceId(processInstanceId);
doReturn(processQuery).when(runtimeService).createProcessInstanceQuery();
org.activiti.engine.runtime.ProcessInstance internalProcess = new ExecutionEntityImpl();
internalProcess.setAppVersion(1);
doReturn(internalProcess).when(processQuery).singleResult();
when(runtimeService.startCreatedProcessInstance(internalProcess, new HashMap<>())).thenReturn(internalProcess);
ProcessInstanceImpl apiProcessInstance = new ProcessInstanceImpl();
apiProcessInstance.setBusinessKey("business-result");
apiProcessInstance.setId("999-999");
given(processInstanceConverter.from(internalProcess)).willReturn(apiProcessInstance);
given(securityPoliciesManager.canRead(any())).willReturn(true);
// when
StartProcessPayload payload = new StartProcessPayload();
ProcessInstance createdProcessInstance = processRuntime.startCreatedProcess(processInstanceId, payload);
// then
assertThat(createdProcessInstance.getId()).isEqualTo("999-999");
assertThat(createdProcessInstance.getBusinessKey()).isEqualTo("business-result");
}
use of org.activiti.engine.impl.persistence.entity.ExecutionEntityImpl in project Activiti by Activiti.
the class ProcessInitiatorELResolverTest method canResolve_should_returnFalseWhenItsExecutionEntityAndPropertyIsNotInitiator.
@Test
public void canResolve_should_returnFalseWhenItsExecutionEntityAndPropertyIsNotInitiator() {
// when
boolean canResolve = resolver.canResolve("anyOtherProperty", new ExecutionEntityImpl());
// then
assertThat(canResolve).isFalse();
}
use of org.activiti.engine.impl.persistence.entity.ExecutionEntityImpl in project Activiti by Activiti.
the class ActivitiEventDispatcherTest method baseEntityEventListener.
/**
* Test the {@link BaseEntityEventListener} shipped with Activiti.
*/
public void baseEntityEventListener() throws Exception {
TestBaseEntityEventListener listener = new TestBaseEntityEventListener();
dispatcher.addEventListener(listener);
ActivitiEntityEventImpl createEvent = new ActivitiEntityEventImpl(processEngineConfiguration.getTaskEntityManager().create(), ActivitiEventType.ENTITY_CREATED);
ActivitiEntityEventImpl deleteEvent = new ActivitiEntityEventImpl(processEngineConfiguration.getTaskEntityManager().create(), ActivitiEventType.ENTITY_DELETED);
ActivitiEntityEventImpl updateEvent = new ActivitiEntityEventImpl(processEngineConfiguration.getTaskEntityManager().create(), ActivitiEventType.ENTITY_UPDATED);
ActivitiEntityEventImpl otherEvent = new ActivitiEntityEventImpl(processEngineConfiguration.getTaskEntityManager().create(), ActivitiEventType.CUSTOM);
// Dispatch create event
dispatcher.dispatchEvent(createEvent);
assertThat(listener.isCreateReceived()).isTrue();
assertThat(listener.isUpdateReceived()).isFalse();
assertThat(listener.isCustomReceived()).isFalse();
assertThat(listener.isInitializeReceived()).isFalse();
assertThat(listener.isDeleteReceived()).isFalse();
listener.reset();
// Dispatch update event
dispatcher.dispatchEvent(updateEvent);
assertThat(listener.isUpdateReceived()).isTrue();
assertThat(listener.isCreateReceived()).isFalse();
assertThat(listener.isCustomReceived()).isFalse();
assertThat(listener.isDeleteReceived()).isFalse();
listener.reset();
// Dispatch delete event
dispatcher.dispatchEvent(deleteEvent);
assertThat(listener.isDeleteReceived()).isTrue();
assertThat(listener.isCreateReceived()).isFalse();
assertThat(listener.isCustomReceived()).isFalse();
assertThat(listener.isUpdateReceived()).isFalse();
listener.reset();
// Dispatch other event
dispatcher.dispatchEvent(otherEvent);
assertThat(listener.isCustomReceived()).isTrue();
assertThat(listener.isCreateReceived()).isFalse();
assertThat(listener.isUpdateReceived()).isFalse();
assertThat(listener.isDeleteReceived()).isFalse();
listener.reset();
// Test typed entity-listener
listener = new TestBaseEntityEventListener(Task.class);
// Dispatch event for a task, should be received
dispatcher.addEventListener(listener);
dispatcher.dispatchEvent(createEvent);
assertThat(listener.isCreateReceived()).isTrue();
listener.reset();
// Dispatch event for a execution, should NOT be received
ActivitiEntityEventImpl createEventForExecution = new ActivitiEntityEventImpl(new ExecutionEntityImpl(), ActivitiEventType.ENTITY_CREATED);
dispatcher.dispatchEvent(createEventForExecution);
assertThat(listener.isCreateReceived()).isFalse();
}
Aggregations