]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7794 WS api/qualityprofiles/search return userUpdatedAt 1066/head
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Mon, 27 Jun 2016 22:14:09 +0000 (00:14 +0200)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 29 Jun 2016 09:07:55 +0000 (11:07 +0200)
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfile.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchDataLoader.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java
sonar-ws/src/main/protobuf/ws-qualityprofiles.proto

index b66740fe52f8eadbca7f66a0878f8cfb1800b997..6fd51d2e3c339d65403148f0b90b4c3a599549d0 100644 (file)
@@ -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
index d05b2c18604d79447e7375a4adce3267bb16dbbf..42eb3d3a0c4f53a8e8c38319e4497d8ffe4be0b4 100644 (file)
@@ -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()) {
index 2d60e4043e00055adc9789846c4240d564ada23c..60547d5f4dcf9f1a685189c32f48da1f8edfe5a1 100644 (file)
@@ -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());
     }
   }
 }
index fce69e72f2056f649b424fce2c82319afe6dbad1..9de141b1d934b06c5b15c7b87daa5b1613dfcf2d 100644 (file)
@@ -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
index 02e2392659580214d0c792c76d2c466861da2dd1..9b430fb0dbd63b65d2259f61a607285af9cb4707 100644 (file)
@@ -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
index 534b46c64a6a6eb3585ac7ed6dae77a65ec3ec54..0829180d46df857bdc774c83dc648531d8dfc0b4 100644 (file)
@@ -42,5 +42,6 @@ message SearchWsResponse {
     optional int64 projectCount = 10;
     optional string rulesUpdatedAt = 11;
     optional string lastUsed = 13;
+    optional string userUpdatedAt = 14;
   }
 }