source: josm/trunk/test/unit/org/openstreetmap/josm/tools/MultiMapTest.java@ 9757

Last change on this file since 9757 was 9757, checked in by bastiK, 8 years ago

remove unstable test

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.tools;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertTrue;
6
7import java.util.Arrays;
8import java.util.HashSet;
9
10import nl.jqno.equalsverifier.EqualsVerifier;
11import org.junit.Test;
12
13/**
14 * Unit tests of {@link MultiMap} class.
15 */
16public class MultiMapTest {
17
18 /**
19 * Unit test of methods {@link MultiMap#equals} and {@link MultiMap#hashCode}.
20 */
21 @Test
22 public void equalsContract() {
23 EqualsVerifier.forClass(MultiMap.class).usingGetClass().verify();
24 }
25
26 /**
27 * Various test of {@link MultiMap}.
28 */
29 @Test
30 public void testMultiMap() {
31 final MultiMap<String, String> map = new MultiMap<>();
32 assertTrue(map.isEmpty());
33 map.put("foo", "bar");
34 map.put("foo", "baz");
35 map.putVoid("alpha");
36 assertEquals(2, map.size());
37 assertEquals(new HashSet<>(Arrays.asList("foo", "alpha")), map.keySet());
38 assertEquals(new HashSet<>(Arrays.asList("bar", "baz")), map.get("foo"));
39 assertEquals(new HashSet<>(), map.get("alpha"));
40 assertEquals(null, map.get("beta"));
41 assertEquals(new HashSet<>(), map.getValues("alpha"));
42 assertEquals(new HashSet<>(), map.getValues("beta"));
43 assertEquals("[[bar, baz], []]", map.values().toString());
44 map.put("foo", "baz2");
45 map.put("foo", "baz");
46 assertEquals(new HashSet<>(Arrays.asList("bar", "baz", "baz2")), map.get("foo"));
47 map.remove("foo", "baz");
48 assertEquals(new HashSet<>(Arrays.asList("bar", "baz2")), map.get("foo"));
49 map.remove("foo");
50 assertEquals(null, map.get("foo"));
51 assertEquals("(alpha->{})", map.toString());
52 map.remove("alpha");
53 assertTrue(map.isEmpty());
54 map.remove("omega", null);
55 assertTrue(map.isEmpty());
56 map.clear();
57 assertTrue(map.isEmpty());
58 map.putAll("foo", Arrays.asList("bar", "baz"));
59 assertEquals(new HashSet<>(Arrays.asList("bar", "baz")), map.get("foo"));
60 }
61}
Note: See TracBrowser for help on using the repository browser.