]> source.dussan.org Git - sonarqube.git/commitdiff
DAOv.2 - Test preotected chars in value
authorStephane Gamard <stephane.gamard@searchbox.com>
Tue, 27 May 2014 07:27:53 +0000 (09:27 +0200)
committerStephane Gamard <stephane.gamard@searchbox.com>
Tue, 27 May 2014 07:28:14 +0000 (09:28 +0200)
sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexMediumTest.java

index a062e4f2c4c2cf80cb516e7b174018191e74ae8e..1df8eba7eb5e8369205162fe99dc192f635bf903 100644 (file)
@@ -34,8 +34,10 @@ import org.sonar.check.Cardinality;
 import org.sonar.core.persistence.DbSession;
 import org.sonar.core.persistence.MyBatis;
 import org.sonar.core.qualityprofile.db.ActiveRuleDto;
+import org.sonar.core.qualityprofile.db.ActiveRuleParamDto;
 import org.sonar.core.qualityprofile.db.QualityProfileDto;
 import org.sonar.core.rule.RuleDto;
+import org.sonar.core.rule.RuleParamDto;
 import org.sonar.core.technicaldebt.db.CharacteristicDto;
 import org.sonar.server.db.DbClient;
 import org.sonar.server.rule.Rule;
@@ -500,6 +502,36 @@ public class RuleIndexMediumTest {
 
   }
 
+  @Test
+  public void complex_param_value(){
+    String value = "//expression[primary/qualifiedIdentifier[count(IDENTIFIER) = 2]/IDENTIFIER[2]/@tokenValue = 'firstOf' and primary/identifierSuffix/arguments/expression[not(primary) or primary[not(qualifiedIdentifier) or identifierSuffix]]]";
+
+    QualityProfileDto profile = QualityProfileDto.createFor("name","Language");
+    dbClient.qualityProfileDao().insert(dbSession, profile);
+
+    RuleDto rule = newRuleDto(RuleKey.of("java", "S001"));
+    dao.insert(dbSession,rule);
+
+    RuleParamDto param = RuleParamDto.createFor(rule)
+      .setName("testing")
+      .setType("STRING")
+      .setDefaultValue(value);
+    dao.addRuleParam(rule, param, dbSession);
+
+    ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule)
+      .setSeverity("BLOCKER");
+
+    ActiveRuleParamDto activeRuleParam = ActiveRuleParamDto.createFor(param);
+    dbClient.activeRuleDao().insert(dbSession, activeRule);
+    dbClient.activeRuleDao().addParam(activeRule, activeRuleParam, dbSession);
+    dbSession.commit();
+
+    assertThat(index.getByKey(rule.getKey()).params().get(0).defaultValue()).isEqualTo(value);
+
+
+  }
+
+
   @Test
   public void search_by_tag() throws InterruptedException {
     dao.insert(dbSession, newRuleDto(RuleKey.of("java", "S001")).setTags(ImmutableSet.of("tag1")));