From: Simon Brandhof Date: Wed, 22 May 2013 13:57:04 +0000 (+0200) Subject: SONAR-4290 allow to create an action plan on today X-Git-Tag: 3.6~308 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e9a6f9f440cecc8c92bd3ccff910be0514e32a95;p=sonarqube.git SONAR-4290 allow to create an action plan on today --- diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties index 45e519f5f6b..6539383d1b6 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -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 #------------------------------------------------------------------------------ # diff --git a/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java b/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java index 0c74050f444..e0ba5b35c0e 100644 --- a/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java +++ b/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java @@ -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 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 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 createResultForExistingActionPlan(String actionPlanKey) { Result 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; } diff --git a/sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java b/sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java index e450e449ed9..24e5ebabe0c 100644 --- a/sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java +++ b/sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java @@ -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 = "";