Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Content layer
id352547792
Content column
id352547794
Content block
id352547791

On this page

Table of Contents
maxLevel4

Content block
id352547793

Class Diagram of a Model Validation Tool

A Class diagram of a ModelValidationTool.

Class MetricstoolModelValidationTool

Methods:

  • +validate( suiteName : String ) : List<ValidationResult>
  • +validate( suiteName : String, severity: String ) : List<ValidationResult>
  • +validate( suiteName : String, element : List, severity : String) : List<ValidationResult>
  • +getSuiteNames() : List<String>

Class ValidationResult

Methods:

  • +getElement( ) : Element
  • +getSeverity( ) : String
  • +getAbbreviation() : String
  • +getMessage( ) : String

Validate Methods

validate(suiteName : String) : List<ValidationResult>

Uses only a suite name to validate a model from the whole project with default “debug” as severity.

Code Block
languagetext
#set ($results = $validator.validate("suitename"))

validate(suiteName : String, severity : String) : List<ValidationResult>

Uses a suite name and a severity type to validate a model from the whole project. The severity types are “debug”, “info”, “warning”, “error” and “fatal”.

Code Block
languagetext
#set ($results = $validator.validate("suitename", "severity"))

validate(suiteName : String, elementList : List<Element>, severity : String) : List<ValidationResult>

Uses a suite name and a severity type to validate a model from an element list. The severity types are “debug”, “info”, “warning”, “error”, and “fatal”.

Code Block
languagetext
#set ($results = $validator.validate("suitename", $elementList, "severity"))

To validate all classes by using ‘UML completeness constraints’ suite and the severity type is warning, for example, type the following code:

Code Block
languagetext
#set ($results = $validator.validate("UML completeness constraints", $Class, "warning"))

Getting the Suite Name List

The template author can list the entire available Model Validation suite names from ‘suiteNames’ methods. The ‘suiteNames’ is available in the ModelValidationtool class.

getSuiteNames() : List<String>

Code Block
languagetext
#set ($nameList = $validator.suiteNames)

$validator represents the ModelValidationtool class.

Prints all Metrics names and their values of all Classes, for example, type the following code:

Code Block
languagetext
#foreach ($name in $validator.suiteNames)
$name
#end

Getting the Validation Data from Validation Results

The object returned from validate methods in the previous section is the list of validation results. The validation results contain columns of validation result with each row of validated models.

getElement() : Element

Gets a validated element.

Code Block
languagetext
#set ($element = $result.getElement())

To print all validated elements' names, for example, type the following code:

Code Block
languagetext
#set ($results = $validator.validate("UML completeness constraints")) 
#foreach ($result in $results) 
$result.element.name
#end

getSeverity() : String

Gets a severity type.

Code Block
languagetext
#set ($severity = $result.getSeverity())
or
$result.severity

getAbbreviation() : String

Gets an abbreviation.

Code Block
languagetext
#set ($abbr = $result.getAbbreviation())
or
$result.abbreviation

getMessage() : String

Gets a message.

Code Block
languagetext
#set ($message = $result.getMessage())
or
$result.message

isIgnored() : Boolean

Gets an isIgnored value to check whether the validated element is ignored or not.

Code Block
languagetext
#set ($isIgnored = $result.isIgnored())
or
$result.isIgnored