diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-07-24 09:21:51 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-07-24 09:21:51 +0200 |
commit | ef9869ca12457efb552c7abd4517c334ed839c66 (patch) | |
tree | 69c929a2e99d64b0db3b0dab64c523f6ce134c38 /sonar-core/src/test | |
parent | e4fdef49e36d269ef5365a3056af67c8c3d5aceb (diff) | |
download | sonarqube-ef9869ca12457efb552c7abd4517c334ed839c66.tar.gz sonarqube-ef9869ca12457efb552c7abd4517c334ed839c66.zip |
SONAR-5417 Return quality profiles and settings by module
Diffstat (limited to 'sonar-core/src/test')
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/qualityprofile/db/QualityProfileDaoTest.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/QualityProfileDaoTest.java b/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/QualityProfileDaoTest.java index 1f1c8554acf..21386e7be70 100644 --- a/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/QualityProfileDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/QualityProfileDaoTest.java @@ -20,6 +20,7 @@ package org.sonar.core.qualityprofile.db; +import org.junit.After; import org.junit.Before; import org.junit.Test; import org.sonar.api.utils.System2; @@ -36,14 +37,21 @@ import static org.mockito.Mockito.when; public class QualityProfileDaoTest extends AbstractDaoTestCase { QualityProfileDao dao; + DbSession session; System2 system = mock(System2.class); @Before public void createDao() { + this.session = getMyBatis().openSession(false); dao = new QualityProfileDao(getMyBatis(), system); when(system.now()).thenReturn(UtcDateUtils.parseDateTime("2014-01-20T12:00:00+0000").getTime()); } + @After + public void after() { + this.session.close(); + } + @Test public void insert() { setupData("shared"); @@ -217,10 +225,21 @@ public class QualityProfileDaoTest extends AbstractDaoTestCase { } @Test - public void select_by_project_and_language() { + public void select_by_project_id_and_language() { setupData("projects"); QualityProfileDto dto = dao.getByProjectAndLanguage(1L, "java", "sonar.profile.java"); assertThat(dto.getId()).isEqualTo(1); } + + @Test + public void select_by_project_key_and_language() { + setupData("projects"); + + QualityProfileDto dto = dao.getByProjectAndLanguage("org.codehaus.sonar:sonar", "java", "sonar.profile.java", session); + assertThat(dto.getId()).isEqualTo(1); + + assertThat(dao.getByProjectAndLanguage("org.codehaus.sonar:sonar", "unkown", "sonar.profile.java", session)).isNull(); + assertThat(dao.getByProjectAndLanguage("unknown", "java", "sonar.profile.java", session)).isNull(); + } } |