diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2013-05-07 11:58:53 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2013-05-07 11:58:53 +0200 |
commit | 9ac6a6125cf9c67759858223dc65cf8176e849f9 (patch) | |
tree | 1f3765fef6e9475e32d8e70bec3b95d83f141c54 /sonar-core/src/test | |
parent | 35aaa0091d1319da83dcfc558921ca7dd8689757 (diff) | |
download | sonarqube-9ac6a6125cf9c67759858223dc65cf8176e849f9.tar.gz sonarqube-9ac6a6125cf9c67759858223dc65cf8176e849f9.zip |
SONAR-3755 Check that action plan exist when linking an action plan to an issue
Diffstat (limited to 'sonar-core/src/test')
3 files changed, 30 insertions, 1 deletions
diff --git a/sonar-core/src/test/java/org/sonar/core/issue/ActionPlanFinderTest.java b/sonar-core/src/test/java/org/sonar/core/issue/ActionPlanFinderTest.java index e858359bf60..7ae39c5bf9d 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/ActionPlanFinderTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/ActionPlanFinderTest.java @@ -52,6 +52,20 @@ public class ActionPlanFinderTest { } @Test + public void should_find_by_key() { + when(actionPlanDao.findByKey("ABCD")).thenReturn(new ActionPlanDto().setKey("ABCD")); + ActionPlan result = actionPlanFinder.findByKey("ABCD"); + assertThat(result).isNotNull(); + assertThat(result.key()).isEqualTo("ABCD"); + } + + @Test + public void should_return_null_if_no_action_plan_when_find_by_key() { + when(actionPlanDao.findByKey("ABCD")).thenReturn(null); + assertThat(actionPlanFinder.findByKey("ABCD")).isNull(); + } + + @Test public void should_find_by_keys() { when(actionPlanDao.findByKeys(newArrayList("ABCD"))).thenReturn(newArrayList(new ActionPlanDto().setKey("ABCD"))); Collection<ActionPlan> results = actionPlanFinder.findByKeys(newArrayList("ABCD")); @@ -69,7 +83,7 @@ public class ActionPlanFinderTest { } @Test(expected = IllegalArgumentException.class) - public void should_throw_exception_if_projecT_not_found_when_find_open_by_project_key() { + public void should_throw_exception_if_project_not_found_when_find_open_by_project_key() { when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(null); actionPlanFinder.findOpenByProjectKey("<Unkown>"); } diff --git a/sonar-core/src/test/java/org/sonar/core/issue/db/ActionPlanDaoTest.java b/sonar-core/src/test/java/org/sonar/core/issue/db/ActionPlanDaoTest.java index 857aceee67d..53e2d0684ba 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/db/ActionPlanDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/db/ActionPlanDaoTest.java @@ -39,6 +39,15 @@ public class ActionPlanDaoTest extends AbstractDaoTestCase { } @Test + public void should_find_by_key() { + setupData("should_find_by_key"); + + ActionPlanDto result = dao.findByKey("ABC"); + assertThat(result).isNotNull(); + assertThat(result.getKey()).isEqualTo("ABC"); + } + + @Test public void should_find_by_keys() { setupData("should_find_by_keys"); diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanDaoTest/should_find_by_key.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanDaoTest/should_find_by_key.xml new file mode 100644 index 00000000000..451855f27b0 --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanDaoTest/should_find_by_key.xml @@ -0,0 +1,6 @@ +<dataset> + + <action_plans id="1" kee="ABC" project_id="1" name="SHORT_TERM" description="[null]" deadline="[null]" + user_login="igor" status="[null]" created_at="[null]" updated_at="[null]" /> + +</dataset> |