Search in sources :

Example 31 with ProcessRemark

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

the class ProcessRemarkDataServiceMock method getProcessRemark.

@Override
public ProcessRemark getProcessRemark(TestSolution issue, String messageCode) {
    ProcessRemark pr = processRemarkFactory.create();
    pr.setIssue(issue);
    pr.setMessageCode(messageCode);
    return pr;
}
Also used : ProcessRemark(org.asqatasun.entity.audit.ProcessRemark)

Example 32 with ProcessRemark

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

the class SeoRule07013 method check.

@Override
protected void check(final SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    super.check(sspHandler, testSolutionHandler);
    ProcessRemarkService prs = sspHandler.getProcessRemarkService();
    if (CollectionUtils.isNotEmpty(prs.getRemarkList())) {
        for (ProcessRemark pr : prs.getRemarkList()) {
            addElementNameEvidenceElementToOverrideTarget(prs, pr);
        }
    }
}
Also used : ProcessRemark(org.asqatasun.entity.audit.ProcessRemark) ProcessRemarkService(org.asqatasun.service.ProcessRemarkService)

Example 33 with ProcessRemark

use of org.asqatasun.entity.audit.ProcessRemark 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)

Example 34 with ProcessRemark

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

the class ProcessRemarkFactoryImpl method create.

@Override
public ProcessRemark create(TestSolution issue, String messageCode) {
    ProcessRemark remark = this.create();
    remark.setIssue(issue);
    remark.setMessageCode(messageCode);
    return remark;
}
Also used : ProcessRemark(org.asqatasun.entity.audit.ProcessRemark)

Example 35 with ProcessRemark

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

the class Aw22Rule06034 method testLink.

/**
     * 
     * @param sspHandler
     * @param el
     * @return 
     */
private TestSolution testLink(SSPHandler sspHandler, Element el) {
    ElementHandler<Element> elHandler = new ElementHandlerImpl(el);
    TestSolutionHandler tsHandler = new TestSolutionHandlerImpl();
    // reset the service for each tested element. We use the collection 
    // handled by the service to feed the local collection of remarks
    prs.resetService();
    // check the pertinence of the link
    getDecidableElementsChecker().check(sspHandler, elHandler, tsHandler);
    // get the processRemark for eventually override it with the result
    // returned by the title pertinence checker
    ProcessRemark remark = prs.getRemarkList().iterator().next();
    // to nmi but the inverse is impossible.
    if (tsHandler.getTestSolution().equals(TestSolution.FAILED)) {
        // check the pertinence of the title of the link
        String linkText = getDecidableElementsChecker().getTextElementBuilder().buildTextFromElement(el);
        if (testTitleAttributeLink(sspHandler, el, linkText).equals(TestSolution.NEED_MORE_INFO)) {
            //override result (evidence element have already been collected
            remark.setIssue(TestSolution.NEED_MORE_INFO);
            remark.setMessageCode(CHECK_LINK_PERTINENCE_MSG);
            remarks.add(remark);
            return TestSolution.NEED_MORE_INFO;
        }
    }
    remarks.add(remark);
    return tsHandler.getTestSolution();
}
Also used : Element(org.jsoup.nodes.Element) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl) TestSolutionHandlerImpl(org.asqatasun.ruleimplementation.TestSolutionHandlerImpl) TestSolutionHandler(org.asqatasun.ruleimplementation.TestSolutionHandler) ProcessRemark(org.asqatasun.entity.audit.ProcessRemark)

Aggregations

ProcessRemark (org.asqatasun.entity.audit.ProcessRemark)56 ProcessResult (org.asqatasun.entity.audit.ProcessResult)41 SourceCodeRemark (org.asqatasun.entity.audit.SourceCodeRemark)31 LinkedHashSet (java.util.LinkedHashSet)23 ElementHandlerImpl (org.asqatasun.ruleimplementation.ElementHandlerImpl)6 TestSolutionHandler (org.asqatasun.ruleimplementation.TestSolutionHandler)6 TestSolutionHandlerImpl (org.asqatasun.ruleimplementation.TestSolutionHandlerImpl)6 Element (org.jsoup.nodes.Element)6 ProcessRemarkService (org.asqatasun.service.ProcessRemarkService)5 EvidenceElement (org.asqatasun.entity.audit.EvidenceElement)4