Skip to content

Commit 0a444d3

Browse files
committed
Renamed unit tests for ConcurrentModificationUnit
1 parent c40d696 commit 0a444d3

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

‎core-java/src/test/java/com/baeldung/java/concurrentmodificationexception/ConcurrentModificationUnitTest.java‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
public class ConcurrentModificationUnitTest {
1414
@Test(expected = ConcurrentModificationException.class)
15-
public void whilstRemovingDuringIteration_shouldThrowException() throws InterruptedException {
15+
public void givenIterating_whenRemoving_thenThrowException() throws InterruptedException {
1616

1717
ArrayList<Integer> integers = newArrayList(1, 2, 3);
1818

@@ -22,7 +22,7 @@ public void whilstRemovingDuringIteration_shouldThrowException() throws Interrup
2222
}
2323

2424
@Test
25-
public void whilstRemovingDuringIteration_shouldNotThrowException() throws InterruptedException {
25+
public void givenIterating_whenUsingIteratorRemove_thenDontError() throws InterruptedException {
2626

2727
ArrayList<Integer> integers = newArrayList(1, 2, 3);
2828

@@ -37,7 +37,7 @@ public void whilstRemovingDuringIteration_shouldNotThrowException() throws Inter
3737
}
3838

3939
@Test
40-
public void whilstRemovingDuringForEach_shouldNotThrowException() throws InterruptedException {
40+
public void givenIterating_whenUsingRemovalList_thenDontError() throws InterruptedException {
4141

4242
ArrayList<Integer> integers = newArrayList(1, 2, 3);
4343
ArrayList<Integer> toRemove = newArrayList();
@@ -51,4 +51,14 @@ public void whilstRemovingDuringForEach_shouldNotThrowException() throws Interru
5151

5252
assertThat(integers).containsExactly(1, 3);
5353
}
54+
55+
@Test
56+
public void whenUsingRemoveIf_thenRemoveElements() throws InterruptedException {
57+
58+
ArrayList<Integer> integers = newArrayList(1, 2, 3);
59+
60+
integers.removeIf((i) -> i == 2);
61+
62+
assertThat(integers).containsExactly(1, 3);
63+
}
5464
}

0 commit comments

Comments
 (0)