]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5329 Display parameter
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 20 Jun 2014 10:35:04 +0000 (12:35 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 20 Jun 2014 11:06:28 +0000 (13:06 +0200)
sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileActivity.java
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog2.html.erb
sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileServiceMediumTest.java

index dc1b01339bb03d4eba27523c1bf9f67701901157..fb35bab419db8fa13e6cae7570521e9dd76d2b50 100644 (file)
@@ -44,6 +44,9 @@ public class QProfileActivity extends ActivityDoc implements Activity {
     for (Map.Entry detail : details.entrySet()) {
       fields.put((String) detail.getKey(), detail.getValue());
     }
+    if (!fields.containsKey("severity")) {
+      fields.put("severity", null);
+    }
   }
 
   @CheckForNull
@@ -77,8 +80,9 @@ public class QProfileActivity extends ActivityDoc implements Activity {
     return getNullableField(ActivityNormalizer.LogFields.LOGIN.field());
   }
 
+  @CheckForNull
   public String severity(){
-    return (String) getField("severity");
+    return (String) getNullableField("severity");
   }
 
   public Map<String, String> parameters() {
index 05cf3cf8ca243409bedb6a636c78b65154db70f9..96fd48b2d2d5053803bc4bcf46eea967a7b342f3 100644 (file)
         <td valign="top" width="1%" nowrap><%= change.authorName() ? change.authorName() : change.login() ? !change.login().emtpy? : 'System' %></td>
         <td valign="top" width="1%" nowrap><%= action_message %></td>
         <td valign="top"><%= change.ruleName() ? change.ruleName() : change.ruleKey() %></td>
-        <td valign="top"></td>
+        <td valign="top">
+          <% if change.severity() %>
+            <%= message('quality_profiles.severity_set_to_x', :params => ["<i class=\"icon-severity-#{change.severity().downcase}\"></i>", change.severity()]) -%>
+            <br/>
+          <% end %>
+          <% change.parameters().each do |param_key, param_value| %>
+            <%= message('quality_profiles.parameter_set_to_x', :params => [param_key, param_value]) -%>
+            <br/>
+          <% end %>
+        </td>
       </tr>
       <% end %>
     </table>
index d1a38a0ddf8ca4ffe5530f9cd77518b70055b9b4..b54d251dd0a71a0d54e71e40db05383c0399245c 100644 (file)
@@ -154,11 +154,34 @@ public class QProfileServiceMediumTest {
     assertThat(activity.action()).isEqualTo(ActiveRuleChange.Type.ACTIVATED.name());
     assertThat(activity.ruleKey()).isEqualTo(RuleTesting.XOO_X1);
     assertThat(activity.profileKey()).isEqualTo(XOO_P1_KEY);
-    assertThat(activity.parameters().get("max")).isEqualTo("10");
     assertThat(activity.severity()).isEqualTo(Severity.MAJOR);
     assertThat(activity.ruleName()).isEqualTo(rule.getName());
     assertThat(activity.login()).isEqualTo("me");
     assertThat(activity.authorName()).isNull();
+
+    assertThat(activity.parameters()).hasSize(1);
+    assertThat(activity.parameters().get("max")).isEqualTo("10");
+  }
+
+  @Test
+  public void search_qprofile_activity_without_severity() throws InterruptedException {
+    MockUserSession.set().setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN).setLogin("me");
+
+    RuleKey ruleKey = RuleKey.of("xoo", "deleted_rule");
+
+    tester.get(ActivityService.class).write(dbSession, Activity.Type.QPROFILE,
+      ActiveRuleChange.createFor(ActiveRuleChange.Type.UPDATED, ActiveRuleKey.of(XOO_P1_KEY, ruleKey))
+        .setParameter("max", "10")
+    );
+    dbSession.commit();
+
+    List<QProfileActivity> activities = service.findActivities(new QProfileActivityQuery(), new QueryOptions());
+    assertThat(activities).hasSize(1);
+
+    QProfileActivity activity = activities.get(0);
+    assertThat(activity.severity()).isNull();
+    assertThat(activity.parameters()).hasSize(1);
+    assertThat(activity.parameters().get("max")).isEqualTo("10");
   }
 
   @Test