use of org.sonar.plugins.html.node.Node in project sonar-web by SonarSource.
the class VueLexerTest method testMultipleTemplates.
@Test
public void testMultipleTemplates() {
String fragment = "<template><foo/><bar/><baz/></template><template><qux/></template>";
StringReader reader = new StringReader(fragment);
VueLexer lexer = new VueLexer();
List<Node> nodeList = lexer.parse(reader);
assertThat(nodeList).hasSize(3);
}
use of org.sonar.plugins.html.node.Node in project sonar-web by SonarSource.
the class VueLexerTest method commentedTemplate.
@Test
public void commentedTemplate() {
String fragment = "<!-- <template><foo/><bar/></template> -->";
StringReader reader = new StringReader(fragment);
VueLexer lexer = new VueLexer();
List<Node> nodeList = lexer.parse(reader);
assertThat(nodeList).isEmpty();
}
use of org.sonar.plugins.html.node.Node in project sonar-web by SonarSource.
the class VueLexerTest method testFilledTemplate.
@Test
public void testFilledTemplate() {
String fragment = "<template>" + "<!-- some HTML code here -->" + "<p>Hello, World!</p>" + "<div>" + "Hello, again!" + "<ul>" + "<li>foo</li>" + "<li>bar</li>" + "</ul>" + "</div>" + "</template>";
StringReader reader = new StringReader(fragment);
VueLexer lexer = new VueLexer();
List<Node> nodeList = lexer.parse(reader);
assertThat(nodeList).hasSize(15);
}
use of org.sonar.plugins.html.node.Node in project sonar-web by SonarSource.
the class NoSonarScannerTest method scanNoSonar.
@Test
public void scanNoSonar() throws Exception {
List<Node> nodeList;
try (Reader reader = new StringReader(CONTENT)) {
nodeList = new PageLexer().parse(reader);
}
InputFile inputFile = new TestInputFileBuilder("key", "dummy.jsp").setContents(CONTENT).setCharset(StandardCharsets.UTF_8).build();
NoSonarFilter noSonarFilter = spy(new NoSonarFilter());
HtmlAstScanner pageScanner = new HtmlAstScanner(Collections.emptyList());
pageScanner.addVisitor(new NoSonarScanner(noSonarFilter));
pageScanner.scan(nodeList, new HtmlSourceCode(inputFile));
verify(noSonarFilter, times(1)).noSonarInFile(eq(inputFile), argThat(new IsOnlyIgnoringLine2()));
}
Aggregations