aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-10-09 12:02:32 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-10-09 12:02:32 +0200
commitfde900a0be3a5ec99d0b6dfcde4cf18d531210f6 (patch)
treee9db39dac2810cc1138ebf38d73ff11817c3e054 /sonar-batch
parent1f2c767187d23d71f2af67a2c1686eb849f3c717 (diff)
downloadsonarqube-fde900a0be3a5ec99d0b6dfcde4cf18d531210f6.tar.gz
sonarqube-fde900a0be3a5ec99d0b6dfcde4cf18d531210f6.zip
Fix some quality flaws
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameResult.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scm/DefaultBlameResultTest.java46
2 files changed, 49 insertions, 3 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameResult.java b/sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameResult.java
index 905f7c01f45..93269c7a32a 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameResult.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameResult.java
@@ -60,10 +60,10 @@ class DefaultBlameResult implements BlameResult {
int lineNumber = 1;
for (BlameLine line : lines) {
- authors.add(lineNumber, normalizeString(line.getAuthor()));
- Date date = line.getDate();
+ authors.add(lineNumber, normalizeString(line.author()));
+ Date date = line.date();
dates.add(lineNumber, date != null ? DateUtils.formatDateTime(date) : "");
- revisions.add(lineNumber, line.getRevision());
+ revisions.add(lineNumber, line.revision());
lineNumber++;
}
ScmSensor.saveMeasures(context, file, authors.buildData(), dates.buildData(), revisions.buildData());
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scm/DefaultBlameResultTest.java b/sonar-batch/src/test/java/org/sonar/batch/scm/DefaultBlameResultTest.java
new file mode 100644
index 00000000000..c64f7ebc6ee
--- /dev/null
+++ b/sonar-batch/src/test/java/org/sonar/batch/scm/DefaultBlameResultTest.java
@@ -0,0 +1,46 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.batch.scm;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
+import org.sonar.api.batch.scm.BlameLine;
+
+import java.util.Arrays;
+
+public class DefaultBlameResultTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void shouldFailIfNotSameNumberOfLines() {
+ InputFile file = new DefaultInputFile("foo", "src/main/java/Foo.java").setLines(10);
+
+ thrown.expect(IllegalArgumentException.class);
+ thrown.expectMessage("Expected one blame result per line but provider returned 1 blame lines while file has 10 lines");
+
+ new DefaultBlameResult(null).add(file, Arrays.asList(new BlameLine(null, "1", "guy")));
+ }
+
+}