Use Assert.assertThrows() 67/89967/3
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 26 May 2020 18:00:26 +0000 (20:00 +0200)
committerHema Gopalakrishnan <hema.gopalkrishnan@ericsson.com>
Wed, 22 Jul 2020 17:25:57 +0000 (17:25 +0000)
org.opendaylight.infrautils.testutils.Asserts.assertThrows() has been
deprecated, as we now have a more modern JUnit, which provides this
facility. Migrate all users and remove dependency on
infrautils-testutils where is it no longer required.

Change-Id: If7bb59bf45ad290fb79747105c690af4a684dfdb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
ipv6util/api/pom.xml
ipv6util/api/src/test/java/org/opendaylight/genius/ipv6util/api/Ipv6UtilTest.java
ipv6util/api/src/test/java/org/opendaylight/genius/ipv6util/api/decoders/Ipv6NaDecoderTest.java
ipv6util/impl/pom.xml
ipv6util/impl/src/test/java/org/opendaylight/genius/ipv6util/nd/Ipv6NsHelperTest.java
mdsalutil/mdsalutil-api/pom.xml
mdsalutil/mdsalutil-api/src/test/java/org/opendaylight/genius/mdsalutil/tests/NWUtilTest.java
mdsalutil/mdsalutil-testutils/src/test/java/org/opendaylight/genius/datastoreutils/testutils/tests/TestableDataBrokerTest.java
mdsalutil/mdsalutil-testutils/src/test/java/org/opendaylight/genius/infra/tests/DatastoreTest.java
mdsalutil/mdsalutil-testutils/src/test/java/org/opendaylight/genius/infra/tests/ManagedNewTransactionRunnerImplTest.java
mdsalutil/mdsalutil-testutils/src/test/java/org/opendaylight/genius/infra/tests/TransactionAdapterTest.java

index 5a022c6099bb9a2ffe6a6109e22c8a16832de302..26326b74e5ce3e37eedf0866d7a83b1127e1bb34 100644 (file)
@@ -48,9 +48,5 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-lang3</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.opendaylight.infrautils</groupId>
-      <artifactId>infrautils-testutils</artifactId>
-    </dependency>
   </dependencies>
 </project>
index 9ad79b7695509527a4eda660492241f411e86db7..a87e6e060672d1348800c72186cae81f2e2e3055 100644 (file)
@@ -5,13 +5,12 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.genius.ipv6util.api;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
 
 import org.junit.Test;
-import org.opendaylight.infrautils.testutils.Asserts;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
 
@@ -33,13 +32,13 @@ public class Ipv6UtilTest {
         assertEquals(Ipv6Util.getFormattedIpAddress(IpAddressBuilder.getDefaultInstance("10.0.0.10")), "10.0.0.10");
 
         // Negative cases
-        Asserts.assertThrows(IllegalArgumentException.class, () -> {
+        assertThrows(IllegalArgumentException.class, () -> {
             Ipv6Util.getFormattedIpAddress(IpAddressBuilder.getDefaultInstance("abcd-invalid"));
         });
-        Asserts.assertThrows(IllegalArgumentException.class, () -> {
+        assertThrows(IllegalArgumentException.class, () -> {
             Ipv6Util.getFormattedIpAddress(IpAddressBuilder.getDefaultInstance("1001:db8:0:2::/64"));
         });
-        Asserts.assertThrows(IllegalArgumentException.class, () -> {
+        assertThrows(IllegalArgumentException.class, () -> {
             Ipv6Util.getFormattedIpAddress(IpAddressBuilder.getDefaultInstance("20.0.0.10/24"));
         });
     }
@@ -59,10 +58,10 @@ public class Ipv6UtilTest {
                 "fe80:0:0:0:0:0:a00:27f1");
 
         // Negative cases
-        Asserts.assertThrows(IllegalArgumentException.class, () -> {
+        assertThrows(IllegalArgumentException.class, () -> {
             Ipv6Util.getFormattedIpv6Address(Ipv6Address.getDefaultInstance("abcd-invalid"));
         });
-        Asserts.assertThrows(IllegalArgumentException.class, () -> {
+        assertThrows(IllegalArgumentException.class, () -> {
             Ipv6Util.getFormattedIpv6Address(Ipv6Address.getDefaultInstance("1001:db8:0:2::/64"));
         });
     }
index 2b410347ef8891d41acaba10542688601a14bd5c..1c978ccc07702c15dd61e6ca58c5bb19fc4cdbee 100644 (file)
@@ -5,18 +5,17 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.genius.ipv6util.api.decoders;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertThrows;
 
 import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.List;
 import org.junit.Test;
 import org.opendaylight.genius.ipv6util.api.Icmpv6Type;
-import org.opendaylight.infrautils.testutils.Asserts;
 import org.opendaylight.openflowplugin.libraries.liblldp.BufferException;
 import org.opendaylight.openflowplugin.libraries.liblldp.EtherTypes;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
@@ -113,7 +112,7 @@ public class Ipv6NaDecoderTest {
                 "00 20",                                           // Payload length
                 "3A"                                               // Next header is ICMPv6
         );
-        Asserts.assertThrows(BufferException.class, () -> {
+        assertThrows(BufferException.class, () -> {
             new Ipv6NaDecoder(invalidInputPayload).decode();
         });
     }
index 30489a92c845fadfd74a6603c3f9f9144a63b078..19f2263b14227b3335ea619544085931d73d3f1e 100644 (file)
@@ -36,10 +36,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <groupId>javax.inject</groupId>
       <artifactId>javax.inject</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.opendaylight.infrautils</groupId>
-      <artifactId>infrautils-testutils</artifactId>
-    </dependency>
   </dependencies>
   <build>
     <pluginManagement>
index 200160eddf522c65aa69d94efdd8836f078627f6..2bc84a044f3a516aecc42cf4263e3f0c9edc78d5 100644 (file)
@@ -5,10 +5,10 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.genius.ipv6util.nd;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.times;
@@ -22,7 +22,6 @@ import org.mockito.Mockito;
 import org.opendaylight.genius.mdsalutil.ActionInfo;
 import org.opendaylight.genius.mdsalutil.MDSALUtil;
 import org.opendaylight.genius.mdsalutil.actions.ActionGroup;
-import org.opendaylight.infrautils.testutils.Asserts;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
@@ -187,7 +186,7 @@ public class Ipv6NsHelperTest {
         long invalidOfGroupId = -1;
 
         // case: 1 - Invalid OF group ID
-        Asserts.assertThrows(IllegalArgumentException.class, () -> {
+        assertThrows(IllegalArgumentException.class, () -> {
             instance.transmitNeighborSolicitationToOfGroup(dpnId, srcMacAddress, srcIpv6Address, targetIpv6Address,
                     invalidOfGroupId);
         });
index 47f46fb30c0f0dcb859417bd694e2266681762fd..165ca228032f1afc9994a801daaf1b7f886b340b 100644 (file)
@@ -150,10 +150,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <groupId>org.opendaylight.mdsal</groupId>
       <artifactId>mdsal-binding-spi</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.opendaylight.infrautils</groupId>
-      <artifactId>infrautils-testutils</artifactId>
-    </dependency>
     <dependency>
       <groupId>com.google.truth</groupId>
       <artifactId>truth</artifactId>
index 99b26ae2db57dcd06c6bdf1fd397701ae93f8bd6..d38e0e653e898771b9839337473f98e50550be9a 100644 (file)
@@ -5,19 +5,18 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.genius.mdsalutil.tests;
 
 import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 import static org.opendaylight.genius.mdsalutil.NWUtil.getEtherTypeFromIpPrefix;
 import static org.opendaylight.genius.mdsalutil.NWUtil.isIpAddressInRange;
 
 import org.junit.Test;
 import org.opendaylight.genius.mdsalutil.NwConstants;
-import org.opendaylight.infrautils.testutils.Asserts;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
@@ -117,17 +116,17 @@ public class NWUtilTest {
     }
 
     private static void assertThrowsBadAddress(final String address) {
-        final IllegalArgumentException thrown = Asserts.assertThrows(IllegalArgumentException.class, () -> {
+        final IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> {
             getEtherTypeFromIpPrefix(address);
         });
         assertThat(thrown.getMessage()).contains(address.replaceAll("/.*", ""));
     }
 
-    private static IpAddress buildIpAddress(String ipAddress) {
+    private static IpAddress buildIpAddress(final String ipAddress) {
         return IpAddressBuilder.getDefaultInstance(ipAddress);
     }
 
-    private static IpPrefix buildIpPrefix(String cidr) {
+    private static IpPrefix buildIpPrefix(final String cidr) {
         return IpPrefixBuilder.getDefaultInstance(cidr);
     }
 }
index f050581c12fb1f85c174c855262d8f9647a896c1..eac26191ef86b47571e7241710c6747c5e8d6edd 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.genius.datastoreutils.testutils.tests;
 
 import static com.google.common.truth.Truth.assertThat;
-import static org.opendaylight.infrautils.testutils.Asserts.assertThrows;
+import static org.junit.Assert.assertThrows;
 
 import java.util.concurrent.atomic.AtomicBoolean;
 import org.junit.Test;
index 4a25bb8d2e1e511928001a340f904fabedde7fb2..8a3408aa668d3607f3f25ef829216ef4d90669d0 100644 (file)
@@ -8,23 +8,21 @@
 package org.opendaylight.genius.infra.tests;
 
 import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
 
 import org.junit.Test;
 import org.opendaylight.genius.infra.Datastore;
-import org.opendaylight.infrautils.testutils.Asserts;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 
 public class DatastoreTest {
-
     @Test
     public void testDatastore() {
         assertThat(Datastore.toType(Datastore.CONFIGURATION)).isEqualTo(LogicalDatastoreType.CONFIGURATION);
         assertThat(Datastore.toType(Datastore.OPERATIONAL)).isEqualTo(LogicalDatastoreType.OPERATIONAL);
-        Asserts.assertThrows(NullPointerException.class, () -> Datastore.toType(null));
+        assertThrows(NullPointerException.class, () -> Datastore.toType(null));
 
         assertThat(Datastore.toClass(LogicalDatastoreType.CONFIGURATION)).isEqualTo(Datastore.CONFIGURATION);
         assertThat(Datastore.toClass(LogicalDatastoreType.OPERATIONAL)).isEqualTo(Datastore.OPERATIONAL);
-        Asserts.assertThrows(NullPointerException.class, () -> Datastore.toClass(null));
+        assertThrows(NullPointerException.class, () -> Datastore.toClass(null));
     }
-
 }
index 66787432efd9d5ac483870e4b040c476a6f75358..db4c22ab78ca0aff9fa010685d9272fece9f8786 100644 (file)
@@ -9,13 +9,13 @@ package org.opendaylight.genius.infra.tests;
 
 import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY;
 import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.path;
 import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList;
 import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
-import static org.opendaylight.infrautils.testutils.Asserts.assertThrows;
 
 import java.io.IOException;
 import java.util.concurrent.ExecutionException;
index 4ccf892e0cbf262de10a642aac00be505f7be777..dd35684ec445e4ba27cb46f5150fd1f45d265cab 100644 (file)
@@ -9,12 +9,12 @@
 
 import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.TOP_FOO_KEY;
 import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.path;
 import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList;
-import static org.opendaylight.infrautils.testutils.Asserts.assertThrows;
 import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
 import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL;