Use assertThrows in yang-common
[yangtools.git] / yang / yang-common / src / test / java / org / opendaylight / yangtools / yang / common / Uint64Test.java
index dfc5e84f33bd167c029dc62f5a807fc3a7f50617..12f096379f93678232eafe901a3fa2bd9b7b0275 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.UnsignedLong;
@@ -105,19 +106,19 @@ public class Uint64Test {
         assertEquals(Uint32.TEN, Uint64.TEN.toUint32());
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testToUint8() {
-        Uint64.MAX_VALUE.toUint8();
+        assertThrows(IllegalArgumentException.class, () -> Uint64.MAX_VALUE.toUint8());
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testToUint16() {
-        Uint64.MAX_VALUE.toUint16();
+        assertThrows(IllegalArgumentException.class, () -> Uint64.MAX_VALUE.toUint16());
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testToUint32() {
-        Uint64.MAX_VALUE.toUint32();
+        assertThrows(IllegalArgumentException.class, () -> Uint64.MAX_VALUE.toUint32());
     }
 
     @Test
@@ -136,43 +137,43 @@ public class Uint64Test {
         assertSame(source, read);
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testNegativeByte() {
-        Uint64.valueOf((byte)-1);
+        assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf((byte)-1));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testNegativeShort() {
-        Uint64.valueOf((short)-1);
+        assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf((short)-1));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testNegativeInt() {
-        Uint64.valueOf(-1);
+        assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf(-1));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testNegativeLong() {
-        Uint64.valueOf(-1L);
+        assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf(-1L));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testNegativeBigInteger() {
-        Uint64.valueOf(new BigInteger("-1"));
+        assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf(new BigInteger("-1")));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testBigBigInteger() {
-        Uint64.valueOf(new BigInteger("0x10000000000000000"));
+        assertThrows(IllegalArgumentException.class, () -> Uint64.valueOf(new BigInteger("0x10000000000000000")));
     }
 
-    @Test(expected = NullPointerException.class)
+    @Test
     public void testNullValueOfString() {
-        Uint64.valueOf((String) null);
+        assertThrows(NullPointerException.class, () -> Uint64.valueOf((String) null));
     }
 
-    @Test(expected = NullPointerException.class)
+    @Test
     public void testNullValueOfBigInteger() {
-        Uint64.valueOf((BigInteger) null);
+        assertThrows(NullPointerException.class, () -> Uint64.valueOf((BigInteger) null));
     }
 }