szetszwo commented on code in PR #981:
URL: https://github.com/apache/ratis/pull/981#discussion_r1419691617
##########
ratis-test/src/test/java/org/apache/ratis/util/TestPreconditions.java:
##########
@@ -50,4 +52,22 @@ public void testAssertUnique() {
Preconditions.assertUnique(three, Arrays.asList(4, 5, 6));
}
+
+ @Test(timeout = 1000)
+ public void testAssertNull() {
+ final Map<String, String> map = new HashMap<>();
+ final String key = "abc1234";
+ // putNew will call Preconditions.assertNull(..) to assert the entry does
not exist in the map
+ // putNew the first time should work
+ CollectionUtils.putNew(key, key, map, () -> "m");
+ Preconditions.assertTrue(map.containsKey(key));
+
+ // putNew the second time should fail
+ final Throwable e = testFailureCase("put " + key + " again",
+ () -> CollectionUtils.putNew(key, key, map, () -> "m"),
+ IllegalStateException.class);
+ LOG.info("Expected to get:", e);
Review Comment:
Let's remove it then.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]