diff --git a/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/TestgeneratorDSL.xtext b/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/TestgeneratorDSL.xtext index d18bc7dbb141224d472fe28ff2c7bca55a33502f..589ccfa23cee11dc2478862d0ce2b15e3a91216c 100644 --- a/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/TestgeneratorDSL.xtext +++ b/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/TestgeneratorDSL.xtext @@ -107,21 +107,25 @@ Variable: StringVariable | IntVariable | BooleanVariable; VariableReference: - ref=[Variable]; + ref=[Variable] + ("(" validationStatus=ValidationState ")")?; StringVariable: "String" name=ID "with" "proposals" ASSOCIATION LIST_OPEN (proposals+=STRING (SEPARATOR proposals+=STRING)*)? LIST_CLOSED + "with" "constraints" ASSOCIATION LIST_OPEN (constraints+=Constraint (SEPARATOR constraints+=Constraint)*)? LIST_CLOSED DECLARATION_FINISHED; IntVariable: "Integer" name=ID "with" "proposals" ASSOCIATION LIST_OPEN (proposals+=INT (SEPARATOR proposals+=INT)*)? LIST_CLOSED + "with" "constraints" ASSOCIATION LIST_OPEN (constraints+=Constraint (SEPARATOR constraints+=Constraint)*)? LIST_CLOSED DECLARATION_FINISHED; BooleanVariable: "Boolean" name=ID "with" "proposals" ASSOCIATION LIST_OPEN (proposals+=Boolean (SEPARATOR proposals+=Boolean)*)? LIST_CLOSED + "with" "constraints" ASSOCIATION LIST_OPEN (constraints+=Constraint (SEPARATOR constraints+=Constraint)*)? LIST_CLOSED DECLARATION_FINISHED; enum Boolean: @@ -239,6 +243,9 @@ IntCompare: BooleanCompare: key=[BooleanVariable] compareSymbol=BooleanCompareSymbol value=Boolean; + +Constraint: + key=STRING ASSOCIATION value=INT; enum StringCompareSymbol: EQUALS = "==" | @@ -261,6 +268,11 @@ enum Flag: GREEN = "GREEN" | YELLOW = "YELLOW" | RED = "RED"; + +enum ValidationState: + REQUIRED = "REQUIRED" | + OPTIONAL = "OPTIONAL" +; terminal LIST_OPEN : '['; terminal LIST_CLOSED : ']'; diff --git a/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/serialization/Main.java b/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/serialization/Main.java index f5f994b2c08ea44305031fb9da58a1aa8603580b..f2895faebaa2d6418a1771e5416729c5a620f658 100644 --- a/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/serialization/Main.java +++ b/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/serialization/Main.java @@ -2,6 +2,7 @@ package de.fhmuenster.masterthesis.serialization; import java.io.IOException; import java.util.Arrays; +import java.util.Collections; import java.util.List; import de.fhmuenster.masterthesis.testgeneratorDSL.BPMNDiagram; @@ -31,7 +32,7 @@ public class Main { FlowElement start = TestgeneratorDSLObjectCreator.createStartFlowElement("Start_123", Arrays.asList()); FlowElement gateway = TestgeneratorDSLObjectCreator.createGatewayFlowElement("Gateway_123"); - FlowElement activity = TestgeneratorDSLObjectCreator.createUserTaskFlowElement("Activity_123", Arrays.asList(), Arrays.asList(), "Activity 123"); + FlowElement activity = TestgeneratorDSLObjectCreator.createUserTaskFlowElement("Activity_123", Arrays.asList(), Arrays.asList(), "Activity 123", null); FlowElement end = TestgeneratorDSLObjectCreator.createEndFlowElement("End_123"); FlowElement activity2 = TestgeneratorDSLObjectCreator.createServiceTaskFlowElement("Activity_234"); FlowElement end2 = TestgeneratorDSLObjectCreator.createEndFlowElement("End_234"); diff --git a/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/serialization/TestgeneratorDSLObjectCreator.java b/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/serialization/TestgeneratorDSLObjectCreator.java index 7bc2cebfbe853b313b6d6d60482419d5eeeb7550..17e3ee90835ccb41ea27b04c2fddbc29053f524c 100644 --- a/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/serialization/TestgeneratorDSLObjectCreator.java +++ b/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/serialization/TestgeneratorDSLObjectCreator.java @@ -16,6 +16,7 @@ import de.fhmuenster.masterthesis.testgeneratorDSL.BooleanVariableEquals; import de.fhmuenster.masterthesis.testgeneratorDSL.BooleanVariableNotEquals; import de.fhmuenster.masterthesis.testgeneratorDSL.BusinessRuleTaskFlowElement; import de.fhmuenster.masterthesis.testgeneratorDSL.Compare; +import de.fhmuenster.masterthesis.testgeneratorDSL.Constraint; import de.fhmuenster.masterthesis.testgeneratorDSL.DelegateMock; import de.fhmuenster.masterthesis.testgeneratorDSL.DelegateServiceTaskFlowElement; import de.fhmuenster.masterthesis.testgeneratorDSL.DelegateServiceTaskReference; @@ -57,6 +58,7 @@ import de.fhmuenster.masterthesis.testgeneratorDSL.StringVariableNotEquals; import de.fhmuenster.masterthesis.testgeneratorDSL.Test; import de.fhmuenster.masterthesis.testgeneratorDSL.TestgeneratorDSLFactory; import de.fhmuenster.masterthesis.testgeneratorDSL.UserTaskFlowElement; +import de.fhmuenster.masterthesis.testgeneratorDSL.ValidationState; import de.fhmuenster.masterthesis.testgeneratorDSL.Variable; import de.fhmuenster.masterthesis.testgeneratorDSL.VariableDeclaration; import de.fhmuenster.masterthesis.testgeneratorDSL.VariableDeclarations; @@ -108,7 +110,8 @@ public class TestgeneratorDSLObjectCreator { return element; } - public static UserTaskFlowElement createUserTaskFlowElement(String name, List<Variable> inputVariables, List<Variable> outputVariables, String label) { + public static UserTaskFlowElement createUserTaskFlowElement(String name, List<Variable> inputVariables, List<Variable> outputVariables, String label, + HashMap<String, List<Constraint>> taskSpecificConstraints) { UserTaskFlowElement element = TestgeneratorDSLFactory.eINSTANCE.createUserTaskFlowElement(); element.setName(name); element.setLabel(label); @@ -116,6 +119,18 @@ public class TestgeneratorDSLObjectCreator { for (Variable inputVariable : inputVariables) { VariableReference variableReference = TestgeneratorDSLFactory.eINSTANCE.createVariableReference(); variableReference.setRef(inputVariable); + + if(taskSpecificConstraints.get(inputVariable.getName()) != null) { + for(Constraint c : taskSpecificConstraints.get(inputVariable.getName())) { + if(c.getKey().equals("required")) { + if(c.getValue() == 0) { + variableReference.setValidationStatus(ValidationState.OPTIONAL); + } + } + } + } + + element.getInputVariables().add(variableReference); }