From 9a8ee3c8e35b5bbf6af375e7bed243e315191f61 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 24 May 2020 13:02:01 +0200 Subject: [PATCH] [core] Improve NumberUtil's exception message and fix javadoc --- .../org/jivesoftware/smack/util/NumberUtil.java | 14 +++++++------- .../xdatavalidation/DataValidationHelperTest.java | 3 +-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/NumberUtil.java b/smack-core/src/main/java/org/jivesoftware/smack/util/NumberUtil.java index 831ccf0ad..98635309d 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/NumberUtil.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/NumberUtil.java @@ -1,6 +1,6 @@ /** * - * Copyright © 2015-2019 Florian Schmaus + * Copyright © 2015-2020 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,15 +33,15 @@ public class NumberUtil { /** * Checks if the given long is within the range of an unsigned 32-bit integer, the XML type "xs:unsignedInt". * - * @param value TODO javadoc me please + * @param value the long to check. * @return the input value. */ public static long requireUInt32(long value) { if (value < 0) { - throw new IllegalArgumentException("unsigned 32-bit integers can't be negative"); + throw new IllegalArgumentException("unsigned 32-bit integers can't be negative: " + value); } if (value > ((1L << 32) - 1)) { - throw new IllegalArgumentException("unsigned 32-bit integers can't be greater than 2^32 - 1"); + throw new IllegalArgumentException("unsigned 32-bit integers can't be greater than 2^32 - 1: " + value); } return value; } @@ -49,15 +49,15 @@ public class NumberUtil { /** * Checks if the given int is within the range of an unsigned 16-bit integer, the XML type "xs:unsignedShort". * - * @param value TODO javadoc me please + * @param value the int to check. * @return the input value. */ public static int requireUShort16(int value) { if (value < 0) { - throw new IllegalArgumentException("unsigned 16-bit integers can't be negative"); + throw new IllegalArgumentException("unsigned 16-bit integers can't be negative: " + value); } if (value > ((1 << 16) - 1)) { - throw new IllegalArgumentException("unsigned 16-bit integers can't be greater than 2^16 - 1"); + throw new IllegalArgumentException("unsigned 16-bit integers can't be greater than 2^16 - 1: " + value); } return value; } diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/xdatavalidation/DataValidationHelperTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/xdatavalidation/DataValidationHelperTest.java index a12effdb6..42f08f499 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/xdatavalidation/DataValidationHelperTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/xdatavalidation/DataValidationHelperTest.java @@ -44,9 +44,8 @@ public class DataValidationHelperTest { () -> element.checkConsistency(field)); assertEquals("Field type 'jid-single' is not consistent with validation method 'basic'.", vce.getMessage()); - IllegalArgumentException iae = assertThrows(IllegalArgumentException.class, + assertThrows(IllegalArgumentException.class, () -> new ListRange(-1L, 1L)); - assertEquals("unsigned 32-bit integers can't be negative", iae.getMessage()); element.setListRange(new ListRange(10L, 100L)); vce = assertThrows(ValidationConsistencyException.class, () -> element.checkConsistency(field));