]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4290 allow to create an action plan on today
authorSimon Brandhof <simon.brandhof@gmail.com>
Wed, 22 May 2013 13:57:04 +0000 (15:57 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Wed, 22 May 2013 13:57:11 +0000 (15:57 +0200)
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java
sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java

index 45e519f5f6b2967b991ea40e66218daec5d6f09e..6539383d1b66c09cc1320ee5a391173699f9d163 100644 (file)
@@ -625,18 +625,14 @@ action_plans.col.author=Author
 action_plans.col.closed_on=Closed on
 action_plans.col.operations=Operations
 action_plans.no_action_plan=No action plan
-action_plans.no_reviews_linked_to_action_plan=No reviews linked to this action plan yet.
-action_plans.confirm_delete=Delete this action plan? Associated reviews will not be deleted.
-action_plans.confirm_close=Close this action plan? There are still open reviews linked to it.
+action_plans.confirm_delete=Delete this action plan? Associated issues will not be deleted.
+action_plans.confirm_close=Close this action plan? There are still open issues linked to it.
 action_plans.create_form_title=Create Action Plan
 action_plans.edit_action_plan=Edit Action Plan
 action_plans.same_name_in_same_project=An action plan with this name already exists in this project.
 action_plans.date_format_help=The date should be entered using the following pattern: 'day/month/year'. For instance, '31/12/2011'.
 action_plans.date_not_valid=Date not valid
 action_plans.date_cant_be_in_past=The dead-line can't be in the past
-action_plans.x_out_of_x_reviews_solved={0} of {1} reviews solved
-action_plans.resolved_reviews_x_percent=Resolved reviews - {0}% ({1} reviews)
-action_plans.open_reviews_x_percent=Open reviews - {0}% ({1} reviews)
 action_plans.closed_action_plan=Closed Action Plans
 action_plans.no_issues_linked_to_action_plan=No issues linked to this action plan yet.
 action_plans.status.OPEN=Open
@@ -645,7 +641,7 @@ action_plans.resolved_issues_x_percent=Resolved issues - {0}% ({1} issues)
 action_plans.unresolved_issues_x_percent=Unresolved issues - {0}% ({1} issues)
 action_plans.x_out_of_x_issues_solved={0} of {1} issues solved
 action_plans.reopen=Reopen
-
+action_plans.errors.action_plan_does_not_exist=Action plan with key {0} does not exists
 
 #------------------------------------------------------------------------------
 #
index 0c74050f444325c492dd3c71219a5c4bd9adcb8d..e0ba5b35c0eef06103b4ef2a20772bd943adbac3 100644 (file)
@@ -22,6 +22,7 @@ package org.sonar.server.issue;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Strings;
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateUtils;
 import org.sonar.api.ServerComponent;
 import org.sonar.api.issue.ActionPlan;
 import org.sonar.api.issue.Issue;
@@ -177,7 +178,7 @@ public class InternalRubyIssueService implements ServerComponent {
     DefaultActionPlan existingActionPlan = (DefaultActionPlan) actionPlanService.findByKey(key);
     if (existingActionPlan == null) {
       Result<ActionPlan> result = Result.of();
-      result.addError(Result.Message.ofL10n("issues_action_plans.errors.action_plan_does_not_exists", key));
+      result.addError(Result.Message.ofL10n("action_plans.errors.action_plan_does_not_exist", key));
       return result;
     } else {
       Result<ActionPlan> result = createActionPlanResult(parameters, existingActionPlan.name());
@@ -250,7 +251,7 @@ public class InternalRubyIssueService implements ServerComponent {
     } else {
       ResourceDto project = resourceDao.getResource(ResourceQuery.create().setKey(projectParam));
       if (project == null) {
-        result.addError(Result.Message.ofL10n("issues_action_plans.errors.project_does_not_exists", projectParam));
+        result.addError(Result.Message.ofL10n("action_plans.errors.project_does_not_exist", projectParam));
       }
     }
 
@@ -258,8 +259,9 @@ public class InternalRubyIssueService implements ServerComponent {
       try {
         SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
         deadLine = dateFormat.parse(deadLineParam);
-        if (deadLine.before(new Date())) {
-          result.addError(Result.Message.ofL10n("issues_action_plans.date_cant_be_in_past"));
+        Date today = new Date();
+        if (deadLine.before(today) && !DateUtils.isSameDay(deadLine, today)) {
+          result.addError(Result.Message.ofL10n("action_plans.date_cant_be_in_past"));
         }
       } catch (Exception e) {
         result.addError(Result.Message.ofL10n("errors.is_not_valid", "date"));
@@ -268,7 +270,7 @@ public class InternalRubyIssueService implements ServerComponent {
 
     if (!Strings.isNullOrEmpty(projectParam) && !Strings.isNullOrEmpty(name) && !name.equals(oldName)
       && actionPlanService.isNameAlreadyUsedForProject(name, projectParam)) {
-      result.addError(Result.Message.ofL10n("issues_action_plans.same_name_in_same_project"));
+      result.addError(Result.Message.ofL10n("action_plans.same_name_in_same_project"));
     }
 
     if (result.ok()) {
@@ -285,7 +287,7 @@ public class InternalRubyIssueService implements ServerComponent {
   private Result<ActionPlan> createResultForExistingActionPlan(String actionPlanKey) {
     Result<ActionPlan> result = Result.of();
     if (findActionPlan(actionPlanKey) == null) {
-      result.addError(Result.Message.ofL10n("issues_action_plans.errors.action_plan_does_not_exists", actionPlanKey));
+      result.addError(Result.Message.ofL10n("action_plans.errors.action_plan_does_not_exist", actionPlanKey));
     }
     return result;
   }
index e450e449ed977d244950d583cbbdccdca36aa9a9..24e5ebabe0ca1c5da5c5bf074116c96c07f76a76 100644 (file)
@@ -127,7 +127,7 @@ public class InternalRubyIssueServiceTest {
 
     Result result = internalRubyIssueService.updateActionPlan("ABCD", null);
     assertThat(result.ok()).isFalse();
-    assertThat(result.errors()).contains(Result.Message.ofL10n("issues_action_plans.errors.action_plan_does_not_exists", "ABCD"));
+    assertThat(result.errors()).contains(Result.Message.ofL10n("action_plans.errors.action_plan_does_not_exist", "ABCD"));
   }
 
   @Test
@@ -146,7 +146,7 @@ public class InternalRubyIssueServiceTest {
     Result result = internalRubyIssueService.deleteActionPlan("ABCD");
     verify(actionPlanService, never()).delete("ABCD");
     assertThat(result.ok()).isFalse();
-    assertThat(result.errors()).contains(Result.Message.ofL10n("issues_action_plans.errors.action_plan_does_not_exists", "ABCD"));
+    assertThat(result.errors()).contains(Result.Message.ofL10n("action_plans.errors.action_plan_does_not_exist", "ABCD"));
   }
 
   @Test
@@ -237,7 +237,7 @@ public class InternalRubyIssueServiceTest {
 
     Result result = internalRubyIssueService.createActionPlanResult(parameters);
     assertThat(result.ok()).isFalse();
-    assertThat(result.errors()).contains(Result.Message.ofL10n("issues_action_plans.date_cant_be_in_past"));
+    assertThat(result.errors()).contains(Result.Message.ofL10n("action_plans.date_cant_be_in_past"));
   }
 
   @Test
@@ -251,7 +251,7 @@ public class InternalRubyIssueServiceTest {
 
     Result result = internalRubyIssueService.createActionPlanResult(parameters, "Short term");
     assertThat(result.ok()).isFalse();
-    assertThat(result.errors()).contains(Result.Message.ofL10n("issues_action_plans.same_name_in_same_project"));
+    assertThat(result.errors()).contains(Result.Message.ofL10n("action_plans.same_name_in_same_project"));
   }
 
   @Test
@@ -265,7 +265,7 @@ public class InternalRubyIssueServiceTest {
 
     Result result = internalRubyIssueService.createActionPlanResult(parameters);
     assertThat(result.ok()).isFalse();
-    assertThat(result.errors()).contains(Result.Message.ofL10n("issues_action_plans.errors.project_does_not_exists", "org.sonar.Sample"));
+    assertThat(result.errors()).contains(Result.Message.ofL10n("action_plans.errors.project_does_not_exist", "org.sonar.Sample"));
   }
   public String createLongString(int size) {
     String result = "";