From a0a6f86dd90abe06ce847eb095ad91bd4612fb04 Mon Sep 17 00:00:00 2001 From: Stephane Gamard Date: Fri, 27 Jun 2014 22:52:27 +0200 Subject: [PATCH] fix quality flaw (re-enabled test and fixed assertion) --- .../server/rule/RuleBackendMediumTest.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/sonar-server/src/test/java/org/sonar/server/rule/RuleBackendMediumTest.java b/sonar-server/src/test/java/org/sonar/server/rule/RuleBackendMediumTest.java index 08e86e38593..b17666864ba 100644 --- a/sonar-server/src/test/java/org/sonar/server/rule/RuleBackendMediumTest.java +++ b/sonar-server/src/test/java/org/sonar/server/rule/RuleBackendMediumTest.java @@ -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 -- 2.39.5