Search in sources :

Example 66 with EvidenceElement

use of org.asqatasun.entity.audit.EvidenceElement in project Asqatasun by Asqatasun.

the class Rgaa22Rule04011Test method setProcess.

@Override
protected void setProcess() {
    //----------------------------------------------------------------------
    //------------------------------1Passed-01------------------------------
    //----------------------------------------------------------------------
    ProcessResult processResult = processPageTest("RGAA22.Test.4.1-1Passed-01");
    // check number of elements in the page
    assertEquals(1, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check number of remarks and their value
    assertNull(processResult.getRemarkSet());
    //----------------------------------------------------------------------
    //------------------------------1Passed-02------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-1Passed-02");
    // check number of elements in the page
    assertEquals(3, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check number of remarks and their value
    assertNull(processResult.getRemarkSet());
    //----------------------------------------------------------------------
    //------------------------------1Passed-03------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-1Passed-03");
    // check number of elements in the page
    assertEquals(3, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check number of remarks and their value
    assertNull(processResult.getRemarkSet());
    //----------------------------------------------------------------------
    //------------------------------1Passed-04------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-1Passed-04");
    // check number of elements in the page
    assertEquals(3, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check number of remarks and their value
    assertNull(processResult.getRemarkSet());
    //----------------------------------------------------------------------
    //------------------------------1Passed-05------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-1Passed-05");
    // check number of elements in the page
    assertEquals(1, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check number of remarks and their value
    assertNull(processResult.getRemarkSet());
    //----------------------------------------------------------------------
    //------------------------------1Passed-06------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-1Passed-06");
    // check number of elements in the page
    assertEquals(1, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check number of remarks and their value
    assertNull(processResult.getRemarkSet());
    //----------------------------------------------------------------------
    //------------------------------1Passed-07------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-1Passed-07");
    // check number of elements in the page
    assertEquals(1, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.PASSED, processResult.getValue());
    // check number of remarks and their value
    assertNull(processResult.getRemarkSet());
    //----------------------------------------------------------------------
    //------------------------------2Failed-01------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-2Failed-01");
    // check number of elements in the page
    assertEquals(1, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.FAILED, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    SourceCodeRemark processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next());
    assertEquals(RemarkMessageStore.ALT_MISSING_MSG, processRemark.getMessageCode());
    assertEquals(TestSolution.FAILED, processRemark.getIssue());
    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();
    assertEquals(SRC_ATTR, ee.getEvidence().getCode());
    assertTrue(StringUtils.contains(ee.getValue(), "mock-image-failed.jpg"));
    //----------------------------------------------------------------------
    //------------------------------2Failed-02------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-2Failed-02");
    // check number of elements in the page
    assertEquals(2, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.FAILED, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next());
    assertEquals(RemarkMessageStore.ALT_MISSING_MSG, processRemark.getMessageCode());
    assertEquals(TestSolution.FAILED, processRemark.getIssue());
    assertEquals(HtmlElementStore.IMG_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-failed.jpg"));
    assertEquals(SRC_ATTR, ee.getEvidence().getCode());
    //----------------------------------------------------------------------
    //------------------------------2Failed-03------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-2Failed-03");
    // check number of elements in the page
    assertEquals(2, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.FAILED, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next());
    assertEquals(RemarkMessageStore.ALT_MISSING_MSG, processRemark.getMessageCode());
    assertEquals(TestSolution.FAILED, processRemark.getIssue());
    assertEquals(HtmlElementStore.IMG_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-failed.jpg"));
    assertEquals(SRC_ATTR, ee.getEvidence().getCode());
    //----------------------------------------------------------------------
    //------------------------------2Failed-04------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-2Failed-04");
    // check number of elements in the page
    assertEquals(3, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.FAILED, processResult.getValue());
    // check number of remarks and their value
    assertEquals(2, processResult.getRemarkSet().size());
    processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next());
    assertEquals(RemarkMessageStore.ALT_MISSING_MSG, processRemark.getMessageCode());
    assertEquals(TestSolution.FAILED, processRemark.getIssue());
    assertEquals(HtmlElementStore.AREA_ELEMENT, processRemark.getTarget());
    assertNotNull(processRemark.getSnippet());
    // check number of evidence elements and their value
    assertEquals(1, processRemark.getElementList().size());
    ee = processRemark.getElementList().iterator().next();
    assertEquals(ABSENT_ATTRIBUTE_VALUE, ee.getValue());
    assertEquals(HREF_ATTR, ee.getEvidence().getCode());
    //----------------------------------------------------------------------
    //------------------------------2Failed-05------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-2Failed-05");
    // check number of elements in the page
    assertEquals(3, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.FAILED, processResult.getValue());
    // check number of remarks and their value
    assertEquals(2, processResult.getRemarkSet().size());
    processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next());
    assertEquals(RemarkMessageStore.ALT_MISSING_MSG, processRemark.getMessageCode());
    assertEquals(TestSolution.FAILED, processRemark.getIssue());
    assertEquals(HtmlElementStore.AREA_ELEMENT, processRemark.getTarget());
    assertNotNull(processRemark.getSnippet());
    // check number of evidence elements and their value
    assertEquals(1, processRemark.getElementList().size());
    ee = processRemark.getElementList().iterator().next();
    assertEquals(ABSENT_ATTRIBUTE_VALUE, ee.getValue());
    assertEquals(HREF_ATTR, ee.getEvidence().getCode());
    //----------------------------------------------------------------------
    //------------------------------2Failed-06------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-2Failed-06");
    // check number of elements in the page
    assertEquals(3, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.FAILED, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next());
    assertEquals(RemarkMessageStore.ALT_MISSING_MSG, processRemark.getMessageCode());
    assertEquals(TestSolution.FAILED, processRemark.getIssue());
    assertEquals(HtmlElementStore.AREA_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-area-link.html"));
    assertEquals(HREF_ATTR, ee.getEvidence().getCode());
    //----------------------------------------------------------------------
    //------------------------------2Failed-07------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-2Failed-07");
    // check number of elements in the page
    assertEquals(1, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.FAILED, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next());
    assertEquals(RemarkMessageStore.ALT_MISSING_MSG, processRemark.getMessageCode());
    assertEquals(TestSolution.FAILED, processRemark.getIssue());
    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();
    assertEquals(ABSENT_ATTRIBUTE_VALUE, ee.getValue());
    assertEquals(SRC_ATTR, ee.getEvidence().getCode());
    //----------------------------------------------------------------------
    //------------------------------2Failed-08------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-2Failed-08");
    // check number of elements in the page
    assertEquals(2, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.FAILED, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next());
    assertEquals(RemarkMessageStore.ALT_MISSING_MSG, processRemark.getMessageCode());
    assertEquals(TestSolution.FAILED, processRemark.getIssue());
    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-input-src.jpg"));
    assertEquals(SRC_ATTR, ee.getEvidence().getCode());
    //----------------------------------------------------------------------
    //------------------------------2Failed-09------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-2Failed-09");
    // check number of elements in the page
    assertEquals(1, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.FAILED, processResult.getValue());
    // check number of remarks and their value
    assertEquals(1, processResult.getRemarkSet().size());
    processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next());
    assertEquals(TestSolution.FAILED, processRemark.getIssue());
    assertEquals(HtmlElementStore.APPLET_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.class"));
    assertEquals(CODE_ATTR, ee.getEvidence().getCode());
    //----------------------------------------------------------------------
    //------------------------------4NA-01----------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-4NA-01");
    // check number of elements in the page
    assertEquals(0, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue());
    // check number of remarks and their value
    assertNull(processResult.getRemarkSet());
    //----------------------------------------------------------------------
    //------------------------------4NA-02----------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-4NA-02");
    // check number of elements in the page
    assertEquals(0, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue());
    // check number of remarks and their value
    assertNull(processResult.getRemarkSet());
    //----------------------------------------------------------------------
    //------------------------------4NA-03----------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-4NA-03");
    // check number of elements in the page
    assertEquals(0, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue());
    // check number of remarks and their value
    assertNull(processResult.getRemarkSet());
    //----------------------------------------------------------------------
    //------------------------------4NA-04----------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-4NA-04");
    // check number of elements in the page
    assertEquals(0, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue());
    // check number of remarks and their value
    assertNull(processResult.getRemarkSet());
    //----------------------------------------------------------------------
    //------------------------------4NA-05----------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-4NA-05");
    // check number of elements in the page
    assertEquals(0, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue());
    // check number of remarks and their value
    assertNull(processResult.getRemarkSet());
    //----------------------------------------------------------------------
    //------------------------------4NA-06----------------------------------
    //----------------------------------------------------------------------
    processResult = processPageTest("RGAA22.Test.4.1-4NA-06");
    // check number of elements in the page
    assertEquals(0, processResult.getElementCounter());
    // check test result
    assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue());
    // check number of remarks and their value
    assertNull(processResult.getRemarkSet());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) EvidenceElement(org.asqatasun.entity.audit.EvidenceElement) ProcessResult(org.asqatasun.entity.audit.ProcessResult) SourceCodeRemark(org.asqatasun.entity.audit.SourceCodeRemark)

Example 67 with EvidenceElement

use of org.asqatasun.entity.audit.EvidenceElement in project Asqatasun by Asqatasun.

the class Rgaa30Rule090104 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);
}
Also used : EvidenceElement(org.asqatasun.entity.audit.EvidenceElement)

Example 68 with EvidenceElement

use of org.asqatasun.entity.audit.EvidenceElement in project Asqatasun by Asqatasun.

the class AbstractRuleImplementationTestCase method checkRemarkIsPresent.

/**
     * 
     * @param processResult
     * @param testSolution
     * @param remarkMessageCode
     * @param remarkTarget
     * @param position
     * @param emptySnippet
     * @param evidencePairs 
     */
protected void checkRemarkIsPresent(ProcessResult processResult, TestSolution testSolution, String remarkMessageCode, String remarkTarget, int position, boolean emptySnippet, Pair<String, String>... evidencePairs) {
    if (((LinkedHashSet) processResult.getRemarkSet()).toArray()[position - 1] instanceof SourceCodeRemark) {
        SourceCodeRemark sourceCodeRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).toArray()[position - 1]);
        Logger.getLogger(this.getClass()).debug(sourceCodeRemark.getMessageCode());
        assertEquals(remarkMessageCode, sourceCodeRemark.getMessageCode());
        assertEquals(testSolution, sourceCodeRemark.getIssue());
        Logger.getLogger(this.getClass()).debug(sourceCodeRemark.getIssue());
        if (remarkTarget.equals("EMPTY_TARGET")) {
            assertEquals(-1, sourceCodeRemark.getLineNumber());
        } else {
            assertEquals(remarkTarget, sourceCodeRemark.getTarget());
            Logger.getLogger(this.getClass()).debug(sourceCodeRemark.getTarget());
            if (!emptySnippet) {
                assertNotNull("Snippet is empty but shouldn't !!! ", sourceCodeRemark.getSnippet());
            }
        }
        if (evidencePairs.length == 0) {
            assertNull("Evidence Element list is not empty but should be !!! ", sourceCodeRemark.getElementList());
            return;
        }
        // check number of evidence elements and their value
        assertEquals(evidencePairs.length, sourceCodeRemark.getElementList().size());
        Object[] evEls = sourceCodeRemark.getElementList().toArray();
        for (int i = 0; i < evEls.length; i++) {
            EvidenceElement ee = (EvidenceElement) evEls[i];
            Logger.getLogger(this.getClass()).debug(ee.getEvidence().getCode());
            Logger.getLogger(this.getClass()).debug(ee.getValue());
            assertEquals(evidencePairs[i].getLeft(), ee.getEvidence().getCode());
            assertTrue("Wrong evidence element : expected[" + evidencePairs[i].getRight() + "] actual[" + ee.getValue() + "]", StringUtils.contains(ee.getValue(), evidencePairs[i].getRight()));
        }
    } else {
        ProcessRemark processRemark = (ProcessRemark) (((LinkedHashSet) processResult.getRemarkSet()).toArray()[position - 1]);
        Logger.getLogger(this.getClass()).debug(processRemark.getMessageCode());
        assertEquals(remarkMessageCode, processRemark.getMessageCode());
        assertEquals(testSolution, processRemark.getIssue());
        assertNull(processRemark.getElementList());
    }
}
Also used : EvidenceElement(org.asqatasun.entity.audit.EvidenceElement) SourceCodeRemark(org.asqatasun.entity.audit.SourceCodeRemark) ProcessRemark(org.asqatasun.entity.audit.ProcessRemark)

Aggregations

EvidenceElement (org.asqatasun.entity.audit.EvidenceElement)68 ProcessResult (org.asqatasun.entity.audit.ProcessResult)53 SourceCodeRemark (org.asqatasun.entity.audit.SourceCodeRemark)53 LinkedHashSet (java.util.LinkedHashSet)22 ProcessRemark (org.asqatasun.entity.audit.ProcessRemark)4 ArrayList (java.util.ArrayList)3 DomElement (org.asqatasun.rules.domelement.DomElement)2 Element (org.jsoup.nodes.Element)2 CascadingStyleSheet (com.phloc.css.decl.CascadingStyleSheet)1 File (java.io.File)1 IOException (java.io.IOException)1 CSSParserExceptionHandlerImpl (org.asqatasun.contentadapter.css.CSSParserExceptionHandlerImpl)1 StylesheetContent (org.asqatasun.entity.audit.StylesheetContent)1 TestSolution (org.asqatasun.entity.audit.TestSolution)1 ContrastCheckerParseResultException (org.asqatasun.rules.elementchecker.contrast.exception.ContrastCheckerParseResultException)1