Modernize AbstractRequestTest 96/103096/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 4 Nov 2022 21:13:36 +0000 (22:13 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 4 Nov 2022 21:18:31 +0000 (22:18 +0100)
Use static imports and improve message assertion.

Change-Id: I97cf242781c25988bf3bcf50f76e9a2dd1b0c8fb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/AbstractRequestTest.java

index c65c1956c2a9ee1c12dae42760cbc41db6223665..e5fb8bc9cc2d6d7ce2c4bb64e68c2a970477c563 100644 (file)
@@ -7,6 +7,10 @@
  */
 package org.opendaylight.controller.cluster.access.concepts;
 
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+
 import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
 import akka.actor.ExtendedActorSystem;
@@ -14,7 +18,6 @@ import akka.serialization.JavaSerializer;
 import akka.testkit.TestProbe;
 import com.google.common.base.MoreObjects;
 import org.apache.commons.lang.SerializationUtils;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -31,13 +34,13 @@ public abstract class AbstractRequestTest<T extends Request<?, T>> {
 
     @Test
     public void getReplyToTest() {
-        Assert.assertEquals(ACTOR_REF, object().getReplyTo());
+        assertEquals(ACTOR_REF, object().getReplyTo());
     }
 
     @Test
     public void addToStringAttributesCommonTest() {
-        final MoreObjects.ToStringHelper result = object().addToStringAttributes(MoreObjects.toStringHelper(object()));
-        Assert.assertTrue(result.toString().contains("replyTo=" + ACTOR_REF));
+        final var result = object().addToStringAttributes(MoreObjects.toStringHelper(object()));
+        assertThat(result.toString(), containsString("replyTo=" + ACTOR_REF));
     }
 
     @SuppressWarnings("unchecked")
@@ -45,9 +48,9 @@ public abstract class AbstractRequestTest<T extends Request<?, T>> {
     public void serializationTest() {
         final Object deserialize = SerializationUtils.clone(object());
 
-        Assert.assertEquals(object().getTarget(), ((T) deserialize).getTarget());
-        Assert.assertEquals(object().getVersion(), ((T) deserialize).getVersion());
-        Assert.assertEquals(object().getSequence(), ((T) deserialize).getSequence());
+        assertEquals(object().getTarget(), ((T) deserialize).getTarget());
+        assertEquals(object().getVersion(), ((T) deserialize).getVersion());
+        assertEquals(object().getSequence(), ((T) deserialize).getSequence());
         doAdditionalAssertions(deserialize);
     }