use of org.activiti.engine.impl.persistence.entity.integration.IntegrationContextEntityImpl in project Activiti by Activiti.
the class IntegrationContextBuilderTest method shouldSetIdWhenIntegrationContextEntityIsProvided.
@Test
public void shouldSetIdWhenIntegrationContextEntityIsProvided() {
// given
ExecutionEntity execution = mock(ExecutionEntity.class);
ExecutionEntity processInstance = mock(ExecutionEntity.class);
ServiceTask serviceTask = mock(ServiceTask.class);
Map<String, Object> variables = singletonMap("key", "value");
given(inboundVariablesProvider.calculateInputVariables(execution)).willReturn(variables);
given(serviceTask.getImplementation()).willReturn(IMPLEMENTATION);
given(serviceTask.getName()).willReturn(SERVICE_TASK_NAME);
given(execution.getVariables()).willReturn(variables);
given(execution.getCurrentActivityId()).willReturn(CURRENT_ACTIVITY_ID);
given(execution.getCurrentFlowElement()).willReturn(serviceTask);
given(execution.getProcessInstanceId()).willReturn(PROCESS_INSTANCE_ID);
given(execution.getProcessDefinitionId()).willReturn(PROCESS_DEFINITION_ID);
given(execution.getCurrentActivityId()).willReturn(CURRENT_ACTIVITY_ID);
given(execution.getProcessInstanceBusinessKey()).willReturn(PROCESS_INSTANCE_BUSINESS_KEY);
given(execution.getProcessInstance()).willReturn(processInstance);
given(processInstance.getParentProcessInstanceId()).willReturn(PARENT_PROCESS_INSTANCE_ID);
IntegrationContextEntityImpl integrationContextEntity = new IntegrationContextEntityImpl();
integrationContextEntity.setId("entityId");
// when
IntegrationContext integrationContext = builder.from(integrationContextEntity, execution);
// then
assertThat(integrationContext).isNotNull();
assertThat(integrationContext.getId()).isEqualTo("entityId");
assertThat(integrationContext.getConnectorType()).isEqualTo(IMPLEMENTATION);
assertThat(integrationContext.getClientId()).isEqualTo(CURRENT_ACTIVITY_ID);
assertThat(integrationContext.getClientName()).isEqualTo(SERVICE_TASK_NAME);
assertThat(integrationContext.getClientType()).isEqualTo(ServiceTask.class.getSimpleName());
assertThat(integrationContext.getBusinessKey()).isEqualTo(PROCESS_INSTANCE_BUSINESS_KEY);
assertThat(integrationContext.getProcessDefinitionId()).isEqualTo(PROCESS_DEFINITION_ID);
assertThat(integrationContext.getProcessInstanceId()).isEqualTo(PROCESS_INSTANCE_ID);
assertThat(integrationContext.getProcessDefinitionKey()).isEqualTo(PROCESS_DEFINITION_KEY);
assertThat(integrationContext.getProcessDefinitionVersion()).isEqualTo(PROCESS_DEFINITION_VERSION);
assertThat(integrationContext.getParentProcessInstanceId()).isEqualTo(PARENT_PROCESS_INSTANCE_ID);
assertThat(integrationContext.getInBoundVariables()).containsAllEntriesOf(variables);
}
Aggregations