/
ListUtilTest.java
42 lines (34 loc) · 1.27 KB
/
ListUtilTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito.internal.util.collections;
import static java.util.Arrays.asList;
import static org.junit.Assert.assertTrue;
import java.util.LinkedList;
import java.util.List;
import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.mockito.internal.util.collections.ListUtil.Filter;
import org.mockitoutil.TestBase;
public class ListUtilTest extends TestBase {
@Test
public void shouldFilterList() throws Exception {
List<String> list = asList("one", "x", "two", "x", "three");
List<String> filtered =
ListUtil.filter(
list,
new Filter<String>() {
public boolean isOut(String object) {
return object == "x";
}
});
Assertions.assertThat(filtered).containsSequence("one", "two", "three");
}
@Test
public void shouldReturnEmptyIfEmptyListGiven() throws Exception {
List<Object> list = new LinkedList<Object>();
List<Object> filtered = ListUtil.filter(list, null);
assertTrue(filtered.isEmpty());
}
}