From 56126e6677ea666b128b25273528de24648a9904 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 21 Dec 2021 09:38:43 +0100 Subject: [PATCH] Cleanup asserts a bit Rather than using String operations, use assertThat() and matchers. Change-Id: I0e76854950965fbfef739c38b061ccda1a9f1e37 Signed-off-by: Robert Varga --- .../controller/cluster/datastore/ShardTest.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java index 7ac18e61dc..3c26d27be0 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java @@ -7,6 +7,9 @@ */ package org.opendaylight.controller.cluster.datastore; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.endsWith; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -239,8 +242,7 @@ public class ShardTest extends AbstractShardTest { CreateTransactionReply.class); final String path = reply.getTransactionPath().toString(); - assertTrue("Unexpected transaction path " + path, path.contains(String.format( - "/user/testCreateTransaction/shard-%s-%s:ShardTransactionTest@0:", + assertThat(path, containsString(String.format("/user/testCreateTransaction/shard-%s-%s:ShardTransactionTest@0:", shardID.getShardName(), shardID.getMemberName().getName()))); } @@ -258,7 +260,7 @@ public class ShardTest extends AbstractShardTest { CreateTransactionReply.class); final String path = reply.getTransactionPath().toString(); - assertTrue("Unexpected transaction path " + path, path.contains(String.format( + assertThat(path, containsString(String.format( "/user/testCreateTransactionOnChain/shard-%s-%s:ShardTransactionTest@0:", shardID.getShardName(), shardID.getMemberName().getName()))); } @@ -480,7 +482,7 @@ public class ShardTest extends AbstractShardTest { .fromSerializable(testKit.expectMsgClass(duration, ReadyTransactionReply.class)); String pathSuffix = shard.path().toString().replaceFirst("akka://test", ""); - assertTrue("Cohort path", readyReply.getCohortPath().endsWith(pathSuffix)); + assertThat(readyReply.getCohortPath(), endsWith(pathSuffix)); // Send the CanCommitTransaction message for the first Tx. shard.tell(new CanCommitTransaction(transactionID1, CURRENT_VERSION).toSerializable(), testKit.getRef()); -- 2.36.6