]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Mon, 27 Jan 2014 09:18:19 +0000 (10:18 +0100)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Mon, 27 Jan 2014 09:18:27 +0000 (10:18 +0100)
sonar-server/src/main/java/org/sonar/server/rule/Rule.java
sonar-server/src/test/java/org/sonar/server/rule/RuleRegistryTest.java
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistryTest/shared/rule1.json

index d41b37c00e619bc887d2a0fd0572d3b34341edcd..a4080016cda24d82b2042bb73d2c3904158d1a12 100644 (file)
@@ -54,7 +54,9 @@ public class Rule {
   public Rule(Map<String, Object> ruleSource) {
     id = (Integer) ruleSource.get(RuleDocument.FIELD_ID);
     key = (String) ruleSource.get(RuleDocument.FIELD_KEY);
+    language = (String) ruleSource.get(RuleDocument.FIELD_LANGUAGE);
     repositoryKey = (String) ruleSource.get(RuleDocument.FIELD_REPOSITORY_KEY);
+    severity = (String) ruleSource.get(RuleDocument.FIELD_SEVERITY);
     name = (String) ruleSource.get(RuleDocument.FIELD_NAME);
     description = (String) ruleSource.get(RuleDocument.FIELD_DESCRIPTION);
     status = (String) ruleSource.get(RuleDocument.FIELD_STATUS);
index 879dc838fbaa2b465104afa1dc56999cf871cb55..cedbb446375a659e436dfb68e08e17ce04c75923 100644 (file)
@@ -76,7 +76,9 @@ public class RuleRegistryTest {
   public void setUp() throws Exception {
     when(myBatis.openSession()).thenReturn(session);
 
-    esSetup = new EsSetup(ImmutableSettings.builder().loadFromUrl(ESNode.class.getResource("config/elasticsearch.json")).build());
+    esSetup = new EsSetup(ImmutableSettings.builder().loadFromUrl(ESNode.class.getResource("config/elasticsearch.json"))
+      .put("http.port", "9200")
+      .build());
     esSetup.execute(EsSetup.deleteAll());
 
     ESNode node = mock(ESNode.class);
@@ -96,6 +98,7 @@ public class RuleRegistryTest {
       EsSetup.index("rules", "rule", "2").withSource(testFileAsString("shared/rule2.json")),
       EsSetup.index("rules", "rule", "3").withSource(testFileAsString("shared/rule3.json"))
     );
+    esSetup.client().admin().cluster().prepareHealth(RuleRegistry.INDEX_RULES).setWaitForGreenStatus().execute().actionGet();
   }
 
   @After
@@ -113,12 +116,15 @@ public class RuleRegistryTest {
 
   @Test
   public void should_find_rule_by_key() {
-    assertThat(registry.findByKey(RuleKey.of("unknown", "OneIssuePerLine"))).isNull();
+    assertThat(registry.findByKey(RuleKey.of("unknown", "RuleWithParameters"))).isNull();
     assertThat(registry.findByKey(RuleKey.of("xoo", "unknown"))).isNull();
-    final Rule rule = registry.findByKey(RuleKey.of("xoo", "OneIssuePerLine"));
+    final Rule rule = registry.findByKey(RuleKey.of("xoo", "RuleWithParameters"));
     assertThat(rule).isNotNull();
     assertThat(rule.repositoryKey()).isEqualTo("xoo");
-    assertThat(rule.key()).isEqualTo("OneIssuePerLine");
+    assertThat(rule.key()).isEqualTo("RuleWithParameters");
+    assertThat(rule.params()).hasSize(5);
+    assertThat(rule.adminTags()).hasSize(1);
+    assertThat(rule.systemTags()).hasSize(2);
   }
 
 
index 38a50de3025de96c62b1cd24d66041106ec94fd8..6d6e7da2957d560704a3432365c1def50a54734d 100644 (file)
   "status": "READY",
   "createdAt": "2013-10-28T13:07:26.329Z",
   "updatedAt": "2013-11-08T10:52:53.473Z",
+  "note": {
+    "data": "<p>This rule should be kept to test params.</p>",
+    "author": "freddy.mallet",
+    "createdAt": "2013-11-14T13:07:26.329Z",
+    "updatedAt": "2013-11-14T13:10:26.329Z"
+  },
+  "systemTags": [ "has-params", "integration-tests" ],
+  "adminTags": [ "keep-enabled" ],
   "params": [
       {
         "key": "string",