Class IntegrityDSLUtil


  • public final class IntegrityDSLUtil
    extends java.lang.Object
    A utility class providing various helper functions.
    Author:
    Rene Schneider - initial API and implementation
    • Method Detail

      • getAllParamNamesFromFixtureMethod

        public static java.util.List<ParamAnnotationTypeTriplet> getAllParamNamesFromFixtureMethod​(MethodReference aMethod)
        Returns a list of all defined parameter names in a given fixture method, each of the results linked to the annotation reference that's connected to the parameter in the method signature.
        Parameters:
        aMethod - the method to inspect
        Returns:
        a list of parameters and annotation references
      • getParamNameFromAnnotation

        public static java.lang.String getParamNameFromAnnotation​(org.eclipse.xtext.common.types.JvmAnnotationReference anAnnotation)
        Returns the name of a single parameter defined by a given annotation reference.
        Parameters:
        anAnnotation - the annotation reference
        Returns:
        the name
      • getParamMandatoryFlagFromAnnotation

        public static boolean getParamMandatoryFlagFromAnnotation​(org.eclipse.xtext.common.types.JvmAnnotationReference anAnnotation)
        Returns whether the mandatory flag is set defined by a given annotation reference.
        Parameters:
        anAnnotation - the annotation reference
        Returns:
        true if mandatory, false otherwise
      • getAllParamNamesFromFork

        public static java.util.List<ParamAnnotationTypeTriplet> getAllParamNamesFromFork​(ForkDefinition aFork)
        Returns a list of all defined parameter names in a given fork, each of the results linked to the annotation reference that's connected to the parameter in the constructor signature. Only one constructor is supported.
        Parameters:
        aFork - the fork to inspect
        Returns:
        a list of parameters and annotation references
      • getAllParamNamesFromForkerClass

        public static java.util.List<ParamAnnotationTypeTriplet> getAllParamNamesFromForkerClass​(org.eclipse.xtext.common.types.JvmGenericType aForkerType)
        Returns a list of all defined parameter names in a given forker class, each of the results linked to the annotation reference that's connected to the parameter in the constructor signature. Only one constructor is supported.
        Parameters:
        aForkerType - the forker class to inspect
        Returns:
        a list of parameters and annotation references
      • getParamNameStringFromParameterName

        public static java.lang.String getParamNameStringFromParameterName​(ParameterName aParameterName)
        Returns the name of a single given parameter defined by a ParameterName instance.
        Parameters:
        aParameterName - the parameter name instance
        Returns:
        the parameter name string
      • getAllEnumLiteralsFromFixtureMethodParam

        public static java.util.List<org.eclipse.xtext.common.types.JvmEnumerationLiteral> getAllEnumLiteralsFromFixtureMethodParam​(MethodReference aMethod,
                                                                                                                                    org.eclipse.xtext.common.types.JvmAnnotationReference aParamAnnotation)
        Returns a list of all valid enumeration literals for a given parameter in a given fixture method.
        Parameters:
        aMethod - the fixture method reference
        aParamAnnotation - the parameter annotation reference
        Returns:
        a list of enumeration literals, or null if the parameter is not an enum parameter
      • getAllResultNamesFromFixtureMethod

        public static java.util.List<ResultFieldTuple> getAllResultNamesFromFixtureMethod​(MethodReference aMethod)
        Returns a list of named results defined by a given fixture method.
        Parameters:
        aMethod - the method
        Returns:
        the list of results
      • getQualifiedNameOfFixtureMethod

        public static java.lang.String getQualifiedNameOfFixtureMethod​(MethodReference aReference)
        Returns the fully qualified name of the fixture method referenced by the given method reference.
        Parameters:
        aReference - the method reference
        Returns:
        the fully qualified name, including the name of the class and the method itself
      • getQualifiedSuiteName

        public static java.lang.String getQualifiedSuiteName​(SuiteDefinition aSuite)
        Returns the fully qualified name of a given SuiteDefinition.
        Parameters:
        aSuite - the suite
        Returns:
        the fully qualified name
      • getQualifiedVariantName

        public static java.lang.String getQualifiedVariantName​(VariantDefinition aVariant)
        Returns the fully qualified name of a given VariantDefinition.
        Parameters:
        aVariant - the variant
        Returns:
        the fully qualified name
      • getQualifiedForkName

        public static java.lang.String getQualifiedForkName​(ForkDefinition aFork)
        Returns the fully qualified name of a given ForkDefinition.
        Parameters:
        aFork - the fork
        Returns:
        the fully qualified name
      • getQualifiedCallName

        public static java.lang.String getQualifiedCallName​(CallDefinition aCall)
        Returns the fully qualified name of a given CallDefinition.
        Parameters:
        aCall - the call definition
        Returns:
        the fully qualified name
      • getQualifiedTestName

        public static java.lang.String getQualifiedTestName​(TestDefinition aTest)
        Returns the fully qualified name of a given TestDefinition.
        Parameters:
        aTest - the test definition
        Returns:
        the fully qualified name
      • getQualifiedVariableEntityName

        public static java.lang.String getQualifiedVariableEntityName​(VariableOrConstantEntity aVariable,
                                                                      boolean aQualifyLocalVariables)
        Returns the fully qualified name of the given VariableOrConstantEntity.
        Parameters:
        aVariable - the variable
        Returns:
        the fully qualified name
      • getExpectedResultNameStringFromTestResultName

        public static java.lang.String getExpectedResultNameStringFromTestResultName​(ResultName aName)
        Returns the name of a specific test result value.
        Parameters:
        aName - the result name object
        Returns:
        the name string
      • cleanSingleLineComment

        public static java.lang.String cleanSingleLineComment​(VisibleSingleLineComment aComment)
        Removes the prefix as well as any trailing newlines from visible single-line comment text.
        Parameters:
        aComment - the comment
        Returns:
        the cleaned text
      • cleanMultiLineComment

        public static java.lang.String cleanMultiLineComment​(VisibleMultiLineComment aComment)
        Removes prefix and suffix from visible single-line comment text, as well as any newlines in between.
        Parameters:
        aComment - the comment
        Returns:
        the cleaned text
      • getSuiteTitle

        public static java.lang.String getSuiteTitle​(SuiteDefinition aSuite)
        Gets the suites' title from a given suite.
        Parameters:
        aSuite - the suite to search in
        Returns:
        the title of the suite or null if it does not have one
      • isResult

        public static java.lang.Boolean isResult​(org.eclipse.emf.ecore.EObject anObject)
        Determines whether a given EObject is part of a result of a test/call/tabletest.
        Parameters:
        anObject - the object to look at
        Returns:
        true if it is a result, false if not. Null if not determinable.
      • getTableHeaderForTableCell

        public static org.eclipse.emf.ecore.EObject getTableHeaderForTableCell​(ParameterTableValue aTableCell)
        Finds the corresponding table header element to a given table cell element.
        Parameters:
        aTableCell - the table cell element
        Returns:
        the table header element if one exists, the table itself in case of the default result column or null if nothing was found
      • getMethodReferenceForAction

        public static MethodReference getMethodReferenceForAction​(org.eclipse.emf.ecore.EObject anAction)
        Finds the matching method reference for a given Test, Call or TableTest.
        Parameters:
        anAction - the action to find a method for
        Returns:
        the method or null if none was found
      • getInitialValueForConstant

        public static ValueOrEnumValueOrOperationCollection getInitialValueForConstant​(ConstantDefinition aConstant,
                                                                                       VariantDefinition aVariant)
        Determines the initial value for the given constant.
        Parameters:
        aConstant - the constant to explore
        aVariant - the current variant being executed (null if no variant is used)
        Returns:
        the initial value, or null if none was given
      • isGlobalVariableOrConstant

        public static boolean isGlobalVariableOrConstant​(VariableOrConstantEntity anEntity)
        Checks whether the given variable/constant entity is defined in a global (package) context.
        Parameters:
        anEntity - the entity to check
        Returns:
        true if globally defined, false if defined in a suite
      • findUpstreamContainer

        public static <T extends org.eclipse.emf.ecore.EObject> T findUpstreamContainer​(java.lang.Class<T> aContainerClass,
                                                                                        org.eclipse.emf.ecore.EObject aSource)
        Finds an upstream container matching a provided container class.
        Parameters:
        aContainerClass - the class to find
        aSource - the starting point for the search
        Returns:
        the upstream container, or null if nothing was found
      • getPackageContaining

        public static PackageDefinition getPackageContaining​(org.eclipse.emf.ecore.EObject anObject)
        Finds the PackageDefinition that contains the given EObject.
        Parameters:
        anObject - the entity
        Returns:
        the package containing the entity, or null if the entity is not in a package
      • getSuiteContaining

        public static SuiteDefinition getSuiteContaining​(org.eclipse.emf.ecore.EObject anObject)
        Finds the SuiteDefinition that contains the given EObject.
        Parameters:
        anObject - the entity
        Returns:
        the suite containing the entity, or null if the entity is not in a package
      • getIdentifierFromKeyValuePair

        public static java.lang.String getIdentifierFromKeyValuePair​(KeyValuePair aPair)
        KeyValuePairs can be identified either by a free-form String (enclosed in quotes) or by a more restricted ID (without quotes). This method abstracts aways the decision where to get the final identifier from.
        Parameters:
        aPair - the key-value pair
        Returns:
        the identifier
      • getIdentifierFromArbitraryParameterOrResultName

        public static java.lang.String getIdentifierFromArbitraryParameterOrResultName​(ArbitraryParameterOrResultName aName)
        ArbitraryParameterOrResultNames can be identified either by a free-form String (enclosed in quotes) or by a more restricted ID (without quotes). This method abstracts aways the decision where to get the final identifier from.
        Parameters:
        aName - the name
        Returns:
        the identifier
      • isPrivate

        public static boolean isPrivate​(org.eclipse.emf.ecore.EObject anObject)
        Checks whether the given EObject is of private visibility.
        Parameters:
        anObject - the object to check
        Returns:
        true or false (will return false on objects which don't support a visibility modifier)
      • isPrivateInsideSuite

        public static boolean isPrivateInsideSuite​(org.eclipse.emf.ecore.EObject anObject)
        Checks whether the given EObject is located inside a suite and is thus of private visibility by default.
        Parameters:
        anObject -
        Returns:
      • ensureResolved

        public static void ensureResolved​(org.eclipse.emf.ecore.EObject anObject)
        Ensures that a given EObject that is possibly a proxy is resolved, resolving it if necessary.
        Parameters:
        anObject -