use of org.sonar.api.batch.fs.internal.TestInputFileBuilder 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.TestInputFileBuilder 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.TestInputFileBuilder 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);
}
use of org.sonar.api.batch.fs.internal.TestInputFileBuilder in project sonarqube by SonarSource.
the class ModuleInputComponentStoreTest method should_get_empty_iterable_on_cache_miss.
@Test
public void should_get_empty_iterable_on_cache_miss() {
ModuleInputComponentStore store = newModuleInputComponentStore();
String ext = "java";
String filename = "Program." + ext;
InputFile inputFile = new TestInputFileBuilder(projectKey, "some/path/" + filename).build();
store.doAdd(inputFile);
assertThat(store.getFilesByName("nonexistent")).isEmpty();
assertThat(store.getFilesByExtension("nonexistent")).isEmpty();
}
use of org.sonar.api.batch.fs.internal.TestInputFileBuilder in project sonarqube by SonarSource.
the class DefaultBlameOutputTest method addWarningIfFilesMissing.
@Test
public void addWarningIfFilesMissing() {
InputFile file = new TestInputFileBuilder("foo", "src/main/java/Foo.java").setLines(10).build();
new DefaultBlameOutput(null, analysisWarnings, singletonList(file)).finish(true);
assertThat(analysisWarnings.warnings()).extracting(DefaultAnalysisWarnings.Message::getText).containsOnly("Missing blame information for 1 file. This may lead to some features not working correctly. " + "Please check the analysis logs and refer to <a href=\"/documentation/analysis/scm-integration/\" target=\"_blank\">the documentation</a>.");
}
Aggregations