Search in sources :

Example 16 with BlameLine

use of org.sonar.api.batch.scm.BlameLine in project sonarqube by SonarSource.

the class DefaultBlameOutputTest method shouldFailIfNullDate.

@Test
public void shouldFailIfNullDate() {
    InputFile file = new TestInputFileBuilder("foo", "src/main/java/Foo.java").setLines(1).build();
    var blameOutput = new DefaultBlameOutput(null, analysisWarnings, singletonList(file));
    var lines = singletonList(new BlameLine().revision("1").author("guy"));
    assertThatThrownBy(() -> blameOutput.blameResult(file, lines)).isInstanceOf(IllegalArgumentException.class).hasMessage("Blame date is null for file " + file + " at line 1");
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) BlameLine(org.sonar.api.batch.scm.BlameLine) InputFile(org.sonar.api.batch.fs.InputFile) Test(org.junit.Test)

Example 17 with BlameLine

use of org.sonar.api.batch.scm.BlameLine in project sonarqube by SonarSource.

the class DefaultBlameOutputTest method shouldFailIfNotExpectedFile.

@Test
public void shouldFailIfNotExpectedFile() {
    InputFile file = new TestInputFileBuilder("foo", "src/main/java/Foo.java").build();
    var blameOutput = new DefaultBlameOutput(null, analysisWarnings, singletonList(new TestInputFileBuilder("foo", "src/main/java/Foo2.java").build()));
    var lines = singletonList(new BlameLine().revision("1").author("guy"));
    assertThatThrownBy(() -> blameOutput.blameResult(file, lines)).isInstanceOf(IllegalArgumentException.class).hasMessage("It was not expected to blame file " + file);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) BlameLine(org.sonar.api.batch.scm.BlameLine) InputFile(org.sonar.api.batch.fs.InputFile) Test(org.junit.Test)

Aggregations

BlameLine (org.sonar.api.batch.scm.BlameLine)17 Test (org.junit.Test)12 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)12 InputFile (org.sonar.api.batch.fs.InputFile)10 File (java.io.File)9 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)9 Date (java.util.Date)7 BlameOutput (org.sonar.api.batch.scm.BlameCommand.BlameOutput)7 IOException (java.io.IOException)4 DefaultFileSystem (org.sonar.api.batch.fs.internal.DefaultFileSystem)4 Path (java.nio.file.Path)3 Arrays (java.util.Arrays)3 Collections.singletonList (java.util.Collections.singletonList)3 List (java.util.List)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Before (org.junit.Before)3 Rule (org.junit.Rule)3 TemporaryFolder (org.junit.rules.TemporaryFolder)3 ArgumentCaptor (org.mockito.ArgumentCaptor)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2