Rule in Asqatasun

Rules input/output

@@@TODO refactor this doc

Input

  • DOM
  • CSS “XML-ised”

@@@to be completed with more details

Output

A test can produce a result with 3 levels of information:

  • Level1 (mandatory) -> PROCESS_RESULT that handles the final result of the test (and the total number of elements implied by the test)
  • Level2 (mandatory) -> PROCESS_REMARK that can be either a general message associated with the result, or a message associated with an element of the DOM that needs to be treated. In this case, the type of the element, its result regarding the test, its position (line number), the source code representing it are automatically saved.
  • Level3 (optional) -> EVIDENCE_ELEMENT that can store additional information about the DOM element to help the qualification and thus the resolution.

The main interfaces

The ElementSelector

The ElementSelector > Explanation

This interface defines a selection applied to the DOM, to set the scope of the rule, and thus its applicability

The existing ElementSelector implementations

Here is a not exhaustive list of existing ElementSelector implementations:

The ElementChecker

The ElementChecker > Explanation

This interface defines a check to be done on elements

The ElementChecker > Method to implement

/**
     * Perform the check operation. The instance of {@link ElementHandler}
     * received as a parameter is used to retrieve elements the test is about
     * and the instance of {@link TestSolutionHandler} received
     * as a parameter is used to store the results of tests performed
     * during the operation
     *
     * @param sspHandler
     * @param elementHandler
     * @param testSolutionHandler
     *
     */
    void check (
            SSPHandler sspHandler,
            ElementHandler elementHandler,
            TestSolutionHandler testSolutionHandler);

Abstract implementation

The existing ElementChecker implementations

Here is a not exhaustive list of existing ElementChecker implementations:

The TextElementBuilder

The TextElementBuilder > Explanation

This builder is in charge of creating a textual representation of an HTML element.

The TextElementBuilder > Method to implement

/**
 * @param element
 * @return a textual representation of the element
 */
String buildTextFromElement(Element element);

Take a look at the online javadoc of the Jsoup Element.

The existing TextElementBuilder implementations

Here is the list of existing TextElementBuilder implementations:

Test context

Create a nomenclature and populate it

-- INSERT THE NOMENCLATURE
INSERT IGNORE INTO `NOMENCLATURE` (`Cd_Nomenclature`) VALUES ('MyNomenclature');

-- INSERT AN ELEMENT AND LINK IT TO THE NOMENCLATURE
INSERT IGNORE INTO `NOMENCLATURE_ELEMENT` (`DTYPE`, `Label`) VALUES ('NomenclatureElementImpl', 'Value1');
UPDATE `NOMENCLATURE_ELEMENT`
SET `Id_Nomenclature`= (
    SELECT `Id_Nomenclature`
    FROM `NOMENCLATURE`
    WHERE `Cd_Nomenclature`
    LIKE 'MyNomenclature')
WHERE Label like 'Value1';