Convert uint tests to assertThrows()
[yangtools.git] / yang / yang-common / src / test / java / org / opendaylight / yangtools / yang / common / Uint32Test.java
index 2706dc0e842c09d09e017b8e1c7ec2fd03a32688..b1a122647a1f007c9ca31e23749614842a0817d0 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.common;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 
 import com.google.common.primitives.UnsignedInteger;
@@ -101,14 +102,14 @@ public class Uint32Test {
         assertEquals(Uint64.valueOf(4294967295L), Uint32.MAX_VALUE.toUint64());
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testToUint8() {
-        Uint32.MAX_VALUE.toUint8();
+        assertThrows(IllegalArgumentException.class, () -> Uint32.MAX_VALUE.toUint8());
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testToUint16() {
-        Uint32.MAX_VALUE.toUint16();
+        assertThrows(IllegalArgumentException.class, () -> Uint32.MAX_VALUE.toUint16());
     }
 
     @Test
@@ -127,33 +128,21 @@ public class Uint32Test {
         assertSame(source, read);
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void testNegativeByte() {
-        Uint32.valueOf((byte)-1);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testNegativeShort() {
-        Uint32.valueOf((short)-1);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testNegativeInt() {
-        Uint32.valueOf(-1);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testNegativeLong() {
-        Uint32.valueOf(-1L);
+    @Test
+    public void testNegativeValues() {
+        assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf((byte)-1));
+        assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf((short)-1));
+        assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf(-1));
+        assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf(-1L));
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void testBigLong() {
-        Uint32.valueOf(4294967296L);
+    @Test
+    public void testLargeValues() {
+        assertThrows(IllegalArgumentException.class, () -> Uint32.valueOf(4294967296L));
     }
 
-    @Test(expected = NullPointerException.class)
+    @Test
     public void testNullValueOfString() {
-        Uint32.valueOf((String) null);
+        assertThrows(NullPointerException.class, () -> Uint32.valueOf((String) null));
     }
 }