From 63b435c0974f08f3f38ae8d0d20cd28a27f51bd6 Mon Sep 17 00:00:00 2001 From: Niket Agrawal Date: Fri, 20 Oct 2023 18:43:27 +0530 Subject: [PATCH] Method removal for Iterators --- .../FirstMatchingElementUnitTest.java | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/core-java-modules/core-java-streams-5/src/test/java/com/baeldung/streams/firstmatchingelement/FirstMatchingElementUnitTest.java b/core-java-modules/core-java-streams-5/src/test/java/com/baeldung/streams/firstmatchingelement/FirstMatchingElementUnitTest.java index d1ca588047..373833e9f7 100644 --- a/core-java-modules/core-java-streams-5/src/test/java/com/baeldung/streams/firstmatchingelement/FirstMatchingElementUnitTest.java +++ b/core-java-modules/core-java-streams-5/src/test/java/com/baeldung/streams/firstmatchingelement/FirstMatchingElementUnitTest.java @@ -2,9 +2,7 @@ package com.baeldung.streams.firstmatchingelement; import static org.junit.jupiter.api.Assertions.assertEquals; -import java.util.Iterator; import java.util.List; -import java.util.ListIterator; import java.util.stream.IntStream; import org.apache.commons.collections4.IterableUtils; @@ -28,34 +26,6 @@ public class FirstMatchingElementUnitTest { assertEquals(1, index); } - @Test - public void whenUsingIterator_thenFindFirstMatchingUserIndex() { - int index = -1; - Iterator iterator = userList.iterator(); - while (iterator.hasNext()) { - User user = iterator.next(); - if (searchName.equals(user.getUserName())) { - index = userList.indexOf(user); - break; - } - } - assertEquals(1, index); - } - - @Test - public void whenUsingListIterator_thenFindFirstMatchingUserIndex() { - int index = -1; - ListIterator listIterator = userList.listIterator(); - while (listIterator.hasNext()) { - if (searchName.equals(listIterator.next() - .getUserName())) { - index = listIterator.previousIndex(); - break; - } - } - assertEquals(1, index); - } - @Test public void whenUsingIntStream_thenFindFirstMatchingUserIndex() { int index = IntStream.range(0, userList.size() - 1)