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;
}
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);
}
}
}
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());
}
}
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;
}
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();
}
Aggregations