diff --git a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/bpmn/data/BPMNFormFields.java b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/bpmn/data/BPMNFormFields.java index 345ede5f886d82a3f20f9899b787a3d29775695a..a1c98a6fae0c729554103996132acf4ac598134c 100644 --- a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/bpmn/data/BPMNFormFields.java +++ b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/bpmn/data/BPMNFormFields.java @@ -51,6 +51,7 @@ public class BPMNFormFields { variableFieldMap.put(formField.getCamundaLabel(), variableFields); } + //FYI: Hier vllt. für Contstraints in Zukunft interessant public HashMap<String, List<BPMNFieldConstraint>> getVariableConstraints() { return variableConstraints; } diff --git a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/dto/FlowElementEnhancedDTO.java b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/dto/FlowElementEnhancedDTO.java index 9fb0e27f454ec70e63cbcffd47b24649114af3fc..1959c0222dc839e444a8e4617d0519bf92e9f346 100644 --- a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/dto/FlowElementEnhancedDTO.java +++ b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/dto/FlowElementEnhancedDTO.java @@ -6,6 +6,7 @@ public class FlowElementEnhancedDTO { private String name; private List<String> inputVariables; + private List<String> outputVariables; public FlowElementEnhancedDTO() { } @@ -25,4 +26,12 @@ public class FlowElementEnhancedDTO { public void setInputVariables(List<String> inputVariables) { this.inputVariables = inputVariables; } + + public List<String> getOutputVariables() { + return outputVariables; + } + + public void setOutputVariables(List<String> outputVariables) { + this.outputVariables = outputVariables; + } } diff --git a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/test/TestService.java b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/test/TestService.java index e6fe4a57bb2cab56f8181d7cadcce4f298e688ce..da5780286d1d6633159155d32b0e3c02d6d5a6d7 100644 --- a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/test/TestService.java +++ b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/test/TestService.java @@ -352,28 +352,47 @@ public class TestService { BPMNIOParameters bpmnIOParameters, List<ExternalTopic> externalTopics) { if (flowElement instanceof StartEvent) { - List<Variable> inputVariables = filterFlowElementVariables(variables, + List<Variable> startVariables = filterFlowElementVariables(variables, formFields.getVariablesForTask(flowElement.getId())); - return TestgeneratorDSLObjectCreator.createStartFlowElement(flowElement.getId(), inputVariables); + return TestgeneratorDSLObjectCreator.createStartFlowElement(flowElement.getId(), startVariables); } else if (flowElement instanceof EndEvent) { return TestgeneratorDSLObjectCreator.createEndFlowElement(flowElement.getId()); } else if (flowElement instanceof Gateway) { return TestgeneratorDSLObjectCreator.createGatewayFlowElement(flowElement.getId()); } else if (flowElement instanceof UserTask) { List<String> inputVariableNames = new ArrayList<>(); - inputVariableNames.addAll(bpmnIOParameters.getOutputVariables(flowElement.getId())); - inputVariableNames.addAll(formFields.getVariablesForTask(flowElement.getId())); - + inputVariableNames.addAll(bpmnIOParameters.getInputVariables(flowElement.getId())); + List<String> outputVariableNames = new ArrayList<>(); + outputVariableNames.addAll(bpmnIOParameters.getOutputVariables(flowElement.getId())); List<Variable> inputVariables = filterFlowElementVariables(variables, inputVariableNames); + List<Variable> outputVariables = filterFlowElementVariables(variables, outputVariableNames); - return TestgeneratorDSLObjectCreator.createUserTaskFlowElement(flowElement.getId(), inputVariables, flowElement.getName()); + return TestgeneratorDSLObjectCreator.createUserTaskFlowElement(flowElement.getId(), inputVariables, outputVariables, flowElement.getName()); } else if (flowElement instanceof ManualTask) { - return TestgeneratorDSLObjectCreator.createManualTaskFlowElement(flowElement.getId(), flowElement.getName()); + List<String> inputVariableNames = new ArrayList<>(); + inputVariableNames.addAll(bpmnIOParameters.getInputVariables(flowElement.getId())); + List<String> outputVariableNames = new ArrayList<>(); + outputVariableNames.addAll(bpmnIOParameters.getOutputVariables(flowElement.getId())); + List<Variable> inputVariables = filterFlowElementVariables(variables, inputVariableNames); + List<Variable> outputVariables = filterFlowElementVariables(variables, outputVariableNames); + return TestgeneratorDSLObjectCreator.createManualTaskFlowElement(flowElement.getId(), inputVariables, outputVariables, flowElement.getName()); } else if (flowElement instanceof ScriptTask) { - return TestgeneratorDSLObjectCreator.createScriptTaskFlowElement(flowElement.getId(), flowElement.getName()); + List<String> inputVariableNames = new ArrayList<>(); + inputVariableNames.addAll(bpmnIOParameters.getInputVariables(flowElement.getId())); + List<String> outputVariableNames = new ArrayList<>(); + outputVariableNames.addAll(bpmnIOParameters.getOutputVariables(flowElement.getId())); + List<Variable> inputVariables = filterFlowElementVariables(variables, inputVariableNames); + List<Variable> outputVariables = filterFlowElementVariables(variables, outputVariableNames); + return TestgeneratorDSLObjectCreator.createScriptTaskFlowElement(flowElement.getId(), inputVariables, outputVariables, flowElement.getName()); } else if (flowElement instanceof BusinessRuleTask) { String resultVariable = BPMNParseUtils.getResultVariable((BusinessRuleTask) flowElement); - return TestgeneratorDSLObjectCreator.createBusinessRuleTaskFlowElement(flowElement.getId(), resultVariable, flowElement.getName()); + List<String> inputVariableNames = new ArrayList<>(); + inputVariableNames.addAll(bpmnIOParameters.getInputVariables(flowElement.getId())); + List<String> outputVariableNames = new ArrayList<>(); + outputVariableNames.addAll(bpmnIOParameters.getOutputVariables(flowElement.getId())); + List<Variable> inputVariables = filterFlowElementVariables(variables, inputVariableNames); + List<Variable> outputVariables = filterFlowElementVariables(variables, outputVariableNames); + return TestgeneratorDSLObjectCreator.createBusinessRuleTaskFlowElement(flowElement.getId(), resultVariable, inputVariables, outputVariables, flowElement.getName()); } else if (flowElement instanceof ServiceTask) { String delegate = getDelegate((ServiceTask) flowElement); @@ -381,19 +400,32 @@ public class TestService { ExternalTopic externalTopic = getExternalTopic(externalTopics, externalTopicTextual); if (delegate != null) { + List<String> inputVariableNames = new ArrayList<>(); + inputVariableNames.addAll(bpmnIOParameters.getInputVariables(flowElement.getId())); + List<String> outputVariableNames = new ArrayList<>(); + outputVariableNames.addAll(bpmnIOParameters.getOutputVariables(flowElement.getId())); + List<Variable> inputVariables = filterFlowElementVariables(variables, inputVariableNames); + List<Variable> outputVariables = filterFlowElementVariables(variables, outputVariableNames); return TestgeneratorDSLObjectCreator.createDelegateServiceTaskFlowElement(flowElement.getId(), - delegate, flowElement.getName()); + delegate, inputVariables, outputVariables, flowElement.getName()); } else if (externalTopic != null) { List<VariableDeclaration> hardcodedVariables = BPMNParseUtils.getHardcodedVariables(flowElement.getId(), variables, bpmnIOParameters); + List<String> inputVariableNames = new ArrayList<>(); + inputVariableNames.addAll(bpmnIOParameters.getInputVariables(flowElement.getId())); + List<String> outputVariableNames = new ArrayList<>(); + outputVariableNames.addAll(bpmnIOParameters.getOutputVariables(flowElement.getId())); + List<Variable> inputVariables = filterFlowElementVariables(variables, inputVariableNames); + List<Variable> outputVariables = filterFlowElementVariables(variables, outputVariableNames); return TestgeneratorDSLObjectCreator.createExternalServiceTaskFlowElement(flowElement.getId(), - externalTopic, hardcodedVariables, flowElement.getName()); + externalTopic, hardcodedVariables, flowElement.getName(), inputVariables, outputVariables); } else { throw new IncompleteFlowElementException(flowElement.getId()); } } else if (flowElement instanceof SequenceFlow) { String expression = expressions.getSequenceFlowExpressionMap().get(flowElement.getId()); return TestgeneratorDSLObjectCreator.createSequenceFlowElement(flowElement.getId(), expression); + } throw new UnsupportedFlowElementException(flowElement.getId()); diff --git a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/utils/BPMNParseUtils.java b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/utils/BPMNParseUtils.java index 3da523422f7f99702af7a192c660e5ef62e545e1..dfea5fb8b0dface1d4da7b6df3c1d946b94f73d2 100644 --- a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/utils/BPMNParseUtils.java +++ b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/utils/BPMNParseUtils.java @@ -6,15 +6,19 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.camunda.bpm.engine.impl.juel.Tree; import org.camunda.bpm.model.bpmn.BpmnModelInstance; import org.camunda.bpm.model.bpmn.instance.BusinessRuleTask; import org.camunda.bpm.model.bpmn.instance.ServiceTask; import org.camunda.bpm.model.dmn.DmnModelInstance; import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNBundle; +import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNExpressions; import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNFlowSet; import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNFormFields; import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNIOParameters; @@ -141,8 +145,11 @@ public class BPMNParseUtils { public static List<Variable> getVariables(BPMNFormFields formFields, HashMap<String, BPMNTestdata<? extends Object>> variableTestdata, BPMNIOParameters bpmnIOParameters) { + HashMap<String, List<String>> inputList = bpmnIOParameters.getInputParameters(); + HashMap<String, List<String>> outputList = bpmnIOParameters.getOutputParameters(); + List<String> hardcodedList = bpmnIOParameters.getHardcodedInputParameters(); + List<Variable> variables = new ArrayList<>(); - List<StringVariable> stringVariables = Stream.concat(Stream.concat(// formFields.getStringVariables().stream(), // bpmnIOParameters.getVariables().stream()), // @@ -151,12 +158,12 @@ public class BPMNParseUtils { .map(s -> TestgeneratorDSLObjectCreator.createStringVariable(s, getProposals(s, variableTestdata.get(s), String.class))) // .collect(Collectors.toList()); // + // List<StringVariable> stringVariables = formFields.getStringVariables().stream() // // .map(s -> TestgeneratorDSLObjectCreator.createStringVariable(s, // getProposals(s, variableTestdata.get(s), String.class))) // // .collect(Collectors.toList()); - List<IntVariable> longVariables = Stream.concat( // formFields.getLongVariables().stream(), // bpmnIOParameters.getHardcodedInputParametersLong().stream() // @@ -164,7 +171,6 @@ public class BPMNParseUtils { .map(i -> TestgeneratorDSLObjectCreator.createIntVariable(i, getIntProposals(i, variableTestdata.get(i)))) // .collect(Collectors.toList()); - List<BooleanVariable> booleanVariables = Stream.concat(// formFields.getBooleanVariables().stream(), // bpmnIOParameters.getHardcodedInputParametersBoolean().stream() // @@ -172,11 +178,9 @@ public class BPMNParseUtils { .map(b -> TestgeneratorDSLObjectCreator.createBooleanVariable(b, getProposals(b, variableTestdata.get(b), Boolean.class))) // .collect(Collectors.toList()); - variables.addAll(stringVariables); variables.addAll(longVariables); variables.addAll(booleanVariables); - return variables; } @@ -257,7 +261,6 @@ public class BPMNParseUtils { .map(entry -> VariableConverter.getVariableDeclaration(variables, entry.getKey(), entry.getValue())) // .forEach(variableDeclaration -> hardcodedVariables.add(variableDeclaration)); // } - return hardcodedVariables; } }