aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-04-07 17:37:20 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-04-07 17:37:20 +0200
commit92c9ac2e355ff34991ed12bdd4571d399e24287e (patch)
tree98bd7c275bd45b0ab273d14335e2bbc872133c38
parentbb71eb37d63ae532747f71a0bbc4e139a0ff0ad4 (diff)
downloadsonarqube-92c9ac2e355ff34991ed12bdd4571d399e24287e.tar.gz
sonarqube-92c9ac2e355ff34991ed12bdd4571d399e24287e.zip
Remove checks of minutes greater than 60 and hours greater than 24
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java6
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/DurationTest.java20
2 files changed, 1 insertions, 25 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java
index 63367f10780..e340f805124 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Duration.java
@@ -79,17 +79,11 @@ public class Duration implements Serializable {
String hoursText = matcher.group(2);
if (hoursText != null) {
hours = Integer.parseInt(hoursText);
- if (hours > 24) {
- throw new IllegalArgumentException(String.format("The number of hours should not be greater than 24, got %s", hours));
- }
sanitizedText = sanitizedText.replace(hoursText + HOUR, "");
}
String minutesText = matcher.group(3);
if (minutesText != null) {
minutes = Integer.parseInt(minutesText);
- if (minutes > 60) {
- throw new IllegalArgumentException(String.format("The number of minutes should not be greater than 60, got %s", minutes));
- }
sanitizedText = sanitizedText.replace(minutesText + MINUTE, "");
}
if (sanitizedText.isEmpty()) {
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/DurationTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/DurationTest.java
index e5b36d8f864..f3170d77534 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/DurationTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/DurationTest.java
@@ -55,26 +55,8 @@ public class DurationTest {
assertThat(Duration.decode("23h", HOURS_IN_DAY)).isEqualTo(Duration.create(23 * ONE_HOUR_IN_MINUTES));
assertThat(Duration.decode("15d", HOURS_IN_DAY)).isEqualTo(Duration.create(15 * ONE_DAY_IN_MINUTES));
assertThat(Duration.decode("42min", HOURS_IN_DAY)).isEqualTo(Duration.create(42 * ONE_MINUTE));
- }
- @Test
- public void fail_to_decode_if_more_than_24_hours() throws Exception {
- try {
- Duration.decode("25h", HOURS_IN_DAY);
- fail();
- } catch (Exception e) {
- assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("The number of hours should not be greater than 24, got 25");
- }
- }
-
- @Test
- public void fail_to_decode_if_more_than_60_minutes() throws Exception {
- try {
- Duration.decode("61min", HOURS_IN_DAY);
- fail();
- } catch (Exception e) {
- assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("The number of minutes should not be greater than 60, got 61");
- }
+ assertThat(Duration.decode("25h61min", HOURS_IN_DAY)).isEqualTo(Duration.create(25 * ONE_HOUR_IN_MINUTES + 61));
}
@Test