Hi.

Le mer. 2 mars 2022 à 23:37, GitBox <[email protected]> a écrit :
>
>
> 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.
>

Indeed, every "Commons" component is like an independent
sub-project from the POV of code management.
Applying rules consistently on all the components has never
been considered a feature, and it indeed goes in the way of
tasks like you've undertaken.
You are welcome to post ot the "dev" ML with a list of coding
style elements that might be worth harmonising.

Best,
Gilles

>
>
> --
> 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.
>

Reply via email to