use of org.activiti.api.runtime.model.impl.IntegrationContextImpl in project Activiti by Activiti.
the class IntegrationContextBuilder method buildFromExecution.
private IntegrationContextImpl buildFromExecution(DelegateExecution execution) {
IntegrationContextImpl integrationContext = new IntegrationContextImpl();
integrationContext.setProcessInstanceId(execution.getProcessInstanceId());
integrationContext.setProcessDefinitionId(execution.getProcessDefinitionId());
integrationContext.setBusinessKey(execution.getProcessInstanceBusinessKey());
integrationContext.setClientId(execution.getCurrentActivityId());
integrationContext.setExecutionId(execution.getId());
if (ExecutionEntity.class.isInstance(execution)) {
ExecutionContext executionContext = new ExecutionContext(ExecutionEntity.class.cast(execution));
ExecutionEntity processInstance = executionContext.getProcessInstance();
if (processInstance != null) {
integrationContext.setParentProcessInstanceId(processInstance.getParentProcessInstanceId());
integrationContext.setAppVersion(Objects.toString(processInstance.getAppVersion(), "1"));
}
// Let's try to resolve process definition attributes
ProcessDefinition processDefinition = executionContext.getProcessDefinition();
if (processDefinition != null) {
integrationContext.setProcessDefinitionKey(processDefinition.getKey());
integrationContext.setProcessDefinitionVersion(processDefinition.getVersion());
}
}
ServiceTask serviceTask = (ServiceTask) execution.getCurrentFlowElement();
if (serviceTask != null) {
integrationContext.setConnectorType(serviceTask.getImplementation());
integrationContext.setClientName(serviceTask.getName());
integrationContext.setClientType(ServiceTask.class.getSimpleName());
}
integrationContext.setInBoundVariables(inboundVariablesProvider.calculateInputVariables(execution));
return integrationContext;
}
use of org.activiti.api.runtime.model.impl.IntegrationContextImpl in project activiti-cloud by Activiti.
the class IntegrationResultChannelResolverImplTest method shouldResolveDestination.
@Test
public void shouldResolveDestination() {
// given
IntegrationContextImpl integrationContext = new IntegrationContextImpl();
IntegrationRequestImpl integrationRequest = new IntegrationRequestImpl(integrationContext);
integrationRequest.setServiceFullName("myApp");
integrationRequest.setAppName("myAppName");
integrationRequest.setAppVersion("1.0");
integrationRequest.setServiceType("RUNTIME_BUNDLE");
integrationRequest.setServiceVersion("1.0");
// when
MessageChannel resut = subject.resolveDestination(integrationRequest);
// then
assertThat(resut).isEqualTo(messageChannel);
verify(builder).buildDestination(integrationRequest);
}
use of org.activiti.api.runtime.model.impl.IntegrationContextImpl in project activiti-cloud by Activiti.
the class IntegrationErrorBuilderTest method shouldBuildIntegrationErrorBasedOnInformationFromIntegrationRequest.
@Test
public void shouldBuildIntegrationErrorBasedOnInformationFromIntegrationRequest() throws Exception {
// given
Throwable error = new Error("Boom!");
IntegrationContextImpl integrationContext = new IntegrationContextImpl();
integrationContext.setClientId(ACTIVITY_ELEMENT_ID);
integrationContext.setInBoundVariables(Collections.emptyMap());
integrationContext.setProcessDefinitionId(PROC_DEF_ID);
integrationContext.setProcessInstanceId(PROC_INST_ID);
IntegrationRequestImpl integrationRequestEvent = new IntegrationRequestImpl(integrationContext);
integrationRequestEvent.setAppName(RB_NAME);
// when
IntegrationError integrationError = IntegrationErrorBuilder.errorFor(integrationRequestEvent, connectorProperties, error).build();
// then
assertThat(integrationError).hasIntegrationContext(integrationContext).hasIntegrationRequest(integrationRequestEvent).hasErrorClassName("java.lang.Error").hasErrorMessage("Boom!").hasStackTraceElements(error.getStackTrace());
assertThat(integrationContext).hasClientId(ACTIVITY_ELEMENT_ID);
}
use of org.activiti.api.runtime.model.impl.IntegrationContextImpl in project activiti-cloud by Activiti.
the class ActivitiCloudConnectorServiceIT method integrationEventShouldBePickedByConnectorMock.
@Test
public void integrationEventShouldBePickedByConnectorMock() throws Exception {
// given
Map<String, Object> variables = new HashMap<>();
variables.put("var1", "value1");
variables.put("var2", 1L);
IntegrationContextImpl integrationContext = new IntegrationContextImpl();
integrationContext.setId(INTEGRATION_ID);
integrationContext.setProcessInstanceId(PROCESS_INSTANCE_ID);
integrationContext.setProcessDefinitionId(PROCESS_DEFINITION_ID);
integrationContext.setInBoundVariables(variables);
IntegrationRequestImpl integrationRequest = new IntegrationRequestImpl(integrationContext);
integrationRequest.setAppName("mock-rb");
integrationRequest.setServiceFullName("mock-rb");
integrationRequest.setServiceType("runtime-bundle");
integrationRequest.setServiceVersion("1");
integrationRequest.setAppVersion("1");
Message<IntegrationRequest> message = MessageBuilder.<IntegrationRequest>withPayload(integrationRequest).setHeader("type", "Mock").build();
integrationEventsProducer.send(message);
message = MessageBuilder.<IntegrationRequest>withPayload(integrationRequest).setHeader("type", "MockProcessRuntime").build();
integrationEventsProducer.send(message);
await("Should receive at least 2 integration results").untilAsserted(() -> assertThat(streamHandler.getIntegrationResultEventsCounter().get()).isGreaterThanOrEqualTo(1));
}
use of org.activiti.api.runtime.model.impl.IntegrationContextImpl in project activiti-cloud by Activiti.
the class ActivitiCloudConnectorServiceIT method mockIntegrationRequest.
private IntegrationRequest mockIntegrationRequest() {
IntegrationContextImpl integrationContext = new IntegrationContextImpl();
integrationContext.setId(INTEGRATION_ID);
integrationContext.setProcessInstanceId(PROCESS_INSTANCE_ID);
integrationContext.setProcessDefinitionId(PROCESS_DEFINITION_ID);
IntegrationRequestImpl integrationRequest = new IntegrationRequestImpl(integrationContext);
integrationRequest.setAppName("mock-rb");
integrationRequest.setServiceFullName("mock-rb");
integrationRequest.setServiceType("runtime-bundle");
integrationRequest.setServiceVersion("1");
integrationRequest.setAppVersion("1");
return integrationRequest;
}
Aggregations