Search in sources :

Example 6 with TextAttributeOfElementBuilder

use of org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder in project Asqatasun by Asqatasun.

the class TextPertinenceCheckerTest method testGetTextElementBuilder.

/**
     * Test of getTextElementBuilder method, of class TextPertinenceChecker.
     */
public void testGetTextElementBuilder() {
    LOGGER.debug("getTextElementBuilder");
    TextPertinenceChecker instance = new TextPertinenceChecker(true, new TextAttributeOfElementBuilder(AttributeStore.ALT_ATTR), "blacklistNomenclature", TestSolution.NEED_MORE_INFO, "notPertinent", "manualCheck");
    TextElementBuilder result = instance.getTextElementBuilder();
    assertTrue(result instanceof SimpleTextElementBuilder);
}
Also used : SimpleTextElementBuilder(org.asqatasun.rules.textbuilder.SimpleTextElementBuilder) TextAttributeOfElementBuilder(org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder) TextElementBuilder(org.asqatasun.rules.textbuilder.TextElementBuilder) SimpleTextElementBuilder(org.asqatasun.rules.textbuilder.SimpleTextElementBuilder)

Example 7 with TextAttributeOfElementBuilder

use of org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder in project Asqatasun by Asqatasun.

the class TextNotIdenticalToAttributeCheckerTest method testDoCheckWithNullTextToCheckAndDetectionResultOverridenByConstructor.

/**
     * Test of doCheck method, of class TextNotIdenticalToAttributeChecker.
     */
public void testDoCheckWithNullTextToCheckAndDetectionResultOverridenByConstructor() {
    LOGGER.debug("doCheckWithNullTextToCheckAndDetectionResultOverridenByConstructor");
    /* Prepare test context */
    elements.add(element);
    mockTestSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
    expectLastCall().once();
    expect(mockTextElementBuilder.buildTextFromElement(element)).andReturn(null);
    TextNotIdenticalToAttributeChecker instance = new TextNotIdenticalToAttributeChecker(mockTextElementBuilder, new TextAttributeOfElementBuilder(AttributeStore.ALT_ATTR), new ImmutablePair(TestSolution.NOT_APPLICABLE, DETECTION_MSG), new ImmutablePair(TestSolution.PASSED, ""));
    replay(mockTextElementBuilder, mockSSPHandler, mockTestSolutionHandler);
    /* test */
    instance.doCheck(mockSSPHandler, elements, mockTestSolutionHandler);
    /* verification */
    verify(mockTextElementBuilder, mockSSPHandler, mockTestSolutionHandler);
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TextAttributeOfElementBuilder(org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder)

Example 8 with TextAttributeOfElementBuilder

use of org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder in project Asqatasun by Asqatasun.

the class Rgaa30Rule010302 method getMarkerElementChecker.

/**
     * 
     * @return the checker user for marked elements
     */
private ElementChecker getMarkerElementChecker() {
    CompositeChecker ec = new CompositeChecker(// checker for elements identified by marker
    new AttributePertinenceChecker(ALT_ATTR, // check emptiness
    true, // compare with src attribute
    new TextAttributeOfElementBuilder(HREF_ATTR), // compare attribute value with nomenclature
    IMAGE_FILE_EXTENSION_NOM, // not pertinent message
    NOT_PERTINENT_ALT_MSG, // manual check message
    CHECK_ALT_PERTINENCE_OF_INFORMATIVE_IMG_MSG, // evidence elements
    ALT_ATTR, TITLE_ATTR, HREF_ATTR), new TextNotIdenticalToAttributeChecker(new TextAttributeOfElementBuilder(TITLE_ATTR), new TextAttributeOfElementBuilder(ALT_ATTR), new ImmutablePair(PASSED, ""), new ImmutablePair(FAILED, TITLE_NOT_IDENTICAL_TO_ALT_MSG), // evidence elements
    ALT_ATTR, TITLE_ATTR, HREF_ATTR));
    ec.setIsOrCombinaison(false);
    return ec;
}
Also used : TextNotIdenticalToAttributeChecker(org.asqatasun.rules.elementchecker.text.TextNotIdenticalToAttributeChecker) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TextAttributeOfElementBuilder(org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder) AttributePertinenceChecker(org.asqatasun.rules.elementchecker.pertinence.AttributePertinenceChecker) CompositeChecker(org.asqatasun.rules.elementchecker.CompositeChecker)

Example 9 with TextAttributeOfElementBuilder

use of org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder in project Asqatasun by Asqatasun.

the class Rgaa30Rule010302 method getLocalRegularElementChecker.

/**
     * 
     * @return the checker user for not marked elements
     */
private ElementChecker getLocalRegularElementChecker() {
    CompositeChecker compositeChecker = new CompositeChecker(ALT_ATTR, TITLE_ATTR, HREF_ATTR);
    compositeChecker.addChecker(new AttributePertinenceChecker(ALT_ATTR, // check emptiness
    true, // compare with src attribute
    new TextAttributeOfElementBuilder(HREF_ATTR), // compare attribute value with nomenclature
    IMAGE_FILE_EXTENSION_NOM, // solution when not pertinent
    FAILED, // not pertinent message
    "", // manual check message
    ""));
    compositeChecker.addChecker(new TextNotIdenticalToAttributeChecker(new TextAttributeOfElementBuilder(ALT_ATTR), new TextAttributeOfElementBuilder(TITLE_ATTR), new ImmutablePair(FAILED, ""), new ImmutablePair(PASSED, "")));
    compositeChecker.setIsOrCombinaison(false);
    compositeChecker.addCheckMessageFromSolution(NEED_MORE_INFO, Collections.singletonMap(NEED_MORE_INFO, RemarkMessageStore.CHECK_NATURE_OF_IMAGE_AND_ALT_PERTINENCE_MSG));
    compositeChecker.addCheckMessageFromSolution(FAILED, Collections.singletonMap(NEED_MORE_INFO, RemarkMessageStore.CHECK_NATURE_OF_IMAGE_WITH_NOT_PERTINENT_ALT_MSG));
    return compositeChecker;
}
Also used : TextNotIdenticalToAttributeChecker(org.asqatasun.rules.elementchecker.text.TextNotIdenticalToAttributeChecker) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TextAttributeOfElementBuilder(org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder) AttributePertinenceChecker(org.asqatasun.rules.elementchecker.pertinence.AttributePertinenceChecker) CompositeChecker(org.asqatasun.rules.elementchecker.CompositeChecker)

Example 10 with TextAttributeOfElementBuilder

use of org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder in project Asqatasun by Asqatasun.

the class Rgaa30Rule010201 method getLocalRegularElementChecker.

/**
     * 
     * @return the checker user for not marked elements
     */
private ElementChecker getLocalRegularElementChecker() {
    CompositeChecker compositeChecker = new CompositeChecker(ALT_ATTR, TITLE_ATTR, SRC_ATTR);
    compositeChecker.addChecker(new TextEmptinessChecker(new TextAttributeOfElementBuilder(ALT_ATTR), new ImmutablePair(PASSED, ""), new ImmutablePair(FAILED, "")));
    compositeChecker.addChecker(new AttributePresenceChecker(TITLE_ATTR, new ImmutablePair(FAILED, ""), new ImmutablePair(PASSED, "")));
    compositeChecker.setIsOrCombinaison(false);
    compositeChecker.addCheckMessageFromSolution(PASSED, Collections.singletonMap(NEED_MORE_INFO, RemarkMessageStore.CHECK_NATURE_OF_IMAGE_WITH_EMPTY_ALT_MSG));
    compositeChecker.addCheckMessageFromSolution(FAILED, Collections.singletonMap(NEED_MORE_INFO, RemarkMessageStore.CHECK_NATURE_OF_IMAGE_WITH_NOT_EMPTY_ALT_MSG));
    return compositeChecker;
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TextAttributeOfElementBuilder(org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder) TextEmptinessChecker(org.asqatasun.rules.elementchecker.text.TextEmptinessChecker) CompositeChecker(org.asqatasun.rules.elementchecker.CompositeChecker) AttributePresenceChecker(org.asqatasun.rules.elementchecker.attribute.AttributePresenceChecker)

Aggregations

TextAttributeOfElementBuilder (org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder)16 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)13 CompositeChecker (org.asqatasun.rules.elementchecker.CompositeChecker)8 TextEmptinessChecker (org.asqatasun.rules.elementchecker.text.TextEmptinessChecker)8 AttributePresenceChecker (org.asqatasun.rules.elementchecker.attribute.AttributePresenceChecker)7 ElementChecker (org.asqatasun.rules.elementchecker.ElementChecker)5 AttributePertinenceChecker (org.asqatasun.rules.elementchecker.pertinence.AttributePertinenceChecker)4 TextNotIdenticalToAttributeChecker (org.asqatasun.rules.elementchecker.text.TextNotIdenticalToAttributeChecker)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ElementHandler (org.asqatasun.ruleimplementation.ElementHandler)3 ElementHandlerImpl (org.asqatasun.ruleimplementation.ElementHandlerImpl)3 IdUnicityChecker (org.asqatasun.rules.elementchecker.attribute.IdUnicityChecker)3 ElementPresenceChecker (org.asqatasun.rules.elementchecker.element.ElementPresenceChecker)3 Element (org.jsoup.nodes.Element)3 TextLengthChecker (org.asqatasun.rules.elementchecker.text.TextLengthChecker)1 SimpleTextElementBuilder (org.asqatasun.rules.textbuilder.SimpleTextElementBuilder)1 TextElementBuilder (org.asqatasun.rules.textbuilder.TextElementBuilder)1