[GitHub] [commons-collections] nhojpatrick commented on a change in pull request #282: JUnit v5 assertThrows no2
nhojpatrick commented on a change in pull request #282: URL: https://github.com/apache/commons-collections/pull/282#discussion_r818415380 ## File path: src/test/java/org/apache/commons/collections4/iterators/ObjectArrayListIteratorTest.java ## @@ -101,15 +102,8 @@ public void testListIteratorSet() { // a call to set() before a call to next() or previous() should throw an IllegalStateException iter = makeArrayListIterator((E[]) testArray); -try { -iter.set((E) "should fail"); -fail("ListIterator#set should fail if next() or previous() have not yet been called."); -} catch (final IllegalStateException e) { -// expected -} catch (final Throwable t) { // should never happen -fail(t.toString()); -} - +ListIterator finalIter = iter; +assertThrows(IllegalStateException.class, () -> finalIter.set((E) "should fail")); Review comment: ditto -- 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: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [commons-collections] nhojpatrick commented on a change in pull request #282: JUnit v5 assertThrows no2
nhojpatrick commented on a change in pull request #282: URL: https://github.com/apache/commons-collections/pull/282#discussion_r818414768 ## File path: src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapper2Test.java ## @@ -134,11 +131,7 @@ public void testRemove() { assertEquals(-1, iter.previousIndex()); assertEquals(0, iter.nextIndex()); -try { -iter.remove(); -fail("ListIteratorWrapper#remove() should fail; must be repositioned first"); -} catch (final IllegalStateException e) { -} +assertThrows(IllegalStateException.class, () -> iter.remove()); Review comment: ditto -- 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: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [commons-collections] nhojpatrick commented on a change in pull request #282: JUnit v5 assertThrows no2
nhojpatrick commented on a change in pull request #282: URL: https://github.com/apache/commons-collections/pull/282#discussion_r818414461 ## File path: src/test/java/org/apache/commons/collections4/iterators/ListIteratorWrapper2Test.java ## @@ -109,11 +110,7 @@ public void testRemove() { assertEquals(-1, iter.previousIndex()); assertEquals(0, iter.nextIndex()); -try { -iter.remove(); -fail("ListIteratorWrapper#remove() should fail; must be initially positioned first"); -} catch (final IllegalStateException e) { -} +assertThrows(IllegalStateException.class, () -> iter.remove()); Review comment: ditto too -- 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: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [commons-collections] nhojpatrick commented on a change in pull request #282: JUnit v5 assertThrows no2
nhojpatrick commented on a change in pull request #282: URL: https://github.com/apache/commons-collections/pull/282#discussion_r818414154 ## File path: src/test/java/org/apache/commons/collections4/iterators/ArrayListIteratorTest.java ## @@ -104,15 +105,8 @@ public void testListIteratorSet() { // a call to set() before a call to next() or previous() should throw an IllegalStateException iter = makeArrayListIterator(testArray); -try { -iter.set((E) "should fail"); -fail("ListIterator#set should fail if next() or previous() have not yet been called."); -} catch (final IllegalStateException e) { -// expected -} catch (final Throwable t) { // should never happen -fail(t.toString()); -} - +ListIterator finalIter = iter; +assertThrows(IllegalStateException.class, () -> finalIter.set((E) "should fail")); Review comment: ditto -- 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: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [commons-collections] nhojpatrick commented on a change in pull request #282: JUnit v5 assertThrows no2
nhojpatrick commented on a change in pull request #282: URL: https://github.com/apache/commons-collections/pull/282#discussion_r818413283 ## File path: src/test/java/org/apache/commons/collections4/comparators/ComparatorChainTest.java ## @@ -67,11 +68,8 @@ public void testBadNoopComparatorChain() { final ComparatorChain chain = new ComparatorChain<>(); final Integer i1 = 4; final Integer i2 = 6; -try { -chain.compare(i1, i2); -fail("An exception should be thrown when a chain contains zero comparators."); -} catch (final UnsupportedOperationException e) { -} + +assertThrows(UnsupportedOperationException.class, () -> chain.compare(i1, i2)); Review comment: ditto too -- 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: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [commons-collections] nhojpatrick commented on a change in pull request #282: JUnit v5 assertThrows no2
nhojpatrick commented on a change in pull request #282: URL: https://github.com/apache/commons-collections/pull/282#discussion_r818412923 ## File path: src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionTest.java ## @@ -99,12 +98,9 @@ public void testIllegalAddAll() { elements.add((E) "two"); elements.add((E) Integer.valueOf(3)); elements.add((E) "four"); -try { -c.addAll(elements); -fail("Integer should fail string predicate."); -} catch (final IllegalArgumentException e) { -// expected -} + +assertThrows(IllegalArgumentException.class, () -> c.addAll(elements)); Review comment: ditto too -- 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: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [commons-collections] nhojpatrick commented on a change in pull request #282: JUnit v5 assertThrows no2
nhojpatrick commented on a change in pull request #282: URL: https://github.com/apache/commons-collections/pull/282#discussion_r818412579 ## File path: src/test/java/org/apache/commons/collections4/collection/PredicatedCollectionTest.java ## @@ -82,12 +84,9 @@ public PredicatedCollectionTest(final String name) { public void testIllegalAdd() { final Collection c = makeTestCollection(); final Integer i = 3; -try { -c.add((E) i); -fail("Integer should fail string predicate."); -} catch (final IllegalArgumentException e) { -// expected -} + +assertThrows(IllegalArgumentException.class, () -> c.add((E) i)); Review comment: added back in next push. -- 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: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org