From 626bdc83fbde6e6d0426f1a514700ea698b00778 Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Tue, 28 Jun 2016 00:14:09 +0200 Subject: [PATCH] SONAR-7794 WS api/qualityprofiles/search return userUpdatedAt --- .../org/sonar/server/qualityprofile/QProfile.java | 14 +++++++++++++- .../server/qualityprofile/ws/SearchAction.java | 3 +++ .../server/qualityprofile/ws/SearchDataLoader.java | 3 ++- .../sonar/server/qualityprofile/QProfileTest.java | 2 +- .../server/qualityprofile/ws/SearchActionTest.java | 4 +++- .../src/main/protobuf/ws-qualityprofiles.proto | 1 + 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=,name=Default,language=java,parent=Parent,isDefault=false,rulesUpdatedAt=,lastUsed=]"); + .contains("[id=1,key=,name=Default,language=java,parent=Parent,isDefault=false,rulesUpdatedAt=,lastUsed=,userUpdatedAt=]"); } @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; } } -- 2.39.5