@Test public void testApply() { MessageBuilder<CloudRuntimeEvent<?,?>> request = MessageBuilder.withPayload(new IgnoredRuntimeEvent()); subject.apply(request); Message<CloudRuntimeEvent<?,?>> message = request.build(); assertThat(message.getHeaders()) .containsEntry(ExecutionContextMessageHeaders.BUSINESS_KEY, MOCK_BUSINESS_KEY) .containsEntry(ExecutionContextMessageHeaders.PROCESS_INSTANCE_ID, MOCK_PROCESS_INSTANCE_ID) .containsEntry(ExecutionContextMessageHeaders.PROCESS_DEFINITION_ID, MOCK_PROCESS_DEFINITION_ID) .containsEntry(ExecutionContextMessageHeaders.PROCESS_DEFINITION_KEY, MOCK_PROCESS_DEFINITION_KEY) .containsEntry(ExecutionContextMessageHeaders.PARENT_PROCESS_INSTANCE_ID, MOCK_PARENT_PROCESS_INSTANCE_ID) .containsEntry(ExecutionContextMessageHeaders.PROCESS_DEFINITION_VERSION, MOCK_PROCESS_DEFINITION_VERSION) .containsEntry(ExecutionContextMessageHeaders.PROCESS_NAME, MOCK_PROCESS_NAME) .containsEntry(ExecutionContextMessageHeaders.PARENT_PROCESS_INSTANCE_NAME, MOCK_PARENT_PROCESS_NAME) .containsEntry(ExecutionContextMessageHeaders.PROCESS_DEFINITION_NAME, MOCK_PROCESS_DEFINITION_NAME) .containsEntry(ExecutionContextMessageHeaders.DEPLOYMENT_ID, MOCK_DEPLOYMENT_ID) .containsEntry(ExecutionContextMessageHeaders.DEPLOYMENT_NAME, MOCK_DEPLOYMENT_NAME) .containsEntry(ExecutionContextMessageHeaders.APP_VERSION, MOCK_APP_VERSION); }
@Override public <P> MessageBuilder<P> apply(MessageBuilder<P> request) { Assert.notNull(request, "request must not be null"); if(executionContext != null) { ExecutionEntity processInstance = executionContext.getProcessInstance(); ProcessDefinition processDefinition = executionContext.getProcessDefinition(); DeploymentEntity deploymentEntity = executionContext.getDeployment(); if(processInstance != null) { request.setHeader(ExecutionContextMessageHeaders.BUSINESS_KEY, processInstance.getBusinessKey()) .setHeader(ExecutionContextMessageHeaders.PROCESS_INSTANCE_ID, processInstance.getId()) .setHeader(ExecutionContextMessageHeaders.PROCESS_NAME, processInstance.getName()); applyParent(processInstance, request); } if(processDefinition != null) { request.setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_ID, processDefinition.getId()) .setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_KEY, processDefinition.getKey()) .setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_VERSION, processDefinition.getVersion()) .setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_NAME, processDefinition.getName()); } if(deploymentEntity != null) { request.setHeader(ExecutionContextMessageHeaders.DEPLOYMENT_ID, deploymentEntity.getId()) .setHeader(ExecutionContextMessageHeaders.DEPLOYMENT_NAME, deploymentEntity.getName()) .setHeader(ExecutionContextMessageHeaders.APP_VERSION, deploymentEntity.getVersion()); } } return request; }
ExecutionContextMessageBuilderAppender implements MessageBuilderAppender { @Override public <P> MessageBuilder<P> apply(MessageBuilder<P> request) { Assert.notNull(request, "request must not be null"); if(executionContext != null) { ExecutionEntity processInstance = executionContext.getProcessInstance(); ProcessDefinition processDefinition = executionContext.getProcessDefinition(); DeploymentEntity deploymentEntity = executionContext.getDeployment(); if(processInstance != null) { request.setHeader(ExecutionContextMessageHeaders.BUSINESS_KEY, processInstance.getBusinessKey()) .setHeader(ExecutionContextMessageHeaders.PROCESS_INSTANCE_ID, processInstance.getId()) .setHeader(ExecutionContextMessageHeaders.PROCESS_NAME, processInstance.getName()); applyParent(processInstance, request); } if(processDefinition != null) { request.setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_ID, processDefinition.getId()) .setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_KEY, processDefinition.getKey()) .setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_VERSION, processDefinition.getVersion()) .setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_NAME, processDefinition.getName()); } if(deploymentEntity != null) { request.setHeader(ExecutionContextMessageHeaders.DEPLOYMENT_ID, deploymentEntity.getId()) .setHeader(ExecutionContextMessageHeaders.DEPLOYMENT_NAME, deploymentEntity.getName()) .setHeader(ExecutionContextMessageHeaders.APP_VERSION, deploymentEntity.getVersion()); } } return request; } }
ExecutionContextMessageBuilderAppender implements MessageBuilderAppender { @Override public <P> MessageBuilder<P> apply(MessageBuilder<P> request) { Assert.notNull(request, "request must not be null"); if(executionContext != null) { ExecutionEntity processInstance = executionContext.getProcessInstance(); ProcessDefinition processDefinition = executionContext.getProcessDefinition(); DeploymentEntity deploymentEntity = executionContext.getDeployment(); if(processInstance != null) { request.setHeader(ExecutionContextMessageHeaders.BUSINESS_KEY, processInstance.getBusinessKey()) .setHeader(ExecutionContextMessageHeaders.PROCESS_INSTANCE_ID, processInstance.getId()) .setHeader(ExecutionContextMessageHeaders.PROCESS_NAME, processInstance.getName()); applyParent(processInstance, request); } if(processDefinition != null) { request.setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_ID, processDefinition.getId()) .setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_KEY, processDefinition.getKey()) .setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_VERSION, processDefinition.getVersion()) .setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_NAME, processDefinition.getName()); } if(deploymentEntity != null) { request.setHeader(ExecutionContextMessageHeaders.DEPLOYMENT_ID, deploymentEntity.getId()) .setHeader(ExecutionContextMessageHeaders.DEPLOYMENT_NAME, deploymentEntity.getName()) .setHeader(ExecutionContextMessageHeaders.APP_VERSION, deploymentEntity.getVersion()); } } return request; } ExecutionContextMessageBuilderAppender(@Nullable ExecutionContext executionContext); }
ExecutionContextMessageBuilderAppender implements MessageBuilderAppender { @Override public <P> MessageBuilder<P> apply(MessageBuilder<P> request) { Assert.notNull(request, "request must not be null"); if(executionContext != null) { ExecutionEntity processInstance = executionContext.getProcessInstance(); ProcessDefinition processDefinition = executionContext.getProcessDefinition(); DeploymentEntity deploymentEntity = executionContext.getDeployment(); if(processInstance != null) { request.setHeader(ExecutionContextMessageHeaders.BUSINESS_KEY, processInstance.getBusinessKey()) .setHeader(ExecutionContextMessageHeaders.PROCESS_INSTANCE_ID, processInstance.getId()) .setHeader(ExecutionContextMessageHeaders.PROCESS_NAME, processInstance.getName()); applyParent(processInstance, request); } if(processDefinition != null) { request.setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_ID, processDefinition.getId()) .setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_KEY, processDefinition.getKey()) .setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_VERSION, processDefinition.getVersion()) .setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_NAME, processDefinition.getName()); } if(deploymentEntity != null) { request.setHeader(ExecutionContextMessageHeaders.DEPLOYMENT_ID, deploymentEntity.getId()) .setHeader(ExecutionContextMessageHeaders.DEPLOYMENT_NAME, deploymentEntity.getName()) .setHeader(ExecutionContextMessageHeaders.APP_VERSION, deploymentEntity.getVersion()); } } return request; } ExecutionContextMessageBuilderAppender(@Nullable ExecutionContext executionContext); @Override MessageBuilder<P> apply(MessageBuilder<P> request); }
ExecutionContextMessageBuilderAppender implements MessageBuilderAppender { @Override public <P> MessageBuilder<P> apply(MessageBuilder<P> request) { Assert.notNull(request, "request must not be null"); if(executionContext != null) { ExecutionEntity processInstance = executionContext.getProcessInstance(); ProcessDefinition processDefinition = executionContext.getProcessDefinition(); DeploymentEntity deploymentEntity = executionContext.getDeployment(); if(processInstance != null) { request.setHeader(ExecutionContextMessageHeaders.BUSINESS_KEY, processInstance.getBusinessKey()) .setHeader(ExecutionContextMessageHeaders.PROCESS_INSTANCE_ID, processInstance.getId()) .setHeader(ExecutionContextMessageHeaders.PROCESS_NAME, processInstance.getName()); applyParent(processInstance, request); } if(processDefinition != null) { request.setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_ID, processDefinition.getId()) .setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_KEY, processDefinition.getKey()) .setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_VERSION, processDefinition.getVersion()) .setHeader(ExecutionContextMessageHeaders.PROCESS_DEFINITION_NAME, processDefinition.getName()); } if(deploymentEntity != null) { request.setHeader(ExecutionContextMessageHeaders.DEPLOYMENT_ID, deploymentEntity.getId()) .setHeader(ExecutionContextMessageHeaders.DEPLOYMENT_NAME, deploymentEntity.getName()) .setHeader(ExecutionContextMessageHeaders.APP_VERSION, deploymentEntity.getVersion()); } } return request; } ExecutionContextMessageBuilderAppender(@Nullable ExecutionContext executionContext); @Override MessageBuilder<P> apply(MessageBuilder<P> request);  }