aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-06-28 00:14:09 +0200
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-06-29 11:07:55 +0200
commit626bdc83fbde6e6d0426f1a514700ea698b00778 (patch)
tree48125e29780307ec888e926540209aa5bc967b8f
parent1c92ea547e7a91585f419279dbf655cb44cc3164 (diff)
downloadsonarqube-626bdc83fbde6e6d0426f1a514700ea698b00778.tar.gz
sonarqube-626bdc83fbde6e6d0426f1a514700ea698b00778.zip
SONAR-7794 WS api/qualityprofiles/search return userUpdatedAt
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfile.java14
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchDataLoader.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java4
-rw-r--r--sonar-ws/src/main/protobuf/ws-qualityprofiles.proto1
6 files changed, 23 insertions, 4 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfile.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfile.java
index b66740fe52f..6fd51d2e3c3 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfile.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfile.java
@@ -35,6 +35,7 @@ public class QProfile {
private boolean isDefault;
private String rulesUpdatedAt;
private Long lastUsed;
+ private Long userUpdatedAt;
/**
* @deprecated in 4.4
@@ -122,6 +123,16 @@ public class QProfile {
return this;
}
+ @CheckForNull
+ public Long getUserUpdatedAt() {
+ return userUpdatedAt;
+ }
+
+ public QProfile setUserUpdatedAt(@Nullable Long userUpdatedAt) {
+ this.userUpdatedAt = userUpdatedAt;
+ return this;
+ }
+
public static QProfile from(QualityProfileDto dto) {
return new QProfile()
.setId(dto.getId())
@@ -131,7 +142,8 @@ public class QProfile {
.setParent(dto.getParentKee())
.setDefault(dto.isDefault())
.setRulesUpdatedAt(dto.getRulesUpdatedAt())
- .setLastUsed(dto.getLastUsed());
+ .setLastUsed(dto.getLastUsed())
+ .setUserUpdatedAt(dto.getUserUpdatedAt());
}
@Override
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java
index d05b2c18604..42eb3d3a0c4 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java
@@ -125,6 +125,9 @@ public class SearchAction implements QProfileWsAction {
if (profile.getLastUsed() != null) {
profileBuilder.setLastUsed(formatDateTime(profile.getLastUsed()));
}
+ if (profile.getUserUpdatedAt() != null) {
+ profileBuilder.setUserUpdatedAt(formatDateTime(profile.getUserUpdatedAt()));
+ }
profileBuilder.setActiveRuleCount(data.getActiveRuleCount(profileKey));
profileBuilder.setActiveDeprecatedRuleCount(data.getActiveDeprecatedRuleCount(profileKey));
if (!profile.isDefault()) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchDataLoader.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchDataLoader.java
index 2d60e4043e0..60547d5f4dc 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchDataLoader.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchDataLoader.java
@@ -245,7 +245,8 @@ public class SearchDataLoader {
.setLanguage(input.getLanguage())
.setDefault(input.isDefault())
.setRulesUpdatedAt(input.getRulesUpdatedAt())
- .setLastUsed(input.getLastUsed());
+ .setLastUsed(input.getLastUsed())
+ .setUserUpdatedAt(input.getUserUpdatedAt());
}
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileTest.java
index fce69e72f20..9de141b1d93 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileTest.java
@@ -38,7 +38,7 @@ public class QProfileTest {
@Test
public void to_string() {
assertThat(new QProfile().setId(1).setName("Default").setLanguage("java").setParent("Parent").toString())
- .contains("[id=1,key=<null>,name=Default,language=java,parent=Parent,isDefault=false,rulesUpdatedAt=<null>,lastUsed=<null>]");
+ .contains("[id=1,key=<null>,name=Default,language=java,parent=Parent,isDefault=false,rulesUpdatedAt=<null>,lastUsed=<null>,userUpdatedAt=<null>]");
}
@Test
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java
index 02e23926595..9b430fb0dbd 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java
@@ -131,13 +131,15 @@ public class SearchActionTest {
qualityProfileDb.insertQualityProfiles(newQualityProfileDto()
.setLanguage(xoo1.getKey())
.setRulesUpdatedAt("2016-12-21T19:10:03+0100")
- .setLastUsed(time));
+ .setLastUsed(time)
+ .setUserUpdatedAt(time));
SearchWsResponse result = call(ws.newRequest());
assertThat(result.getProfilesCount()).isEqualTo(1);
assertThat(result.getProfiles(0).getRulesUpdatedAt()).isEqualTo("2016-12-21T19:10:03+0100");
assertThat(parseDateTime(result.getProfiles(0).getLastUsed()).getTime()).isEqualTo(time);
+ assertThat(parseDateTime(result.getProfiles(0).getUserUpdatedAt()).getTime()).isEqualTo(time);
}
@Test
diff --git a/sonar-ws/src/main/protobuf/ws-qualityprofiles.proto b/sonar-ws/src/main/protobuf/ws-qualityprofiles.proto
index 534b46c64a6..0829180d46d 100644
--- a/sonar-ws/src/main/protobuf/ws-qualityprofiles.proto
+++ b/sonar-ws/src/main/protobuf/ws-qualityprofiles.proto
@@ -42,5 +42,6 @@ message SearchWsResponse {
optional int64 projectCount = 10;
optional string rulesUpdatedAt = 11;
optional string lastUsed = 13;
+ optional string userUpdatedAt = 14;
}
}