use of org.asqatasun.entity.audit.EvidenceElement in project Asqatasun by Asqatasun.
the class CssPropertyPresenceCheckerTest method initCheckerAndLaunch.
/**
*
* @param fileName
* @param resultOnDetection
*/
private void initCheckerAndLaunch(String fileName, String[] pseudoSelectors, TestSolution resultOnDetection, String selector) {
try {
String styleSheetName = fileName.substring(fileName.lastIndexOf("/") + 1);
expect(mockTestSolutionHandler.getTestSolution()).andReturn(resultOnDetection).times(2);
mockTestSolutionHandler.addTestSolution(resultOnDetection);
expectLastCall().anyTimes();
if (StringUtils.isNotBlank(selector)) {
EvidenceElement eElement1 = createMock(EvidenceElement.class);
EvidenceElement eElement2 = createMock(EvidenceElement.class);
expect(mockProcessRemarkService.getEvidenceElement(EvidenceStore.CSS_SELECTOR_EE, selector)).andReturn(eElement1);
expect(mockProcessRemarkService.getEvidenceElement(EvidenceStore.CSS_FILENAME_EE, styleSheetName)).andReturn(eElement2);
mockProcessRemarkService.addSourceCodeRemark(resultOnDetection, "content attribute not empty", contentAttributeDectected, eElement1, eElement2);
expectLastCall().once();
EasyMock.replay(mockProcessRemarkService);
}
EasyMock.replay(mockTestSolutionHandler);
CascadingStyleSheet cascadingStyleSheet = CSSReader.readFromString(FileUtils.readFileToString(new File(fileName)), Charset.defaultCharset(), ECSSVersion.CSS30, new CSSParserExceptionHandlerImpl(stylesheetContent));
Collection<String> pseudoSelectorList;
if (pseudoSelectors == null) {
pseudoSelectorList = new ArrayList<>();
} else {
pseudoSelectorList = Arrays.asList(pseudoSelectors);
}
CssPropertyPresenceChecker instance = new CssPropertyPresenceChecker(AttributeStore.CONTENT_ATTR, pseudoSelectorList, resultOnDetection, contentAttributeDectected);
instance.check(mockSSPHandler, styleSheetName, cascadingStyleSheet, mockTestSolutionHandler);
} catch (IOException ex) {
LOGGER.warn(ex);
}
}
use of org.asqatasun.entity.audit.EvidenceElement in project Asqatasun by Asqatasun.
the class AttributePresenceCheckerTest method testDoCheckWithDetectionResultOverridenByConstructorAndProcessRemarkOnAttribute.
/**
* Test of doCheck method, of class AttributePresenceChecker.
*/
public void testDoCheckWithDetectionResultOverridenByConstructorAndProcessRemarkOnAttribute() {
LOGGER.debug("doCheckWithDetectionResultOverridenByConstructorAndProcessRemarkOnAttribute");
/* Prepare test context */
elements.add(element);
mockTestSolutionHandler.addTestSolution(TestSolution.FAILED);
expectLastCall().once();
Collection<EvidenceElement> evidenceElementList = new ArrayList<>();
EvidenceElement ee = createMock(EvidenceElement.class);
expect(mockProcessRemarkService.getEvidenceElement(EvidenceStore.TARGETTED_ELEMENT_FROM_SCOPE_EE, AttributeStore.ALT_ATTR)).andReturn(ee).once();
evidenceElementList.add((ee));
mockProcessRemarkService.addSourceCodeRemarkOnElement(TestSolution.FAILED, element, ATTR_PRESENT_MSG, evidenceElementList);
expectLastCall().once();
AttributePresenceChecker instance = new AttributePresenceChecker(AttributeStore.ALT_ATTR, TestSolution.FAILED, TestSolution.PASSED, ATTR_PRESENT_MSG, ATTR_ABSENT_MSG, true);
instance.setProcessRemarkService(mockProcessRemarkService);
replay(mockSSPHandler, mockTestSolutionHandler, mockProcessRemarkService);
/* test */
instance.doCheck(mockSSPHandler, elements, mockTestSolutionHandler);
/* verification */
verify(mockSSPHandler, mockTestSolutionHandler, mockProcessRemarkService);
}
use of org.asqatasun.entity.audit.EvidenceElement in project Asqatasun by Asqatasun.
the class Rgaa22Rule10021 method addElementNameEvidenceElementToOverrideTarget.
/**
* This method adds an evidence element of type DEFAULT_EVIDENCE to
* override the default behaviour when grouping message.
*
* @param prs
* @param pr
*/
private void addElementNameEvidenceElementToOverrideTarget(ProcessRemarkService prs, ProcessRemark pr) {
EvidenceElement ee = prs.getEvidenceElement(ProcessRemarkService.DEFAULT_EVIDENCE, ELEMENT_NAME_VALUE_KEY);
pr.addElement(ee);
}
use of org.asqatasun.entity.audit.EvidenceElement in project Asqatasun by Asqatasun.
the class Rgaa22Rule10121Test method setProcess.
@Override
protected void setProcess() {
//----------------------------------------------------------------------
//------------------------------3NMI-01------------------------------
//----------------------------------------------------------------------
ProcessResult processResult = processPageTest("Rgaa22.Test.10.12-3NMI-01");
// check test result
assertEquals(TestSolution.NEED_MORE_INFO, processResult.getValue());
// check test has no remark
assertNotNull(processResult.getRemarkSet());
// check number of elements in the page
assertEquals(1, processResult.getElementCounter());
// check type of remarks and their value
assertNotNull(processResult.getRemarkSet());
SourceCodeRemark processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next());
assertEquals(MANUAL_CHECK_ON_ELEMENTS_MSG, processRemark.getMessageCode());
// check number, type and value of evidence elements
assertEquals(2, processRemark.getElementList().size());
Iterator<EvidenceElement> iterator = processRemark.getElementList().iterator();
EvidenceElement ee = iterator.next();
assertEquals(TEXT_ELEMENT2, ee.getEvidence().getCode());
ee = iterator.next();
assertEquals(TITLE_ATTR, ee.getEvidence().getCode());
//----------------------------------------------------------------------
//------------------------------4NA-01------------------------------
//----------------------------------------------------------------------
processResult = processPageTest("Rgaa22.Test.10.12-4NA-01");
// check number of elements in the page
assertEquals(0, processResult.getElementCounter());
// check test result
assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue());
// check test has no remark
assertNull(processResult.getRemarkSet());
//----------------------------------------------------------------------
//------------------------------4NA-02------------------------------
//----------------------------------------------------------------------
processResult = processPageTest("Rgaa22.Test.10.12-4NA-02");
// check number of elements in the page
assertEquals(1, processResult.getElementCounter());
// check test result
assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue());
// check test has no remark
assertNull(processResult.getRemarkSet());
}
use of org.asqatasun.entity.audit.EvidenceElement in project Asqatasun by Asqatasun.
the class Rgaa22Rule06011Test method setProcess.
@Override
protected void setProcess() {
//----------------------------------------------------------------------
//------------------------------3NMI-01---------------------------------
//----------------------------------------------------------------------
ProcessResult processResult = processPageTest("RGAA22.Test.6.1-3NMI-01");
// check number of elements in the page
assertEquals(1, processResult.getElementCounter());
// check test result
assertEquals(TestSolution.NEED_MORE_INFO, processResult.getValue());
// check number of remarks and their value
assertEquals(1, processResult.getRemarkSet().size());
SourceCodeRemark processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next());
assertEquals(TestSolution.NEED_MORE_INFO, processRemark.getIssue());
assertEquals(RemarkMessageStore.MANUAL_CHECK_ON_ELEMENTS_MSG, processRemark.getMessageCode());
assertEquals(HtmlElementStore.IMG_ELEMENT, processRemark.getTarget());
assertNotNull(processRemark.getSnippet());
// check number of evidence elements and their value
assertEquals(1, processRemark.getElementList().size());
EvidenceElement ee = processRemark.getElementList().iterator().next();
assertTrue(StringUtils.contains(ee.getValue(), "mock-image.jpg"));
assertEquals(SRC_ATTR, ee.getEvidence().getCode());
//----------------------------------------------------------------------
//------------------------------3NMI-02---------------------------------
//----------------------------------------------------------------------
processResult = processPageTest("RGAA22.Test.6.1-3NMI-02");
// check number of elements in the page
assertEquals(1, processResult.getElementCounter());
// check test result
assertEquals(TestSolution.NEED_MORE_INFO, processResult.getValue());
// check number of remarks and their value
assertEquals(1, processResult.getRemarkSet().size());
processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next());
assertEquals(TestSolution.NEED_MORE_INFO, processRemark.getIssue());
assertEquals(RemarkMessageStore.MANUAL_CHECK_ON_ELEMENTS_MSG, processRemark.getMessageCode());
assertEquals(HtmlElementStore.INPUT_ELEMENT, processRemark.getTarget());
assertNotNull(processRemark.getSnippet());
// check number of evidence elements and their value
assertEquals(1, processRemark.getElementList().size());
ee = processRemark.getElementList().iterator().next();
assertTrue(StringUtils.contains(ee.getValue(), "mock-image.jpg"));
assertEquals(SRC_ATTR, ee.getEvidence().getCode());
//----------------------------------------------------------------------
//------------------------------4NA-01---------------------------------
//----------------------------------------------------------------------
processResult = processPageTest("RGAA22.Test.6.1-4NA-01");
// check test result
assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue());
// check test has no remark
assertNull(processResult.getRemarkSet());
// check number of elements in the page
assertEquals(0, processResult.getElementCounter());
//----------------------------------------------------------------------
//------------------------------4NA-01----------------------------------
//----------------------------------------------------------------------
processResult = processPageTest("RGAA22.Test.6.1-4NA-02");
// check test result
assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue());
// check test has no remark
assertNull(processResult.getRemarkSet());
// check number of elements in the page
assertEquals(0, processResult.getElementCounter());
}
Aggregations