use of org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder in project Asqatasun by Asqatasun.
the class TextNotIdenticalToAttributeCheckerTest method testDoCheckWithDefaultNotDetectionResultAndDetectionResultOverridenByConstructor.
/**
* Test of doCheck method, of class TextNotIdenticalToAttributeChecker.
*/
public void testDoCheckWithDefaultNotDetectionResultAndDetectionResultOverridenByConstructor() {
LOGGER.debug("doCheckWithDefaultNotDetectionResultAndDetectionResultOverridenByConstructor");
/* Prepare test context */
elements.add(element);
expect(mockTextElementBuilder.buildTextFromElement(element)).andReturn("testNotIdentical");
mockTestSolutionHandler.addTestSolution(TestSolution.PASSED);
expectLastCall().once();
TextNotIdenticalToAttributeChecker instance = new TextNotIdenticalToAttributeChecker(mockTextElementBuilder, new TextAttributeOfElementBuilder(AttributeStore.ALT_ATTR), new ImmutablePair(TestSolution.NEED_MORE_INFO, DETECTION_MSG), new ImmutablePair(TestSolution.PASSED, ""));
replay(mockTextElementBuilder, mockSSPHandler, mockTestSolutionHandler);
/* test */
instance.doCheck(mockSSPHandler, elements, mockTestSolutionHandler);
/* verification */
verify(mockTextElementBuilder, mockSSPHandler, mockTestSolutionHandler);
}
use of org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder in project Asqatasun by Asqatasun.
the class SeoRule01013 method check.
@Override
protected void check(final SSPHandler sspHandler, final TestSolutionHandler testSolutionHandler) {
if (elementHandler.isEmpty() || elementHandler.get().size() > 1) {
testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
return;
}
ElementChecker checker = new TextLengthChecker(new TextAttributeOfElementBuilder(AttributeStore.CONTENT_ATTR), MAX_META_DESC_LENGTH, META_DESC_EXCEEDS_LIMIT_MSG, // evidence elements
AttributeStore.CONTENT_ATTR);
checker.check(sspHandler, elementHandler, testSolutionHandler);
}
use of org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder in project Asqatasun by Asqatasun.
the class Rgaa30Rule010301 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 AttributePertinenceChecker(ALT_ATTR, // check emptiness
true, // compare with src attribute
new TextAttributeOfElementBuilder(SRC_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;
}
use of org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder in project Asqatasun by Asqatasun.
the class Rgaa30Rule010202 method getLocalRegularElementChecker.
/**
*
* @return the checker user for not marked elements
*/
private ElementChecker getLocalRegularElementChecker() {
CompositeChecker compositeChecker = new CompositeChecker(new TextEmptinessChecker(new TextAttributeOfElementBuilder(ALT_ATTR), new ImmutablePair(PASSED, ""), new ImmutablePair(FAILED, "")), 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;
}
use of org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder in project Asqatasun by Asqatasun.
the class Aw22Rule11012 method check.
@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
// If the page has no input form element, the test is not applicable
if (labels.isEmpty()) {
testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
return;
}
/* The attribute Presence Checker */
ElementChecker attributePresenceChecker = new AttributePresenceChecker(ID_ATTR, TestSolution.PASSED, TestSolution.FAILED, null, ID_MISSING_MSG);
attributePresenceChecker.check(sspHandler, labels, testSolutionHandler);
/* The attribute Emptiness Checker. Keep default value i.e failed
when attribute is empty
*/
ElementChecker attributeEmptinessChecker = new TextEmptinessChecker(new TextAttributeOfElementBuilder(ID_ATTR), ID_MISSING_MSG, null);
attributeEmptinessChecker.check(sspHandler, labels, testSolutionHandler);
/* The id unicityChecker */
ElementChecker idUnicityChecker = new IdUnicityChecker(ID_NOT_UNIQUE_MSG);
idUnicityChecker.check(sspHandler, labels, testSolutionHandler);
}
Aggregations