diff options
author | Eric Hartmann <hartmann.eric@gmail.com> | 2017-06-14 16:05:29 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-06-15 00:14:36 +0200 |
commit | d54a64ddb75b2125631a37f2158237870969d667 (patch) | |
tree | ef925c9c8c7024785d3dd6b1342c202101f0c2fd /server/sonar-db-dao | |
parent | 764185d9211229e5dcafe885cfdcbfbfadf54ce7 (diff) | |
download | sonarqube-d54a64ddb75b2125631a37f2158237870969d667.tar.gz sonarqube-d54a64ddb75b2125631a37f2158237870969d667.zip |
SONAR-9305 complete tests
Diffstat (limited to 'server/sonar-db-dao')
-rw-r--r-- | server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java | 2 | ||||
-rw-r--r-- | server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDbTester.java | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java index 6f82c926bd1..494d623402e 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java @@ -115,7 +115,7 @@ public class QualityProfileDao implements Dao { mapper.updateRuleProfile(rulesProfile, new Date(now)); } - private void doUpdate(QualityProfileMapper mapper, QProfileDto profile, long now) { + private static void doUpdate(QualityProfileMapper mapper, QProfileDto profile, long now) { mapper.updateRuleProfile(RulesProfileDto.from(profile), new Date(now)); mapper.updateOrgQProfile(OrgQProfileDto.from(profile), now); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDbTester.java b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDbTester.java index 7ba24919da6..7f222a3e0ae 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDbTester.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDbTester.java @@ -65,6 +65,12 @@ public class RuleDbTester { return rule; } + public RuleDefinitionDto update(RuleDefinitionDto rule) { + db.getDbClient().ruleDao().update(db.getSession(), rule); + db.commit(); + return rule; + } + @SafeVarargs public final RuleMetadataDto insertOrUpdateMetadata(RuleDefinitionDto rule, OrganizationDto organization, Consumer<RuleMetadataDto>... populaters) { RuleMetadataDto dto = RuleTesting.newRuleMetadata(rule, organization); @@ -101,6 +107,15 @@ public class RuleDbTester { return ruleDto; } + public RuleDto updateRule(RuleDto ruleDto) { + update(ruleDto.getDefinition()); + RuleMetadataDto metadata = ruleDto.getMetadata(); + if (metadata.getOrganizationUuid() != null) { + db.getDbClient().ruleDao().insertOrUpdate(db.getSession(), metadata.setRuleId(ruleDto.getId())); + db.commit(); + } + return ruleDto; + } /** * Create and persist a rule with random values. */ |