Skip to content

Commit

Permalink
[COLLECTIONS-777] Migrate to JUnit 5
Browse files Browse the repository at this point in the history
[COLLECTIONS-809] Update try/catch/fail logic to assertThrows
  • Loading branch information
garydgregory committed Oct 20, 2024
1 parent 2ceab70 commit 161e1f1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ public void testMapEntrySetIteratorEntrySetValueCrossCheck() {
TestBidiMapEntrySet.this.verify();

if (!isSetValueSupported()) {
try {
entry1.setValue(newValue1);
} catch (final UnsupportedOperationException ex) {
}
assertThrows(UnsupportedOperationException.class, () -> entry1.setValue(newValue1));
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @param <K> the type of the keys in this map
* @param <V> the type of the values in this map
*/
public class AbstractOrderedBidiMapDecoratorTest<K, V>
public abstract class AbstractOrderedBidiMapDecoratorTest<K, V>
extends AbstractOrderedBidiMapTest<K, V> {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,8 @@ public void testAddNodeAfter() {
resetEmpty();
final AbstractLinkedList<E> list = getCollection();
if (!isAddSupported()) {
try {
list.addFirst(null);
} catch (final UnsupportedOperationException ex) {
}
assertThrows(UnsupportedOperationException.class, () -> list.addFirst(null));
}

list.addFirst((E) "value1");
list.addNodeAfter(list.getNode(0, false), (E) "value2");
assertEquals("value1", list.getFirst());
Expand Down Expand Up @@ -110,10 +106,7 @@ public void testRemoveFirst() {
resetEmpty();
final AbstractLinkedList<E> list = getCollection();
if (!isRemoveSupported()) {
try {
list.removeFirst();
} catch (final UnsupportedOperationException ex) {
}
assertThrows(UnsupportedOperationException.class, list::removeFirst);
}

list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
Expand All @@ -136,10 +129,7 @@ public void testRemoveLast() {
resetEmpty();
final AbstractLinkedList<E> list = getCollection();
if (!isRemoveSupported()) {
try {
list.removeLast();
} catch (final UnsupportedOperationException ex) {
}
assertThrows(UnsupportedOperationException.class, list::removeLast);
}

list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -819,15 +819,9 @@ public void testListListIterator() {
@Test
public void testListListIteratorByIndex() {
resetFull();
try {
getCollection().listIterator(-1);
} catch (final IndexOutOfBoundsException ex) {
}
assertThrows(IndexOutOfBoundsException.class, () -> getCollection().listIterator(-1));
resetFull();
try {
getCollection().listIterator(getCollection().size() + 1);
} catch (final IndexOutOfBoundsException ex) {
}
assertThrows(IndexOutOfBoundsException.class, () -> getCollection().listIterator(getCollection().size() + 1));
resetFull();
for (int i = 0; i <= getConfirmed().size(); i++) {
forwardTest(getCollection().listIterator(i), i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,7 @@ public void testMapEntrySetIteratorEntrySetValue() {
verify();

if (!isSetValueSupported()) {
try {
entry1.setValue(newValue1);
} catch (final UnsupportedOperationException ex) {
}
assertThrows(UnsupportedOperationException.class, () -> entry1.setValue(newValue1));
return;
}

Expand Down

0 comments on commit 161e1f1

Please sign in to comment.