@Test public void simpleJavaWithBytecode() throws Exception { ClientInputFile inputFile = TestUtils.createInputFile( new File("src/test/projects/java-with-bytecode/src/Foo.java") .getAbsoluteFile() .toPath(), false); final List<Issue> issues = new ArrayList<>(); sonarlint.analyze( new StandaloneAnalysisConfiguration( baseDir.toPath(), temp.newFolder().toPath(), Arrays.asList(inputFile), ImmutableMap.of( "sonar.java.binaries", new File("src/test/projects/java-with-bytecode/bin").getAbsolutePath())), issue -> issues.add(issue)); assertThat(issues) .extracting("ruleKey", "startLine", "inputFile.path") .containsOnly( tuple("squid:S106", 5, inputFile.getPath()), tuple("squid:S1220", null, inputFile.getPath()), tuple("squid:UndocumentedApi", 1, inputFile.getPath()), tuple("squid:UndocumentedApi", 3, inputFile.getPath()), tuple("squid:UnusedPrivateMethod", 8, inputFile.getPath()), tuple("squid:S1186", 8, inputFile.getPath())); }
private ClientInputFile prepareInputFile( String relativePath, String content, final boolean isTest, Charset encoding) throws IOException { final File file = new File(baseDir, relativePath); FileUtils.write(file, content, encoding); ClientInputFile inputFile = TestUtils.createInputFile(file.toPath(), isTest, encoding); return inputFile; }