use of org.sonar.java.model.VisitorsBridge in project sonar-java by SonarSource.
the class JavaTypeTest method test_fully_qualified_name.
@Test
public void test_fully_qualified_name() {
File bytecodeDir = new File("target/test-classes");
ClassFullQualifiedNameVerifierVisitor visitor = new ClassFullQualifiedNameVerifierVisitor(bytecodeDir);
JavaAstScanner.scanSingleFileForTests(new File("src/test/java/org/sonar/java/resolve/targets/FullyQualifiedName.java"), new VisitorsBridge(Collections.singletonList(visitor), Lists.newArrayList(bytecodeDir), null));
}
use of org.sonar.java.model.VisitorsBridge in project sonar-java by SonarSource.
the class PackageInfoCheckTest method testNoPackageInfo.
@Test
public void testNoPackageInfo() throws Exception {
PackageInfoCheck check = new PackageInfoCheck();
JavaAstScanner.scanSingleFileForTests(new File("src/test/files/checks/packageInfo/nopackageinfo/nopackageinfo.java"), new VisitorsBridge(check));
JavaAstScanner.scanSingleFileForTests(new File("src/test/files/checks/packageInfo/nopackageinfo/HelloWorld.java"), new VisitorsBridge(check));
Set<File> set = check.directoriesWithoutPackageFile;
assertThat(set).hasSize(1);
assertThat(set.iterator().next().getName()).isEqualTo("nopackageinfo");
}
use of org.sonar.java.model.VisitorsBridge in project sonar-java by SonarSource.
the class PackageInfoCheckTest method test.
@Test
public void test() throws Exception {
PackageInfoCheck check = new PackageInfoCheck();
JavaAstScanner.scanSingleFileForTests(new File("src/test/files/checks/packageInfo/HelloWorld.java"), new VisitorsBridge(check));
assertThat(check.directoriesWithoutPackageFile).isEmpty();
}
use of org.sonar.java.model.VisitorsBridge in project sonar-java by SonarSource.
the class AbstractMethodDetectionTest method withoutParameter.
@Test
public void withoutParameter() throws Exception {
Visitor visitor = new Visitor(ImmutableList.of(MethodMatcher.create().typeDefinition("A").name("method").withoutParameter()));
JavaAstScanner.scanSingleFileForTests(new File("src/test/files/checks/AbstractMethodDetection.java"), new VisitorsBridge(visitor));
assertThat(visitor.lines).containsExactly(14);
}
use of org.sonar.java.model.VisitorsBridge in project sonar-java by SonarSource.
the class AbstractMethodDetectionTest method detected.
@Test
public void detected() {
Visitor visitor = new Visitor(ImmutableList.of(MethodMatcher.create().typeDefinition("A").name("method").addParameter("int"), MethodMatcher.create().typeDefinition("A").name("method").addParameter("java.lang.String[]")));
JavaAstScanner.scanSingleFileForTests(new File("src/test/files/checks/AbstractMethodDetection.java"), new VisitorsBridge(visitor));
assertThat(visitor.lines).hasSize(2);
assertThat(visitor.lines).containsExactly(15, 17);
}
Aggregations