nhojpatrick commented on a change in pull request #281:
URL:
https://github.com/apache/commons-collections/pull/281#discussion_r818161889
##########
File path:
src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java
##########
@@ -243,28 +242,26 @@ public void testPrefixMap() {
map = trie.prefixMap("Ab");
Assertions.assertTrue(map.isEmpty());
Assertions.assertEquals(0, map.size());
- try {
- final Object o = map.firstKey();
- Assertions.fail("got a first key: " + o);
- } catch(final NoSuchElementException nsee) {}
- try {
- final Object o = map.lastKey();
- Assertions.fail("got a last key: " + o);
- } catch(final NoSuchElementException nsee) {}
+
+ final SortedMap<String, String> map1 = map;
+ Assertions.assertThrows(NoSuchElementException.class, () ->
map1.firstKey());
+
+ final SortedMap<String, String> map2 = map;
+ Assertions.assertThrows(NoSuchElementException.class, () ->
map2.lastKey());
+
iterator = map.values().iterator();
Assertions.assertFalse(iterator.hasNext());
map = trie.prefixMap("Albertooo");
Assertions.assertTrue(map.isEmpty());
Assertions.assertEquals(0, map.size());
- try {
- final Object o = map.firstKey();
- Assertions.fail("got a first key: " + o);
- } catch(final NoSuchElementException nsee) {}
- try {
- final Object o = map.lastKey();
- Assertions.fail("got a last key: " + o);
- } catch(final NoSuchElementException nsee) {}
+
+ final SortedMap<String, String> map3 = map;
+ Assertions.assertThrows(NoSuchElementException.class, () ->
map3.firstKey());
+
+ final SortedMap<String, String> map4 = map;
+ Assertions.assertThrows(NoSuchElementException.class, () ->
map4.lastKey());
Review comment:
I keep getting told to drop the failure message or not check the
exception message, so assumed that is the apache commons standard. I can
change, but it's slightly confusing as each apache commons pr review appears to
have different criterial or standards that I need to follow.
--
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]