]> source.dussan.org Git - sonarqube.git/commitdiff
fix quality flaw (re-enabled test and fixed assertion)
authorStephane Gamard <stephane.gamard@searchbox.com>
Fri, 27 Jun 2014 20:52:27 +0000 (22:52 +0200)
committerStephane Gamard <stephane.gamard@searchbox.com>
Fri, 27 Jun 2014 20:52:27 +0000 (22:52 +0200)
sonar-server/src/test/java/org/sonar/server/rule/RuleBackendMediumTest.java

index 08e86e38593775a40ee97f572f7a4568f53b9e0f..b17666864bace261ca6eadfa6469796297b22259 100644 (file)
@@ -82,9 +82,6 @@ public class RuleBackendMediumTest {
     assertThat(persistedDto.getId()).isGreaterThanOrEqualTo(0);
     assertThat(persistedDto.getRuleKey()).isEqualTo(ruleDto.getRuleKey());
     assertThat(persistedDto.getLanguage()).isEqualTo(ruleDto.getLanguage());
-//FIXME
-//    assertThat(persistedDto.getTags()).containsOnly(ruleDto.getTags());
-//    assertThat(persistedDto.getSystemTags()).containsOnly(ruleDto.getSystemTags());
     assertThat(persistedDto.getCreatedAt()).isNotNull();
     assertThat(persistedDto.getUpdatedAt()).isNotNull();
 
@@ -102,12 +99,25 @@ public class RuleBackendMediumTest {
     assertThat(hit.internalKey()).isEqualTo(ruleDto.getConfigKey());
     assertThat(hit.severity()).isEqualTo(ruleDto.getSeverityString());
     assertThat(hit.isTemplate()).isFalse();
-//FIXME
-//    assertThat(hit.tags()).containsOnly(ruleDto.getTags());
-//    assertThat(hit.systemTags()).containsOnly(ruleDto.getSystemTags());
     assertThat(hit.effortToFixDescription()).isEqualTo(ruleDto.getEffortToFixDescription());
   }
 
+  @Test
+  public void insert_rule_tags_in_db_and_index_in_es() throws InterruptedException {
+    // insert db
+    RuleDto ruleDto = RuleTesting.newXooX1();
+    dao.insert(dbSession, ruleDto);
+    dbSession.commit();
+
+    RuleDto persistedDto = dao.getNullableByKey(dbSession, RuleTesting.XOO_X1);
+    assertThat(persistedDto.getTags().containsAll(ruleDto.getTags())).isTrue();
+    assertThat(persistedDto.getSystemTags().containsAll(ruleDto.getSystemTags())).isTrue();
+
+    Rule hit = index.getByKey(RuleTesting.XOO_X1);
+    assertThat(hit.tags().containsAll(ruleDto.getTags())).isTrue();
+    assertThat(hit.systemTags().containsAll(ruleDto.getSystemTags())).isTrue();
+  }
+
   @Test
   public void insert_and_index_rule_parameters() {
     // insert db