From a8ab83ef5fca12fe2ba6df9d860fbd0956da2895 Mon Sep 17 00:00:00 2001 From: Florian Lambers <fl462057@fh-muenster.de> Date: Tue, 18 Jan 2022 15:23:14 +0100 Subject: [PATCH] added junit5 code generation --- .../impl/VariableReferenceImpl.java | 74 +++++++++++++++++++ .../generator/TestgeneratorDSLGenerator.xtend | 10 ++- .../TestgeneratorDSLSerializer.java | 7 ++ 3 files changed, 90 insertions(+), 1 deletion(-) diff --git a/de.fhmuenster.masterthesis.textgeneratordsl/src-gen/de/fhmuenster/masterthesis/testgeneratorDSL/impl/VariableReferenceImpl.java b/de.fhmuenster.masterthesis.textgeneratordsl/src-gen/de/fhmuenster/masterthesis/testgeneratorDSL/impl/VariableReferenceImpl.java index ae00545..fb1e0d6 100644 --- a/de.fhmuenster.masterthesis.textgeneratordsl/src-gen/de/fhmuenster/masterthesis/testgeneratorDSL/impl/VariableReferenceImpl.java +++ b/de.fhmuenster.masterthesis.textgeneratordsl/src-gen/de/fhmuenster/masterthesis/testgeneratorDSL/impl/VariableReferenceImpl.java @@ -4,6 +4,7 @@ package de.fhmuenster.masterthesis.testgeneratorDSL.impl; import de.fhmuenster.masterthesis.testgeneratorDSL.TestgeneratorDSLPackage; +import de.fhmuenster.masterthesis.testgeneratorDSL.ValidationState; import de.fhmuenster.masterthesis.testgeneratorDSL.Variable; import de.fhmuenster.masterthesis.testgeneratorDSL.VariableReference; @@ -24,6 +25,7 @@ import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; * </p> * <ul> * <li>{@link de.fhmuenster.masterthesis.testgeneratorDSL.impl.VariableReferenceImpl#getRef <em>Ref</em>}</li> + * <li>{@link de.fhmuenster.masterthesis.testgeneratorDSL.impl.VariableReferenceImpl#getValidationStatus <em>Validation Status</em>}</li> * </ul> * * @generated @@ -40,6 +42,26 @@ public class VariableReferenceImpl extends MinimalEObjectImpl.Container implemen */ protected Variable ref; + /** + * The default value of the '{@link #getValidationStatus() <em>Validation Status</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getValidationStatus() + * @generated + * @ordered + */ + protected static final ValidationState VALIDATION_STATUS_EDEFAULT = ValidationState.REQUIRED; + + /** + * The cached value of the '{@link #getValidationStatus() <em>Validation Status</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getValidationStatus() + * @generated + * @ordered + */ + protected ValidationState validationStatus = VALIDATION_STATUS_EDEFAULT; + /** * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -106,6 +128,31 @@ public class VariableReferenceImpl extends MinimalEObjectImpl.Container implemen eNotify(new ENotificationImpl(this, Notification.SET, TestgeneratorDSLPackage.VARIABLE_REFERENCE__REF, oldRef, ref)); } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public ValidationState getValidationStatus() + { + return validationStatus; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void setValidationStatus(ValidationState newValidationStatus) + { + ValidationState oldValidationStatus = validationStatus; + validationStatus = newValidationStatus == null ? VALIDATION_STATUS_EDEFAULT : newValidationStatus; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, TestgeneratorDSLPackage.VARIABLE_REFERENCE__VALIDATION_STATUS, oldValidationStatus, validationStatus)); + } + /** * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -119,6 +166,8 @@ public class VariableReferenceImpl extends MinimalEObjectImpl.Container implemen case TestgeneratorDSLPackage.VARIABLE_REFERENCE__REF: if (resolve) return getRef(); return basicGetRef(); + case TestgeneratorDSLPackage.VARIABLE_REFERENCE__VALIDATION_STATUS: + return getValidationStatus(); } return super.eGet(featureID, resolve, coreType); } @@ -136,6 +185,9 @@ public class VariableReferenceImpl extends MinimalEObjectImpl.Container implemen case TestgeneratorDSLPackage.VARIABLE_REFERENCE__REF: setRef((Variable)newValue); return; + case TestgeneratorDSLPackage.VARIABLE_REFERENCE__VALIDATION_STATUS: + setValidationStatus((ValidationState)newValue); + return; } super.eSet(featureID, newValue); } @@ -153,6 +205,9 @@ public class VariableReferenceImpl extends MinimalEObjectImpl.Container implemen case TestgeneratorDSLPackage.VARIABLE_REFERENCE__REF: setRef((Variable)null); return; + case TestgeneratorDSLPackage.VARIABLE_REFERENCE__VALIDATION_STATUS: + setValidationStatus(VALIDATION_STATUS_EDEFAULT); + return; } super.eUnset(featureID); } @@ -169,8 +224,27 @@ public class VariableReferenceImpl extends MinimalEObjectImpl.Container implemen { case TestgeneratorDSLPackage.VARIABLE_REFERENCE__REF: return ref != null; + case TestgeneratorDSLPackage.VARIABLE_REFERENCE__VALIDATION_STATUS: + return validationStatus != VALIDATION_STATUS_EDEFAULT; } return super.eIsSet(featureID); } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (validationStatus: "); + result.append(validationStatus); + result.append(')'); + return result.toString(); + } + } //VariableReferenceImpl diff --git a/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/generator/TestgeneratorDSLGenerator.xtend b/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/generator/TestgeneratorDSLGenerator.xtend index 3645989..094c9fa 100644 --- a/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/generator/TestgeneratorDSLGenerator.xtend +++ b/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/generator/TestgeneratorDSLGenerator.xtend @@ -254,12 +254,20 @@ class TestgeneratorDSLGenerator extends AbstractGenerator { appendLine("import org.junit.Before;"); appendLine("import org.junit.ClassRule;"); appendLine("import org.junit.Rule;"); - appendLine("import org.junit.Test;"); appendLine("import java.util.List;"); appendLine("import java.util.Map;"); + appendLine("import org.junit.jupiter.api.Test;"); + appendLine("import org.junit.jupiter.api.TestMethodOrder;"); + appendLine("import org.junit.jupiter.api.extension.ExtendWith;"); + appendLine("import org.junit.jupiter.api.Order;"); + appendLine("import org.junit.jupiter.api.MethodOrderer;"); + appendLine("import org.camunda.bpm.extension.junit5.test.ProcessEngineExtension;"); + } def addClassHeader(String className, StringBuilder builder) { + appendLine("@TestMethodOrder(MethodOrderer.OrderAnnotation.class)"); + appendLine("@ExtendWith(ProcessEngineExtension.class)"); appendLine(String.format(CLASS_DECLARATION, className), builder); } diff --git a/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/serialization/TestgeneratorDSLSerializer.java b/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/serialization/TestgeneratorDSLSerializer.java index 7fa2029..14a3b3c 100644 --- a/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/serialization/TestgeneratorDSLSerializer.java +++ b/de.fhmuenster.masterthesis.textgeneratordsl/src/de/fhmuenster/masterthesis/serialization/TestgeneratorDSLSerializer.java @@ -42,6 +42,7 @@ import de.fhmuenster.masterthesis.testgeneratorDSL.Loop; import de.fhmuenster.masterthesis.testgeneratorDSL.Mock; import de.fhmuenster.masterthesis.testgeneratorDSL.MockReference; import de.fhmuenster.masterthesis.testgeneratorDSL.Model; +import de.fhmuenster.masterthesis.testgeneratorDSL.SequenceFlowElement; import de.fhmuenster.masterthesis.testgeneratorDSL.ServiceTaskFlowElement; import de.fhmuenster.masterthesis.testgeneratorDSL.StartFlowElement; import de.fhmuenster.masterthesis.testgeneratorDSL.StringVariable; @@ -503,6 +504,12 @@ public class TestgeneratorDSLSerializer { .collect(Collectors.toList()); // } + public List<SequenceFlowElement> getSequenceFlows() { + return model.getDeclarations().stream() // + .filter(s -> s instanceof SequenceFlowElement) // + .map(s -> ((SequenceFlowElement) s)) // + .collect(Collectors.toList()); // + } public void serialize() throws IOException { String serialized = serializer.serialize(model); -- GitLab