Rather than using String operations, use assertThat() and matchers.
Change-Id: I0e76854950965fbfef739c38b061ccda1a9f1e37
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
*/
package org.opendaylight.controller.cluster.datastore;
*/
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;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
CreateTransactionReply.class);
final String path = reply.getTransactionPath().toString();
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())));
}
shardID.getShardName(), shardID.getMemberName().getName())));
}
CreateTransactionReply.class);
final String path = reply.getTransactionPath().toString();
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())));
}
"/user/testCreateTransactionOnChain/shard-%s-%s:ShardTransactionTest@0:",
shardID.getShardName(), shardID.getMemberName().getName())));
}
.fromSerializable(testKit.expectMsgClass(duration, ReadyTransactionReply.class));
String pathSuffix = shard.path().toString().replaceFirst("akka://test", "");
.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());
// Send the CanCommitTransaction message for the first Tx.
shard.tell(new CanCommitTransaction(transactionID1, CURRENT_VERSION).toSerializable(), testKit.getRef());