use of org.sonar.api.batch.fs.internal.DefaultInputFile in project sonarqube by SonarSource.
the class GenericTestExecutionReportParserTest method file_without_language_should_be_skipped.
@Test
public void file_without_language_should_be_skipped() throws Exception {
String filePath = "src/main/java/com/example/EmptyClass.java";
DefaultInputFile file = new TestInputFileBuilder(context.module().key(), filePath).setLanguage(null).setType(InputFile.Type.TEST).initMetadata("1\n2\n3\n4\n5\n6").build();
addFileToFs(file);
GenericTestExecutionReportParser parser = parseReportFile("unittest.xml");
assertThat(parser.numberOfMatchedFiles()).isZero();
assertThat(parser.numberOfUnknownFiles()).isEqualTo(2);
assertThat(parser.firstUnknownFiles()).hasSize(2);
assertThat(logs.logs()).contains("Skipping file 'src/main/java/com/example/EmptyClass.java' in the generic test execution report because it doesn't have a known language");
}
use of org.sonar.api.batch.fs.internal.DefaultInputFile in project sonarqube by SonarSource.
the class SvnBlameCommandTest method shouldNotFailIfFileContainsLocalModification.
@Test
public void shouldNotFailIfFileContainsLocalModification() throws Exception {
File repoDir = unzip("repo-svn.zip");
String scmUrl = "file:///" + unixPath(new File(repoDir, "repo-svn"));
File baseDir = new File(checkout(scmUrl), "dummy-svn");
when(fs.baseDir()).thenReturn(baseDir);
DefaultInputFile inputFile = new TestInputFileBuilder("foo", DUMMY_JAVA).setLines(28).setModuleBaseDir(baseDir.toPath()).build();
Files.write(baseDir.toPath().resolve(DUMMY_JAVA), "\n//foo".getBytes(), StandardOpenOption.APPEND);
BlameOutput blameResult = mock(BlameOutput.class);
when(input.filesToBlame()).thenReturn(singletonList(inputFile));
newSvnBlameCommand().blame(input, blameResult);
verifyNoInteractions(blameResult);
}
use of org.sonar.api.batch.fs.internal.DefaultInputFile in project sonarqube by SonarSource.
the class SvnBlameCommandTest method shouldNotFailOnWrongFilename.
// SONARSCSVN-7
@Test
public void shouldNotFailOnWrongFilename() throws Exception {
File repoDir = unzip("repo-svn.zip");
String scmUrl = "file:///" + unixPath(new File(repoDir, "repo-svn"));
File baseDir = new File(checkout(scmUrl), "dummy-svn");
when(fs.baseDir()).thenReturn(baseDir);
DefaultInputFile inputFile = new TestInputFileBuilder("foo", DUMMY_JAVA.toLowerCase()).setLines(27).setModuleBaseDir(baseDir.toPath()).build();
BlameOutput blameResult = mock(BlameOutput.class);
when(input.filesToBlame()).thenReturn(singletonList(inputFile));
newSvnBlameCommand().blame(input, blameResult);
verifyNoInteractions(blameResult);
}
use of org.sonar.api.batch.fs.internal.DefaultInputFile in project sonarqube by SonarSource.
the class SvnBlameCommandTest method testParsingOfOutputWithMergeHistory.
@Test
public void testParsingOfOutputWithMergeHistory() throws Exception {
File repoDir = unzip("repo-svn-with-merge.zip");
String scmUrl = "file:///" + unixPath(new File(repoDir, "repo-svn"));
File baseDir = new File(checkout(scmUrl), "dummy-svn/trunk");
when(fs.baseDir()).thenReturn(baseDir);
DefaultInputFile inputFile = new TestInputFileBuilder("foo", DUMMY_JAVA).setLines(27).setModuleBaseDir(baseDir.toPath()).build();
BlameOutput blameResult = mock(BlameOutput.class);
when(input.filesToBlame()).thenReturn(singletonList(inputFile));
newSvnBlameCommand().blame(input, blameResult);
ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class);
verify(blameResult).blameResult(eq(inputFile), captor.capture());
List<BlameLine> result = captor.getValue();
assertThat(result).hasSize(27);
Date commitDate = new Date(1342691097393L);
Date revision6Date = new Date(1415262184300L);
BlameLine[] expected = IntStream.rangeClosed(1, 27).mapToObj(i -> {
if (i == 2 || i == 24) {
return new BlameLine().date(revision6Date).revision("6").author("henryju");
} else {
return new BlameLine().date(commitDate).revision("2").author("dgageot");
}
}).toArray(BlameLine[]::new);
assertThat(result).containsExactly(expected);
}
use of org.sonar.api.batch.fs.internal.DefaultInputFile in project sonarqube by SonarSource.
the class SvnBlameCommandTest method shouldNotFailOnUncommitedFile.
@Test
public void shouldNotFailOnUncommitedFile() throws Exception {
File repoDir = unzip("repo-svn.zip");
String scmUrl = "file:///" + unixPath(new File(repoDir, "repo-svn"));
File baseDir = new File(checkout(scmUrl), "dummy-svn");
when(fs.baseDir()).thenReturn(baseDir);
String relativePath = "src/main/java/org/dummy/Dummy2.java";
DefaultInputFile inputFile = new TestInputFileBuilder("foo", relativePath).setLines(28).setModuleBaseDir(baseDir.toPath()).build();
Files.write(baseDir.toPath().resolve(relativePath), "package org.dummy;\npublic class Dummy2 {}".getBytes());
BlameOutput blameResult = mock(BlameOutput.class);
when(input.filesToBlame()).thenReturn(singletonList(inputFile));
newSvnBlameCommand().blame(input, blameResult);
verifyNoInteractions(blameResult);
}
Aggregations