-
Notifications
You must be signed in to change notification settings - Fork 587
/
FastListMultimapTest.java
121 lines (105 loc) · 4.71 KB
/
FastListMultimapTest.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
* Copyright (c) 2022 Goldman Sachs and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompany this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*/
package org.eclipse.collections.impl.multimap.list;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.multimap.list.MutableListMultimap;
import org.eclipse.collections.api.tuple.Pair;
import org.eclipse.collections.impl.list.mutable.FastList;
import org.eclipse.collections.impl.tuple.Tuples;
import org.junit.Assert;
import org.junit.Test;
/**
* Test of {@link FastListMultimap}.
*/
public class FastListMultimapTest extends AbstractMutableListMultimapTestCase
{
@Override
public <K, V> MutableListMultimap<K, V> newMultimap()
{
return FastListMultimap.newMultimap();
}
@Override
public <K, V> MutableListMultimap<K, V> newMultimapWithKeyValue(K key, V value)
{
return this.<K, V>newMultimap()
.withKeyValue(key, value);
}
@Override
public <K, V> MutableListMultimap<K, V> newMultimapWithKeysValues(K key1, V value1, K key2, V value2)
{
return this.<K, V>newMultimap()
.withKeyValue(key1, value1)
.withKeyValue(key2, value2);
}
@Override
public <K, V> MutableListMultimap<K, V> newMultimapWithKeysValues(
K key1, V value1,
K key2, V value2,
K key3, V value3)
{
return this.<K, V>newMultimap()
.withKeyValue(key1, value1)
.withKeyValue(key2, value2)
.withKeyValue(key3, value3);
}
@Override
public <K, V> MutableListMultimap<K, V> newMultimapWithKeysValues(
K key1, V value1,
K key2, V value2,
K key3, V value3,
K key4, V value4)
{
return this.<K, V>newMultimap()
.withKeyValue(key1, value1)
.withKeyValue(key2, value2)
.withKeyValue(key3, value3)
.withKeyValue(key4, value4);
}
@SafeVarargs
@Override
public final <K, V> MutableListMultimap<K, V> newMultimap(Pair<K, V>... pairs)
{
return FastListMultimap.newMultimap(pairs);
}
@Override
public <K, V> MutableListMultimap<K, V> newMultimapFromPairs(Iterable<Pair<K, V>> inputIterable)
{
return FastListMultimap.newMultimap(inputIterable);
}
@SafeVarargs
@Override
protected final <V> FastList<V> createCollection(V... args)
{
return FastList.newListWith(args);
}
@Test
public void pairIterableConstructorTest()
{
Pair<Integer, String> pair1 = Tuples.pair(Integer.valueOf(1), "One");
Pair<Integer, String> pair2 = Tuples.pair(Integer.valueOf(2), "Two");
Pair<Integer, String> pair3 = Tuples.pair(Integer.valueOf(3), "Three");
Pair<Integer, String> pair4 = Tuples.pair(Integer.valueOf(4), "Four");
Pair<Integer, String> pair11 = Tuples.pair(Integer.valueOf(1), "OneOne");
Pair<Integer, String> pair22 = Tuples.pair(Integer.valueOf(2), "TwoTwo");
Pair<Integer, String> pair33 = Tuples.pair(Integer.valueOf(3), "ThreeThree");
Pair<Integer, String> pair44 = Tuples.pair(Integer.valueOf(4), "FourFour");
Pair<Integer, String> pair111 = Tuples.pair(Integer.valueOf(1), "One");
Pair<Integer, String> pair222 = Tuples.pair(Integer.valueOf(2), "Two");
Pair<Integer, String> pair333 = Tuples.pair(Integer.valueOf(3), "Three");
Pair<Integer, String> pair444 = Tuples.pair(Integer.valueOf(4), "Four");
MutableList<Pair<Integer, String>> testList = FastList.newListWith(pair1, pair2, pair3, pair4, pair11, pair22, pair33, pair44, pair111, pair222, pair333, pair444);
MutableListMultimap<Integer, String> actual = FastListMultimap.newMultimap(testList);
Assert.assertEquals(FastList.newListWith(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3), Integer.valueOf(4)), actual.keysView().toList());
Assert.assertEquals(FastList.newListWith("One", "OneOne", "One"), actual.get(Integer.valueOf(1)).toList());
Assert.assertEquals(FastList.newListWith("Two", "TwoTwo", "Two"), actual.get(Integer.valueOf(2)).toList());
Assert.assertEquals(FastList.newListWith("Three", "ThreeThree", "Three"), actual.get(Integer.valueOf(3)).toList());
Assert.assertEquals(FastList.newListWith("Four", "FourFour", "Four"), actual.get(Integer.valueOf(4)).toList());
}
}