Search in sources :

Example 1 with ElementHandler

use of org.asqatasun.ruleimplementation.ElementHandler in project Asqatasun by Asqatasun.

the class Rgaa30Rule100102 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    // Attributes checks
    for (Map.Entry<String, ElementHandler> attrElementHandlerMapEntry : attrElementHandlerMap.entrySet()) {
        ElementChecker attrEc = new ElementWithAttributePresenceChecker(new ImmutablePair(TestSolution.FAILED, PRESENTATION_ATTR_DETECTED_MSG), new ImmutablePair(TestSolution.PASSED, ""), attrElementHandlerMapEntry.getKey());
        attrEc.check(sspHandler, attrElementHandlerMapEntry.getValue(), testSolutionHandler);
    }
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) ElementWithAttributePresenceChecker(org.asqatasun.rules.elementchecker.element.ElementWithAttributePresenceChecker) ElementHandler(org.asqatasun.ruleimplementation.ElementHandler) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with ElementHandler

use of org.asqatasun.ruleimplementation.ElementHandler in project Asqatasun by Asqatasun.

the class Rgaa32016Rule100102 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    // Attributes checks
    for (Map.Entry<String, ElementHandler> attrElementHandlerMapEntry : attrElementHandlerMap.entrySet()) {
        ElementChecker attrEc = new ElementWithAttributePresenceChecker(new ImmutablePair(TestSolution.FAILED, PRESENTATION_ATTR_DETECTED_MSG), new ImmutablePair(TestSolution.PASSED, ""), attrElementHandlerMapEntry.getKey());
        attrEc.check(sspHandler, attrElementHandlerMapEntry.getValue(), testSolutionHandler);
    }
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) ElementWithAttributePresenceChecker(org.asqatasun.rules.elementchecker.element.ElementWithAttributePresenceChecker) ElementHandler(org.asqatasun.ruleimplementation.ElementHandler) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with ElementHandler

use of org.asqatasun.ruleimplementation.ElementHandler in project Asqatasun by Asqatasun.

the class Rgaa22Rule07081 method select.

@Override
protected void select(SSPHandler sspHandler) {
    super.select(sspHandler);
    // retrieve element from the nomenclature
    Nomenclature deprecatedHtmlTags = nomenclatureLoaderService.loadByCode(PRESENTATION_TAG_NOM);
    // add each element of the nomenclature to the selector
    MultipleElementSelector mes = new MultipleElementSelector();
    for (String deprecatedTag : deprecatedHtmlTags.getValueList()) {
        mes.addCssQuery(deprecatedTag.toLowerCase());
    }
    mes.selectElements(sspHandler, deprecatedElementHandler);
    // retrieve element from the nomenclature
    Nomenclature deprecatedHtmlAttr = nomenclatureLoaderService.loadByCode(PRESENTATION_ATTR_NOM);
    for (String deprecatedAttr : deprecatedHtmlAttr.getValueList()) {
        SimpleElementSelector sec = new SimpleElementSelector(buildQuery(deprecatedAttr));
        ElementHandler eh = new ElementHandlerImpl();
        sec.selectElements(sspHandler, eh);
        attrElementHandlerMap.put(deprecatedAttr, eh);
    }
}
Also used : Nomenclature(org.asqatasun.entity.reference.Nomenclature) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl) SimpleElementSelector(org.asqatasun.rules.elementselector.SimpleElementSelector) ElementHandler(org.asqatasun.ruleimplementation.ElementHandler) MultipleElementSelector(org.asqatasun.rules.elementselector.MultipleElementSelector)

Example 4 with ElementHandler

use of org.asqatasun.ruleimplementation.ElementHandler in project Asqatasun by Asqatasun.

the class Aw22Rule10012 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    // Attributes checks
    for (Map.Entry<String, ElementHandler> attrElementHandlerMapEntry : attrElementHandlerMap.entrySet()) {
        ElementChecker attrEc = new ElementWithAttributePresenceChecker(new ImmutablePair(TestSolution.FAILED, PRESENTATION_ATTR_DETECTED_MSG), new ImmutablePair(TestSolution.PASSED, ""), attrElementHandlerMapEntry.getKey());
        attrEc.check(sspHandler, attrElementHandlerMapEntry.getValue(), testSolutionHandler);
    }
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) ElementWithAttributePresenceChecker(org.asqatasun.rules.elementchecker.element.ElementWithAttributePresenceChecker) ElementHandler(org.asqatasun.ruleimplementation.ElementHandler) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with ElementHandler

use of org.asqatasun.ruleimplementation.ElementHandler in project Asqatasun by Asqatasun.

the class Rgaa22Rule07081 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    // Tags check
    ElementChecker ec = new ElementPresenceChecker(TestSolution.FAILED, TestSolution.PASSED, PRESENTATION_TAG_DETECTED_MSG, null);
    ec.check(sspHandler, deprecatedElementHandler, testSolutionHandler);
    // Attributes checks
    for (Map.Entry<String, ElementHandler> attrElementHandlerMapEntry : attrElementHandlerMap.entrySet()) {
        ElementChecker attrEc = new ElementWithAttributePresenceChecker(new ImmutablePair(TestSolution.FAILED, PRESENTATION_ATTR_DETECTED_MSG), new ImmutablePair(TestSolution.PASSED, ""), attrElementHandlerMapEntry.getKey());
        attrEc.check(sspHandler, attrElementHandlerMapEntry.getValue(), testSolutionHandler);
    }
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) ElementWithAttributePresenceChecker(org.asqatasun.rules.elementchecker.element.ElementWithAttributePresenceChecker) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker) ElementHandler(org.asqatasun.ruleimplementation.ElementHandler) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ElementHandler (org.asqatasun.ruleimplementation.ElementHandler)9 HashMap (java.util.HashMap)7 Map (java.util.Map)7 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)7 ElementChecker (org.asqatasun.rules.elementchecker.ElementChecker)7 ElementHandlerImpl (org.asqatasun.ruleimplementation.ElementHandlerImpl)5 ElementPresenceChecker (org.asqatasun.rules.elementchecker.element.ElementPresenceChecker)4 ElementWithAttributePresenceChecker (org.asqatasun.rules.elementchecker.element.ElementWithAttributePresenceChecker)4 Element (org.jsoup.nodes.Element)4 TextEmptinessChecker (org.asqatasun.rules.elementchecker.text.TextEmptinessChecker)3 TextAttributeOfElementBuilder (org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder)3 AttributePresenceChecker (org.asqatasun.rules.elementchecker.attribute.AttributePresenceChecker)2 IdUnicityChecker (org.asqatasun.rules.elementchecker.attribute.IdUnicityChecker)2 Nomenclature (org.asqatasun.entity.reference.Nomenclature)1 MultipleElementSelector (org.asqatasun.rules.elementselector.MultipleElementSelector)1 SimpleElementSelector (org.asqatasun.rules.elementselector.SimpleElementSelector)1