From: Robert Varga Date: Fri, 3 Apr 2020 15:42:46 +0000 (+0200) Subject: Migrate Assert.assertThat() X-Git-Tag: v2.0.0~46 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=01ab2b80c3aa90421ad602153e0fe140b071aa5d Migrate Assert.assertThat() This method has been migrated, make sure we use its new place. Change-Id: Ib17471706233150f26a452b8bca36914a95fc8db Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AbstractClientConnectionTest.java b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AbstractClientConnectionTest.java index 1d38b62b8d..36d97a1436 100644 --- a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AbstractClientConnectionTest.java +++ b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AbstractClientConnectionTest.java @@ -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; diff --git a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AbstractTransmitQueueTest.java b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AbstractTransmitQueueTest.java index 7bebd7ac74..6e59daa4b3 100644 --- a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AbstractTransmitQueueTest.java +++ b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AbstractTransmitQueueTest.java @@ -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; diff --git a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/TransmittingTransmitQueueTest.java b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/TransmittingTransmitQueueTest.java index d6e9f5cec5..b40aefb663 100644 --- a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/TransmittingTransmitQueueTest.java +++ b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/TransmittingTransmitQueueTest.java @@ -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; diff --git a/opendaylight/md-sal/sal-cluster-admin-impl/src/test/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcServiceTest.java b/opendaylight/md-sal/sal-cluster-admin-impl/src/test/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcServiceTest.java index cab3281c80..bb47af6400 100644 --- a/opendaylight/md-sal/sal-cluster-admin-impl/src/test/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcServiceTest.java +++ b/opendaylight/md-sal/sal-cluster-admin-impl/src/test/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcServiceTest.java @@ -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; diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteSchemaProviderTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteSchemaProviderTest.java index 06d33690f0..2a8ddd2e56 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteSchemaProviderTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteSchemaProviderTest.java @@ -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; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractProxyTransactionTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractProxyTransactionTest.java index 158c228220..b13bbe7f6c 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractProxyTransactionTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractProxyTransactionTest.java @@ -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 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 hasPath(final YangInstanceIdentifier path) { - return new BaseMatcher() { + return new BaseMatcher<>() { @Override public boolean matches(final Object item) { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/RemoteProxyTransactionTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/RemoteProxyTransactionTest.java index 2731b7d315..497622f631 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/RemoteProxyTransactionTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/RemoteProxyTransactionTest.java @@ -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 result = transaction.directCommit(); final TransactionTester 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 void testModification(final Runnable modification, - final Class cls, - final YangInstanceIdentifier expectedPath) { + private void testModification(final Runnable modification, final Class cls, + final YangInstanceIdentifier expectedPath) { modification.run(); final ModifyTransactionRequest request = transaction.commitRequest(false); final List 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)))); } - } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/TransactionRateLimiterTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/TransactionRateLimiterTest.java index fef8206885..0e0f0266db 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/TransactionRateLimiterTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/TransactionRateLimiterTest.java @@ -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 approximately(final double val) { - return new BaseMatcher() { + 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)); } }; diff --git a/opendaylight/md-sal/sal-distributed-eos/src/test/java/org/opendaylight/controller/cluster/entityownership/DistributedEntityOwnershipIntegrationTest.java b/opendaylight/md-sal/sal-distributed-eos/src/test/java/org/opendaylight/controller/cluster/entityownership/DistributedEntityOwnershipIntegrationTest.java index 07f071d9b1..a743d6db21 100644 --- a/opendaylight/md-sal/sal-distributed-eos/src/test/java/org/opendaylight/controller/cluster/entityownership/DistributedEntityOwnershipIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-eos/src/test/java/org/opendaylight/controller/cluster/entityownership/DistributedEntityOwnershipIntegrationTest.java @@ -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;