]> source.dussan.org Git - sonarqube.git/commitdiff
Fix unit test
authorJulien Lancelot <julien.lancelot@gmail.com>
Tue, 4 Jun 2013 17:24:51 +0000 (19:24 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Tue, 4 Jun 2013 17:24:51 +0000 (19:24 +0200)
sonar-server/src/main/java/org/sonar/server/issue/ActionService.java
sonar-server/src/test/java/org/sonar/server/issue/ActionServiceTest.java

index a847cbaf7b2087d93ed6e08a8a9667d13e2f127b..3e55485410dd2c66e7b79d2623dc99f007c0592b 100644 (file)
@@ -80,10 +80,6 @@ public class ActionService implements ServerComponent {
   public List<Action> listAvailableActions(String issueKey) {
     IssueQueryResult queryResult = loadIssue(issueKey);
     final DefaultIssue issue = (DefaultIssue) queryResult.first();
-    if (issue == null) {
-      throw new IllegalArgumentException("Issue is not found : " + issueKey);
-    }
-
     return listAvailableActions(issue);
   }
 
index 8bbd125bcfe125b920a2eb5aaffac61ccb3ee710..38838e178331d3abae2fedb7499cce1b641e81df 100644 (file)
@@ -54,12 +54,11 @@ public class ActionServiceTest {
   private IssueUpdater updater;
   private PropertiesDao propertiesDao;
   private Settings settings;
-
   private Actions actions;
   private ActionService actionService;
 
   @Before
-  public void before(){
+  public void before() {
     finder = mock(DefaultIssueFinder.class);
     issueStorage = mock(IssueStorage.class);
     updater = mock(IssueUpdater.class);
@@ -122,9 +121,10 @@ public class ActionServiceTest {
 
     actions.add("link-to-jira").setConditions(new AlwaysMatch()).setFunctions(function);
     try {
-    actionService.execute("ABCD", "link-to-jira", mock(UserSession.class));
-    } catch (Exception e){
-      assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("Issue is not found : ABCD");
+      actionService.execute("ABCD", "link-to-jira", mock(UserSession.class));
+      fail();
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("No issue");
     }
     verifyZeroInteractions(function);
   }
@@ -140,7 +140,8 @@ public class ActionServiceTest {
     actions.add("link-to-jira").setConditions(new AlwaysMatch()).setFunctions(function);
     try {
       actionService.execute("ABCD", "tweet", mock(UserSession.class));
-    } catch (Exception e){
+      fail();
+    } catch (Exception e) {
       assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("Action is not found : tweet");
     }
     verifyZeroInteractions(function);
@@ -157,7 +158,8 @@ public class ActionServiceTest {
     actions.add("link-to-jira").setConditions(new NeverMatch()).setFunctions(function);
     try {
       actionService.execute("ABCD", "link-to-jira", mock(UserSession.class));
-    } catch (Exception e){
+      fail();
+    } catch (Exception e) {
       assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("A condition is not respected");
     }
     verifyZeroInteractions(function);
@@ -184,8 +186,8 @@ public class ActionServiceTest {
     try {
       actionService.listAvailableActions("ABCD");
       fail();
-    } catch (Exception e){
-      assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("Issue is not found : ABCD");
+    } catch (Exception e) {
+      assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("No issue");
     }
   }
 
@@ -215,7 +217,7 @@ public class ActionServiceTest {
   public class TweetFunction implements Function {
     @Override
     public void execute(Context context) {
-      context.addComment("New tweet on issue "+ context.issue().key());
+      context.addComment("New tweet on issue " + context.issue().key());
       context.setAttribute("tweet", "tweet sent");
     }
   }