aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2016-03-08 19:58:49 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2016-03-10 10:44:17 +0100
commit0736f40a60b6a3bccbfb933de9bc9a57b950c6e8 (patch)
tree539750936843ee352ddbefa2f89725af1ea76100
parent5d1d0e52b2fcde16c3ff23adc6ea29752ee5cbd7 (diff)
downloadsonarqube-0736f40a60b6a3bccbfb933de9bc9a57b950c6e8.tar.gz
sonarqube-0736f40a60b6a3bccbfb933de9bc9a57b950c6e8.zip
SONAR-7345 Rename Issue debt to effort in changelog
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/IssueChangelog.java21
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/IssueUpdater.java4
-rw-r--r--server/sonar-server/src/main/resources/org/sonar/server/issue/ws/example-changelog.json2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/IssueChangelogServiceTest.java21
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/issue.rb4
-rw-r--r--sonar-core/src/main/resources/org/sonar/l10n/core.properties2
6 files changed, 43 insertions, 11 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueChangelog.java b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueChangelog.java
index add214786cf..d4beab689ad 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueChangelog.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueChangelog.java
@@ -20,13 +20,12 @@
package org.sonar.server.issue;
import com.google.common.collect.Maps;
-import org.sonar.core.issue.FieldDiffs;
-import org.sonar.api.user.User;
-
-import javax.annotation.CheckForNull;
import java.util.Collection;
import java.util.List;
import java.util.Map;
+import javax.annotation.CheckForNull;
+import org.sonar.api.user.User;
+import org.sonar.core.issue.FieldDiffs;
/**
* @since 3.6
@@ -38,6 +37,7 @@ public class IssueChangelog {
public IssueChangelog(List<FieldDiffs> changes, Collection<User> users) {
this.changes = changes;
+ replacedTechnicalDebtByEffort(changes);
this.usersByLogin = Maps.newHashMap();
for (User user : users) {
usersByLogin.put(user.login(), user);
@@ -48,6 +48,19 @@ public class IssueChangelog {
return changes;
}
+ private static void replacedTechnicalDebtByEffort(List<FieldDiffs> changes) {
+ for (FieldDiffs fieldDiffs : changes) {
+ Map<String, FieldDiffs.Diff> diffs = fieldDiffs.diffs();
+ for (Map.Entry<String, FieldDiffs.Diff> entry : diffs.entrySet()) {
+ // As "technicalDebt" couldn't been updated to "effort" in db, we need to convert it here to correctly display "effort" in WS/UI
+ if (entry.getKey().equals(IssueUpdater.TECHNICAL_DEBT)) {
+ diffs.put("effort", entry.getValue());
+ diffs.remove(entry.getKey());
+ }
+ }
+ }
+ }
+
@CheckForNull
public User user(FieldDiffs change) {
if (change.userLogin() == null) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueUpdater.java b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueUpdater.java
index ed7ce1737e5..c8a910ad14c 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueUpdater.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueUpdater.java
@@ -59,6 +59,10 @@ public class IssueUpdater {
public static final String STATUS = "status";
public static final String AUTHOR = "author";
public static final String ACTION_PLAN = "actionPlan";
+
+ /**
+ * It should be renamed to 'effort', but it hasn't been done to prevent a massive update in database
+ */
public static final String TECHNICAL_DEBT = "technicalDebt";
public static final String TAGS = "tags";
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/issue/ws/example-changelog.json b/server/sonar-server/src/main/resources/org/sonar/server/issue/ws/example-changelog.json
index 9ddd968d827..ae03e59ec97 100644
--- a/server/sonar-server/src/main/resources/org/sonar/server/issue/ws/example-changelog.json
+++ b/server/sonar-server/src/main/resources/org/sonar/server/issue/ws/example-changelog.json
@@ -6,7 +6,7 @@
"creationDate": "2014-03-04T23:03:44+0100",
"diffs": [
{
- "key": "technicalDebt",
+ "key": "effort",
"newValue": "2min"
}
]
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueChangelogServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueChangelogServiceTest.java
index 2086d17512c..d42f0d7c62b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueChangelogServiceTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueChangelogServiceTest.java
@@ -27,12 +27,12 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
-import org.sonar.core.issue.DefaultIssue;
-import org.sonar.core.issue.FieldDiffs;
import org.sonar.api.user.User;
import org.sonar.api.user.UserFinder;
-import org.sonar.db.issue.IssueChangeDao;
+import org.sonar.core.issue.DefaultIssue;
+import org.sonar.core.issue.FieldDiffs;
import org.sonar.core.user.DefaultUser;
+import org.sonar.db.issue.IssueChangeDao;
import org.sonar.server.tester.UserSessionRule;
import static org.assertj.core.api.Assertions.assertThat;
@@ -85,6 +85,21 @@ public class IssueChangelogServiceTest {
}
@Test
+ public void rename_technical_debt_change_to_effort() {
+ FieldDiffs userChange = new FieldDiffs().setUserLogin("arthur").setDiff("technicalDebt", "10min", "30min");
+ when(changeDao.selectChangelogByIssue("ABCDE")).thenReturn(Arrays.asList(userChange));
+ User arthur = new DefaultUser().setLogin("arthur").setName("Arthur");
+ when(userFinder.findByLogins(Arrays.asList("arthur"))).thenReturn(Arrays.asList(arthur));
+ when(issueService.getByKey("ABCDE")).thenReturn(new DefaultIssue().setKey("ABCDE"));
+
+ IssueChangelog changelog = service.changelog("ABCDE");
+
+ assertThat(changelog).isNotNull();
+ assertThat(changelog.changes()).hasSize(1);
+ assertThat(changelog.changes().get(0).diffs()).containsKeys("effort");
+ }
+
+ @Test
public void format_diffs() {
FieldDiffs diffs = new FieldDiffs().setUserLogin("arthur").setDiff("severity", "MAJOR", "BLOCKER");
userSessionRule.login();
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/issue.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/issue.rb
index 75494d55757..9904bf4dfdc 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/issue.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/issue.rb
@@ -83,8 +83,8 @@ class Issue
diff = entry.getValue()
hash_diff = {}
hash_diff[:key] = key
- if key == 'technicalDebt'
- # debt is store as a number of minutes in the changelog, so we first create a Duration from the value then we decode it
+ if key == 'effort'
+ # effort is store as a number of minutes in the changelog, so we first create a Duration from the value then we decode it
hash_diff[:newValue] = Internal.durations.encode(Internal.durations.create(diff.newValue().to_i)) if diff.newValue.present?
hash_diff[:oldValue] = Internal.durations.encode(Internal.durations.create(diff.oldValue().to_i)) if diff.oldValue.present?
else
diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
index 270bf9c9a62..460afafa78e 100644
--- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties
+++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
@@ -760,7 +760,7 @@ issue.changelog.field.actionPlan=Action Plan
issue.changelog.field.assignee=Assignee
issue.changelog.field.author=Author
issue.changelog.field.resolution=Resolution
-issue.changelog.field.technicalDebt=Technical Debt
+issue.changelog.field.effort=Effort
issue.changelog.field.status=Status
issue.changelog.field.tags=Tags
issue.changelog.field.type=Type