BAEL-2548 updated the test with toMap and binary operator (#6303)
This commit is contained in:
parent
ca7c2b8c60
commit
f29191df67
@ -85,10 +85,16 @@ public class Java8CollectorsUnitTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenCollectingToMap_shouldCollectToMapMerging() throws Exception {
|
public void whenCollectingToMapwWithDuplicates_shouldCollectToMapMergingTheIdenticalItems() throws Exception {
|
||||||
final Map<String, Integer> result = givenList.stream().collect(toMap(Function.identity(), String::length, (i1, i2) -> i1));
|
final Map<String, Integer> result = listWithDuplicates.stream().collect(
|
||||||
|
toMap(
|
||||||
|
Function.identity(),
|
||||||
|
String::length,
|
||||||
|
(item, identicalItem) -> item
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
assertThat(result).containsEntry("a", 1).containsEntry("bb", 2).containsEntry("ccc", 3).containsEntry("dd", 2);
|
assertThat(result).containsEntry("a", 1).containsEntry("bb", 2).containsEntry("c", 1).containsEntry("d", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user