|
4 | 4 | import java.math.BigDecimal; |
5 | 5 | import java.util.ArrayList; |
6 | 6 | import java.util.Comparator; |
| 7 | +import java.util.LinkedList; |
7 | 8 | import java.util.Map; |
8 | 9 | import java.util.Spliterator; |
9 | 10 | import java.util.function.Function; |
10 | 11 | import java.util.function.Supplier; |
11 | 12 | import java.util.stream.Collector; |
12 | 13 | import java.util.stream.Stream; |
| 14 | +import org.assertj.core.api.Assertions; |
13 | 15 | import org.junit.jupiter.api.TestTemplate; |
14 | 16 |
|
15 | 17 | public class TreeMultimapTest extends AbstractMultimapTest { |
@@ -196,6 +198,21 @@ protected <K extends Comparable<K>, V> Multimap<K, V> mapFill(int n, Tuple2<? ex |
196 | 198 | throw new RuntimeException(); |
197 | 199 | } |
198 | 200 | } |
| 201 | + |
| 202 | + // -- toJavaMap |
| 203 | + |
| 204 | + @TestTemplate |
| 205 | + public void shouldReturnJavaMapSortedUsingSameComparator() { |
| 206 | + final TreeMultimap<String, String> vavrMap = TreeMultimap.withSeq().of(Comparator.comparing(String::length), "aa", "aa", "b", "b"); |
| 207 | + |
| 208 | + final LinkedList<String> orderedJavaMapKeys = new LinkedList<>(); |
| 209 | + final LinkedList<String> orderedVavrMapKeys = new LinkedList<>(); |
| 210 | + vavrMap.forEach((k,v) -> orderedVavrMapKeys.add(k)); |
| 211 | + vavrMap.toJavaMap().forEach((k, v) -> orderedJavaMapKeys.add(k)); |
| 212 | + |
| 213 | + Assertions.assertThat(orderedJavaMapKeys).containsExactly("b", "aa"); |
| 214 | + Assertions.assertThat(orderedVavrMapKeys).containsExactly("b", "aa"); |
| 215 | + } |
199 | 216 |
|
200 | 217 | // -- static narrow |
201 | 218 |
|
|
0 commit comments