use of org.asqatasun.contentadapter.css.CSSParserExceptionHandlerImpl 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);
}
}
Aggregations