@Test public void calculateOutputVariablesShouldNotPassAnyVariablesWhenTheMappingIsEmpty() throws Exception { ObjectMapper objectMapper = new ObjectMapper(); ProcessExtensionModel extensions = objectMapper.readValue(new File("src/test/resources/task-variable-empty-mapping-extensions.json"), ProcessExtensionModel.class); DelegateExecution execution = buildExecution(extensions.getExtensions("Process_taskVariableEmptyMapping")); Map<String, Object> taskVariables = map( "task_output_variable_name_1", "var-one", "non-mapped-output_variable_name_2", "var-two" ); Map<String, Object> outputVariables = variablesMappingProvider.calculateOutPutVariables(buildMappingExecutionContext(execution), taskVariables); assertThat(outputVariables).isEmpty(); }
public Map<String, Object> calculateOutPutVariables(MappingExecutionContext mappingExecutionContext, Map<String, Object> availableVariables) { Extension extensions = processExtensionService.getExtensionsForId(mappingExecutionContext.getProcessDefinitionId()); if (!extensions.hasMapping(mappingExecutionContext.getActivityId())) { return emptyMap(); } if (extensions.shouldMapAllOutputs(mappingExecutionContext.getActivityId())) { return (availableVariables != null ? new HashMap<>(availableVariables) : emptyMap()); } if (availableVariables != null && !availableVariables.isEmpty()) { if (expressionResolver.containsExpression(availableVariables)) { throw new ActivitiIllegalArgumentException("Expressions are not allowed as variable values in the output mapping"); } return calculateOutPutVariables(mappingExecutionContext, extensions, availableVariables); } else { return emptyMap(); } }
ExtensionsVariablesMappingProvider implements VariablesCalculator { public Map<String, Object> calculateOutPutVariables(MappingExecutionContext mappingExecutionContext, Map<String, Object> availableVariables) { Extension extensions = processExtensionService.getExtensionsForId(mappingExecutionContext.getProcessDefinitionId()); if (!extensions.hasMapping(mappingExecutionContext.getActivityId())) { return emptyMap(); } if (extensions.shouldMapAllOutputs(mappingExecutionContext.getActivityId())) { return (availableVariables != null ? new HashMap<>(availableVariables) : emptyMap()); } if (availableVariables != null && !availableVariables.isEmpty()) { if (expressionResolver.containsExpression(availableVariables)) { throw new ActivitiIllegalArgumentException("Expressions are not allowed as variable values in the output mapping"); } return calculateOutPutVariables(mappingExecutionContext, extensions, availableVariables); } else { return emptyMap(); } } }
ExtensionsVariablesMappingProvider implements VariablesCalculator { public Map<String, Object> calculateOutPutVariables(MappingExecutionContext mappingExecutionContext, Map<String, Object> availableVariables) { Extension extensions = processExtensionService.getExtensionsForId(mappingExecutionContext.getProcessDefinitionId()); if (!extensions.hasMapping(mappingExecutionContext.getActivityId())) { return emptyMap(); } if (extensions.shouldMapAllOutputs(mappingExecutionContext.getActivityId())) { return (availableVariables != null ? new HashMap<>(availableVariables) : emptyMap()); } if (availableVariables != null && !availableVariables.isEmpty()) { if (expressionResolver.containsExpression(availableVariables)) { throw new ActivitiIllegalArgumentException("Expressions are not allowed as variable values in the output mapping"); } return calculateOutPutVariables(mappingExecutionContext, extensions, availableVariables); } else { return emptyMap(); } } ExtensionsVariablesMappingProvider(ProcessExtensionService processExtensionService,
                                    ExpressionResolver expressionResolver); }
ExtensionsVariablesMappingProvider implements VariablesCalculator { public Map<String, Object> calculateOutPutVariables(MappingExecutionContext mappingExecutionContext, Map<String, Object> availableVariables) { Extension extensions = processExtensionService.getExtensionsForId(mappingExecutionContext.getProcessDefinitionId()); if (!extensions.hasMapping(mappingExecutionContext.getActivityId())) { return emptyMap(); } if (extensions.shouldMapAllOutputs(mappingExecutionContext.getActivityId())) { return (availableVariables != null ? new HashMap<>(availableVariables) : emptyMap()); } if (availableVariables != null && !availableVariables.isEmpty()) { if (expressionResolver.containsExpression(availableVariables)) { throw new ActivitiIllegalArgumentException("Expressions are not allowed as variable values in the output mapping"); } return calculateOutPutVariables(mappingExecutionContext, extensions, availableVariables); } else { return emptyMap(); } } ExtensionsVariablesMappingProvider(ProcessExtensionService processExtensionService,
                                    ExpressionResolver expressionResolver); Map<String, Object> calculateInputVariables(DelegateExecution execution); Map<String, Object> calculateOutPutVariables(MappingExecutionContext mappingExecutionContext,
                                                        Map<String, Object> availableVariables); }
ExtensionsVariablesMappingProvider implements VariablesCalculator { public Map<String, Object> calculateOutPutVariables(MappingExecutionContext mappingExecutionContext, Map<String, Object> availableVariables) { Extension extensions = processExtensionService.getExtensionsForId(mappingExecutionContext.getProcessDefinitionId()); if (!extensions.hasMapping(mappingExecutionContext.getActivityId())) { return emptyMap(); } if (extensions.shouldMapAllOutputs(mappingExecutionContext.getActivityId())) { return (availableVariables != null ? new HashMap<>(availableVariables) : emptyMap()); } if (availableVariables != null && !availableVariables.isEmpty()) { if (expressionResolver.containsExpression(availableVariables)) { throw new ActivitiIllegalArgumentException("Expressions are not allowed as variable values in the output mapping"); } return calculateOutPutVariables(mappingExecutionContext, extensions, availableVariables); } else { return emptyMap(); } } ExtensionsVariablesMappingProvider(ProcessExtensionService processExtensionService,
                                    ExpressionResolver expressionResolver); Map<String, Object> calculateInputVariables(DelegateExecution execution); Map<String, Object> calculateOutPutVariables(MappingExecutionContext mappingExecutionContext,
                                                        Map<String, Object> availableVariables);  }