Search in sources :

Example 6 with ExecutionEntityImpl

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);
}
Also used : ExecutionEntityImpl(org.activiti.engine.impl.persistence.entity.ExecutionEntityImpl) TaskEntityImpl(org.activiti.engine.impl.persistence.entity.TaskEntityImpl) Test(org.junit.Test)

Example 7 with ExecutionEntityImpl

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");
}
Also used : ProcessInstanceQuery(org.activiti.engine.runtime.ProcessInstanceQuery) ProcessInstanceImpl(org.activiti.api.runtime.model.impl.ProcessInstanceImpl) ExecutionEntityImpl(org.activiti.engine.impl.persistence.entity.ExecutionEntityImpl) StartProcessPayload(org.activiti.api.process.model.payloads.StartProcessPayload) ProcessInstance(org.activiti.api.process.model.ProcessInstance) Test(org.junit.jupiter.api.Test)

Example 8 with ExecutionEntityImpl

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();
}
Also used : ExecutionEntityImpl(org.activiti.engine.impl.persistence.entity.ExecutionEntityImpl) Test(org.junit.Test)

Example 9 with ExecutionEntityImpl

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();
}
Also used : ActivitiEntityEventImpl(org.activiti.engine.delegate.event.impl.ActivitiEntityEventImpl) Task(org.activiti.engine.task.Task) ExecutionEntityImpl(org.activiti.engine.impl.persistence.entity.ExecutionEntityImpl)

Aggregations

ExecutionEntityImpl (org.activiti.engine.impl.persistence.entity.ExecutionEntityImpl)9 Test (org.junit.Test)6 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)2 ProcessInstance (org.activiti.api.process.model.ProcessInstance)1 StartProcessPayload (org.activiti.api.process.model.payloads.StartProcessPayload)1 ProcessInstanceImpl (org.activiti.api.runtime.model.impl.ProcessInstanceImpl)1 ActivitiEntityEventImpl (org.activiti.engine.delegate.event.impl.ActivitiEntityEventImpl)1 TaskEntityImpl (org.activiti.engine.impl.persistence.entity.TaskEntityImpl)1 ProcessInstanceQuery (org.activiti.engine.runtime.ProcessInstanceQuery)1 Task (org.activiti.engine.task.Task)1 Test (org.junit.jupiter.api.Test)1