Review Comments
This commit is contained in:
parent
39f5de4e30
commit
7b83abb7ae
|
@ -44,12 +44,20 @@ public class FirstMatchingElementUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenUsingTakeWhile_thenFindFirstMatchingUserIndex() {
|
public void whenUsingTakeWhile_thenFindFirstMatchingUserIndex() {
|
||||||
long predicateIndex = userList.stream()
|
long predicateIndex = userList.stream()
|
||||||
.takeWhile(user -> !user.getUserName()
|
.takeWhile(user -> !user.getUserName().equals(searchName))
|
||||||
.equals(searchName))
|
|
||||||
.count();
|
.count();
|
||||||
assertEquals(1, predicateIndex);
|
assertEquals(1, predicateIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenUsingTakeWhile_thenFindIndexFromNoMatchingElement() {
|
||||||
|
List<User> userList = List.of(new User(1, "David"), new User(2, "Vick"), new User(3, "Roger"), new User(4, "James"));
|
||||||
|
long predicateIndex = userList.stream()
|
||||||
|
.takeWhile(user -> !user.getUserName().equals(searchName))
|
||||||
|
.count();
|
||||||
|
assertEquals(4, predicateIndex);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenUsingGoogleGuava_thenFindFirstMatchingUserIndex() {
|
public void whenUsingGoogleGuava_thenFindFirstMatchingUserIndex() {
|
||||||
int index = Iterables.indexOf(userList, user -> searchName.equals(user.getUserName()));
|
int index = Iterables.indexOf(userList, user -> searchName.equals(user.getUserName()));
|
||||||
|
|
Loading…
Reference in New Issue