Migrate Assert.assertThat() 78/88878/4
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 3 Apr 2020 15:42:46 +0000 (17:42 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 3 Apr 2020 16:41:49 +0000 (18:41 +0200)
This method has been migrated, make sure we use its new place.

Change-Id: Ib17471706233150f26a452b8bca36914a95fc8db
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AbstractClientConnectionTest.java
opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AbstractTransmitQueueTest.java
opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/TransmittingTransmitQueueTest.java
opendaylight/md-sal/sal-cluster-admin-impl/src/test/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcServiceTest.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteSchemaProviderTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractProxyTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/RemoteProxyTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/TransactionRateLimiterTest.java
opendaylight/md-sal/sal-distributed-eos/src/test/java/org/opendaylight/controller/cluster/entityownership/DistributedEntityOwnershipIntegrationTest.java

index 1d38b62..36d97a1 100644 (file)
@@ -8,9 +8,9 @@
 package org.opendaylight.controller.cluster.access.client;
 
 import static org.hamcrest.CoreMatchers.hasItems;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.isA;
 import static org.mockito.Mockito.mock;
index 7bebd7a..6e59daa 100644 (file)
@@ -8,9 +8,9 @@
 package org.opendaylight.controller.cluster.access.client;
 
 import static org.hamcrest.CoreMatchers.everyItem;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.opendaylight.controller.cluster.access.client.ConnectionEntryMatcher.entryWithRequest;
index d6e9f5c..b40aefb 100644 (file)
@@ -8,9 +8,9 @@
 package org.opendaylight.controller.cluster.access.client;
 
 import static org.hamcrest.CoreMatchers.everyItem;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doAnswer;
index cab3281..bb47af6 100644 (file)
@@ -11,11 +11,11 @@ import static java.lang.Boolean.FALSE;
 import static java.lang.Boolean.TRUE;
 import static org.hamcrest.CoreMatchers.anyOf;
 import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.opendaylight.controller.cluster.datastore.MemberNode.verifyNoShardPresent;
index 06d3369..2a8ddd2 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.controller.cluster.schema.provider.impl;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.instanceOf;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.mockito.Mockito.doReturn;
index 158c228..b13bbe7 100644 (file)
@@ -9,7 +9,11 @@ package org.opendaylight.controller.cluster.databroker.actors.dds;
 
 import static org.hamcrest.CoreMatchers.allOf;
 import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.isA;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
@@ -27,7 +31,6 @@ import java.util.function.Consumer;
 import org.hamcrest.BaseMatcher;
 import org.hamcrest.Description;
 import org.junit.After;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -192,39 +195,39 @@ public abstract class AbstractProxyTransactionTest<T extends AbstractProxyTransa
         transaction.replayMessages(mockSuccessor, entries);
 
         final ModifyTransactionRequest transformed = successor.expectTransactionRequest(ModifyTransactionRequest.class);
-        Assert.assertNotNull(transformed);
-        Assert.assertEquals(successful1.getSequence(), transformed.getSequence());
-        Assert.assertTrue(transformed.getPersistenceProtocol().isPresent());
-        Assert.assertEquals(PersistenceProtocol.ABORT, transformed.getPersistenceProtocol().get());
+        assertNotNull(transformed);
+        assertEquals(successful1.getSequence(), transformed.getSequence());
+        assertTrue(transformed.getPersistenceProtocol().isPresent());
+        assertEquals(PersistenceProtocol.ABORT, transformed.getPersistenceProtocol().get());
 
         ReadTransactionRequest tmpRead = successor.expectTransactionRequest(ReadTransactionRequest.class);
-        Assert.assertNotNull(tmpRead);
-        Assert.assertEquals(successful2.getTarget(), tmpRead.getTarget());
-        Assert.assertEquals(successful2.getSequence(), tmpRead.getSequence());
-        Assert.assertEquals(successful2.getPath(), tmpRead.getPath());
-        Assert.assertEquals(successor.localActor(), tmpRead.getReplyTo());
+        assertNotNull(tmpRead);
+        assertEquals(successful2.getTarget(), tmpRead.getTarget());
+        assertEquals(successful2.getSequence(), tmpRead.getSequence());
+        assertEquals(successful2.getPath(), tmpRead.getPath());
+        assertEquals(successor.localActor(), tmpRead.getReplyTo());
 
         tmpRead = successor.expectTransactionRequest(ReadTransactionRequest.class);
-        Assert.assertNotNull(tmpRead);
-        Assert.assertEquals(request1.getTarget(), tmpRead.getTarget());
-        Assert.assertEquals(request1.getSequence(), tmpRead.getSequence());
-        Assert.assertEquals(request1.getPath(), tmpRead.getPath());
-        Assert.assertEquals(successor.localActor(), tmpRead.getReplyTo());
+        assertNotNull(tmpRead);
+        assertEquals(request1.getTarget(), tmpRead.getTarget());
+        assertEquals(request1.getSequence(), tmpRead.getSequence());
+        assertEquals(request1.getPath(), tmpRead.getPath());
+        assertEquals(successor.localActor(), tmpRead.getReplyTo());
 
         final ExistsTransactionRequest tmpExist = successor.expectTransactionRequest(ExistsTransactionRequest.class);
-        Assert.assertNotNull(tmpExist);
-        Assert.assertEquals(request2.getTarget(), tmpExist.getTarget());
-        Assert.assertEquals(request2.getSequence(), tmpExist.getSequence());
-        Assert.assertEquals(request2.getPath(), tmpExist.getPath());
-        Assert.assertEquals(successor.localActor(), tmpExist.getReplyTo());
+        assertNotNull(tmpExist);
+        assertEquals(request2.getTarget(), tmpExist.getTarget());
+        assertEquals(request2.getSequence(), tmpExist.getSequence());
+        assertEquals(request2.getPath(), tmpExist.getPath());
+        assertEquals(successor.localActor(), tmpExist.getReplyTo());
     }
 
     protected void checkModifications(final ModifyTransactionRequest modifyRequest) {
         final List<TransactionModification> modifications = modifyRequest.getModifications();
-        Assert.assertEquals(3, modifications.size());
-        Assert.assertThat(modifications, hasItem(allOf(isA(TransactionWrite.class), hasPath(PATH_1))));
-        Assert.assertThat(modifications, hasItem(allOf(isA(TransactionMerge.class), hasPath(PATH_2))));
-        Assert.assertThat(modifications, hasItem(allOf(isA(TransactionDelete.class), hasPath(PATH_3))));
+        assertEquals(3, modifications.size());
+        assertThat(modifications, hasItem(allOf(isA(TransactionWrite.class), hasPath(PATH_1))));
+        assertThat(modifications, hasItem(allOf(isA(TransactionMerge.class), hasPath(PATH_2))));
+        assertThat(modifications, hasItem(allOf(isA(TransactionDelete.class), hasPath(PATH_3))));
     }
 
     @SuppressWarnings("checkstyle:hiddenField")
@@ -244,9 +247,9 @@ public abstract class AbstractProxyTransactionTest<T extends AbstractProxyTransa
         transaction.handleReplayedRemoteRequest(request, createCallbackMock(), Ticker.systemTicker().read());
         final RequestEnvelope envelope = backendProbe.expectMsgClass(RequestEnvelope.class);
         final R received = (R) envelope.getMessage();
-        Assert.assertTrue(received.getClass().equals(request.getClass()));
-        Assert.assertEquals(TRANSACTION_ID, received.getTarget());
-        Assert.assertEquals(clientContextProbe.ref(), received.getReplyTo());
+        assertTrue(received.getClass().equals(request.getClass()));
+        assertEquals(TRANSACTION_ID, received.getTarget());
+        assertEquals(clientContextProbe.ref(), received.getReplyTo());
         return received;
     }
 
@@ -269,7 +272,7 @@ public abstract class AbstractProxyTransactionTest<T extends AbstractProxyTransa
     }
 
     protected static BaseMatcher<TransactionModification> hasPath(final YangInstanceIdentifier path) {
-        return new BaseMatcher<TransactionModification>() {
+        return new BaseMatcher<>() {
 
             @Override
             public boolean matches(final Object item) {
index 2731b7d..497622f 100644 (file)
@@ -10,6 +10,9 @@ package org.opendaylight.controller.cluster.databroker.actors.dds;
 import static org.hamcrest.CoreMatchers.both;
 import static org.hamcrest.CoreMatchers.hasItem;
 import static org.hamcrest.CoreMatchers.isA;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtils.assertFutureEquals;
 
 import akka.testkit.TestProbe;
@@ -17,7 +20,6 @@ import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.List;
 import java.util.Optional;
-import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.access.commands.ExistsTransactionRequest;
 import org.opendaylight.controller.cluster.access.commands.ExistsTransactionSuccess;
@@ -99,8 +101,8 @@ public class RemoteProxyTransactionTest extends AbstractProxyTransactionTest<Rem
         final ListenableFuture<Boolean> result = transaction.directCommit();
         final TransactionTester<RemoteProxyTransaction> tester = getTester();
         final ModifyTransactionRequest req = tester.expectTransactionRequest(ModifyTransactionRequest.class);
-        Assert.assertTrue(req.getPersistenceProtocol().isPresent());
-        Assert.assertEquals(PersistenceProtocol.SIMPLE, req.getPersistenceProtocol().get());
+        assertTrue(req.getPersistenceProtocol().isPresent());
+        assertEquals(PersistenceProtocol.SIMPLE, req.getPersistenceProtocol().get());
         tester.replySuccess(new TransactionCommitSuccess(TRANSACTION_ID, req.getSequence()));
         assertFutureEquals(true, result);
     }
@@ -150,9 +152,9 @@ public class RemoteProxyTransactionTest extends AbstractProxyTransactionTest<Rem
         builder.setCommit(false);
         final ModifyTransactionRequest request = builder.build();
         final ModifyTransactionRequest received = testForwardToRemote(request, ModifyTransactionRequest.class);
-        Assert.assertEquals(request.getPersistenceProtocol(), received.getPersistenceProtocol());
-        Assert.assertEquals(request.getModifications(), received.getModifications());
-        Assert.assertEquals(request.getTarget(), received.getTarget());
+        assertEquals(request.getPersistenceProtocol(), received.getPersistenceProtocol());
+        assertEquals(request.getModifications(), received.getModifications());
+        assertEquals(request.getTarget(), received.getTarget());
     }
 
     @Test
@@ -164,9 +166,9 @@ public class RemoteProxyTransactionTest extends AbstractProxyTransactionTest<Rem
         builder.setCommit(true);
         final ModifyTransactionRequest request = builder.build();
         final ModifyTransactionRequest received = testForwardToRemote(request, ModifyTransactionRequest.class);
-        Assert.assertEquals(request.getPersistenceProtocol(), received.getPersistenceProtocol());
-        Assert.assertEquals(request.getModifications(), received.getModifications());
-        Assert.assertEquals(request.getTarget(), received.getTarget());
+        assertEquals(request.getPersistenceProtocol(), received.getPersistenceProtocol());
+        assertEquals(request.getModifications(), received.getModifications());
+        assertEquals(request.getTarget(), received.getTarget());
     }
 
     @Test
@@ -178,9 +180,9 @@ public class RemoteProxyTransactionTest extends AbstractProxyTransactionTest<Rem
         builder.setAbort();
         final ModifyTransactionRequest request = builder.build();
         final ModifyTransactionRequest received = testForwardToRemote(request, ModifyTransactionRequest.class);
-        Assert.assertEquals(request.getTarget(), received.getTarget());
-        Assert.assertTrue(received.getPersistenceProtocol().isPresent());
-        Assert.assertEquals(PersistenceProtocol.ABORT, received.getPersistenceProtocol().get());
+        assertEquals(request.getTarget(), received.getTarget());
+        assertTrue(received.getPersistenceProtocol().isPresent());
+        assertEquals(PersistenceProtocol.ABORT, received.getPersistenceProtocol().get());
     }
 
     @Test
@@ -189,8 +191,8 @@ public class RemoteProxyTransactionTest extends AbstractProxyTransactionTest<Rem
         final ReadTransactionRequest request =
                 new ReadTransactionRequest(TRANSACTION_ID, 0L, probe.ref(), PATH_1, false);
         final ReadTransactionRequest received = testForwardToRemote(request, ReadTransactionRequest.class);
-        Assert.assertEquals(request.getTarget(), received.getTarget());
-        Assert.assertEquals(request.getPath(), received.getPath());
+        assertEquals(request.getTarget(), received.getTarget());
+        assertEquals(request.getPath(), received.getPath());
     }
 
     @Test
@@ -199,8 +201,8 @@ public class RemoteProxyTransactionTest extends AbstractProxyTransactionTest<Rem
         final ExistsTransactionRequest request =
                 new ExistsTransactionRequest(TRANSACTION_ID, 0L, probe.ref(), PATH_1, false);
         final ExistsTransactionRequest received = testForwardToRemote(request, ExistsTransactionRequest.class);
-        Assert.assertEquals(request.getTarget(), received.getTarget());
-        Assert.assertEquals(request.getPath(), received.getPath());
+        assertEquals(request.getTarget(), received.getTarget());
+        assertEquals(request.getPath(), received.getPath());
     }
 
     @Test
@@ -209,7 +211,7 @@ public class RemoteProxyTransactionTest extends AbstractProxyTransactionTest<Rem
         final TransactionPreCommitRequest request =
                 new TransactionPreCommitRequest(TRANSACTION_ID, 0L, probe.ref());
         final TransactionPreCommitRequest received = testForwardToRemote(request, TransactionPreCommitRequest.class);
-        Assert.assertEquals(request.getTarget(), received.getTarget());
+        assertEquals(request.getTarget(), received.getTarget());
     }
 
     @Test
@@ -218,18 +220,16 @@ public class RemoteProxyTransactionTest extends AbstractProxyTransactionTest<Rem
         final TransactionDoCommitRequest request =
                 new TransactionDoCommitRequest(TRANSACTION_ID, 0L, probe.ref());
         final TransactionDoCommitRequest received = testForwardToRemote(request, TransactionDoCommitRequest.class);
-        Assert.assertEquals(request.getTarget(), received.getTarget());
+        assertEquals(request.getTarget(), received.getTarget());
     }
 
 
-    private <T extends TransactionModification> void testModification(final Runnable modification,
-                                                                      final Class<T> cls,
-                                                                      final YangInstanceIdentifier expectedPath) {
+    private <T extends TransactionModification> void testModification(final Runnable modification, final Class<T> cls,
+            final YangInstanceIdentifier expectedPath) {
         modification.run();
         final ModifyTransactionRequest request = transaction.commitRequest(false);
         final List<TransactionModification> modifications = request.getModifications();
-        Assert.assertEquals(1, modifications.size());
-        Assert.assertThat(modifications, hasItem(both(isA(cls)).and(hasPath(expectedPath))));
+        assertEquals(1, modifications.size());
+        assertThat(modifications, hasItem(both(isA(cls)).and(hasPath(expectedPath))));
     }
-
 }
index fef8206..0e0f026 100644 (file)
@@ -5,11 +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.controller.cluster.datastore.utils;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
@@ -280,15 +279,15 @@ public class TransactionRateLimiterTest {
     }
 
     public Matcher<Double> approximately(final double val) {
-        return new BaseMatcher<Double>() {
+        return new BaseMatcher<>() {
             @Override
-            public boolean matches(Object obj) {
+            public boolean matches(final Object obj) {
                 Double value = (Double) obj;
                 return value >= val && value <= val + 1;
             }
 
             @Override
-            public void describeTo(Description description) {
+            public void describeTo(final Description description) {
                 description.appendText("> " + val + " < " + (val + 1));
             }
         };
index 07f071d..a743d6d 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.controller.cluster.entityownership;
 
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.AdditionalMatchers.or;
 import static org.mockito.Mockito.doNothing;

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.