diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-05-24 14:12:09 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-05-24 14:12:17 +0200 |
commit | 147633993d037d2c39623e06c3d66e1b61662734 (patch) | |
tree | 3b8c2a78ab5b21c0a07dc09ab9d548c5e34afd24 /sonar-core/src/test | |
parent | 9b54697acbceb0d1282398181901465c76f4af15 (diff) | |
download | sonarqube-147633993d037d2c39623e06c3d66e1b61662734.tar.gz sonarqube-147633993d037d2c39623e06c3d66e1b61662734.zip |
SONAR-4290 order action plans by chronological deadline
Diffstat (limited to 'sonar-core/src/test')
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/issue/ActionPlanDeadlineComparatorTest.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/sonar-core/src/test/java/org/sonar/core/issue/ActionPlanDeadlineComparatorTest.java b/sonar-core/src/test/java/org/sonar/core/issue/ActionPlanDeadlineComparatorTest.java new file mode 100644 index 00000000000..93a7e691884 --- /dev/null +++ b/sonar-core/src/test/java/org/sonar/core/issue/ActionPlanDeadlineComparatorTest.java @@ -0,0 +1,59 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.core.issue; + +import org.junit.Test; +import org.sonar.api.issue.ActionPlan; +import org.sonar.api.utils.DateUtils; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.fest.assertions.Assertions.assertThat; + +public class ActionPlanDeadlineComparatorTest { + + ActionPlan shortTerm = new DefaultActionPlan().setDeadLine(DateUtils.parseDate("2013-12-01")); + ActionPlan longTerm = new DefaultActionPlan().setDeadLine(DateUtils.parseDate("2018-05-05")); + ActionPlan noDeadline = new DefaultActionPlan().setDeadLine(null); + + @Test + public void compare_plans_with_deadlines() throws Exception { + List<ActionPlan> plans = Arrays.asList(shortTerm, longTerm); + Collections.sort(plans, new ActionPlanDeadlineComparator()); + assertThat(plans).containsSequence(shortTerm, longTerm); + + plans = Arrays.asList(longTerm, shortTerm); + Collections.sort(plans, new ActionPlanDeadlineComparator()); + assertThat(plans).containsSequence(shortTerm, longTerm); + } + + @Test + public void end_with_plans_without_deadline() throws Exception { + List<ActionPlan> plans = Arrays.asList(noDeadline, longTerm, shortTerm); + Collections.sort(plans, new ActionPlanDeadlineComparator()); + assertThat(plans).containsSequence(shortTerm, longTerm, noDeadline); + + plans = Arrays.asList(longTerm, noDeadline, shortTerm); + Collections.sort(plans, new ActionPlanDeadlineComparator()); + assertThat(plans).containsSequence(shortTerm, longTerm, noDeadline); + } +} |