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

Last change on this file since 13812 was 13079, checked in by Don-vip, 6 years ago

see #15560 - EqualsVerifier does not work with newer Java versions -> disable tests automatically in this case
Workaround to https://github.com/jqno/equalsverifier/issues/177 / https://github.com/raphw/byte-buddy/issues/370
Inspired by https://issues.apache.org/jira/browse/SOLR-11606

  • 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 org.junit.Test;
11import org.openstreetmap.josm.TestUtils;
12
13import nl.jqno.equalsverifier.EqualsVerifier;
14
15/**
16 * Unit tests of {@link MultiMap} class.
17 */
18public class MultiMapTest {
19
20 /**
21 * Unit test of methods {@link MultiMap#equals} and {@link MultiMap#hashCode}.
22 */
23 @Test
24 public void testEqualsContract() {
25 TestUtils.assumeWorkingEqualsVerifier();
26 EqualsVerifier.forClass(MultiMap.class).usingGetClass().verify();
27 }
28
29 /**
30 * Various test of {@link MultiMap}.
31 */
32 @Test
33 public void testMultiMap() {
34 final MultiMap<String, String> map = new MultiMap<>();
35 assertTrue(map.isEmpty());
36 map.put("foo", "bar");
37 map.put("foo", "baz");
38 map.putVoid("alpha");
39 assertEquals(2, map.size());
40 assertEquals(new HashSet<>(Arrays.asList("foo", "alpha")), map.keySet());
41 assertEquals(new HashSet<>(Arrays.asList("bar", "baz")), map.get("foo"));
42 assertEquals(new HashSet<>(), map.get("alpha"));
43 assertEquals(null, map.get("beta"));
44 assertEquals(new HashSet<>(), map.getValues("alpha"));
45 assertEquals(new HashSet<>(), map.getValues("beta"));
46 map.put("foo", "baz2");
47 map.put("foo", "baz");
48 assertEquals(new HashSet<>(Arrays.asList("bar", "baz", "baz2")), map.get("foo"));
49 map.remove("foo", "baz");
50 assertEquals(new HashSet<>(Arrays.asList("bar", "baz2")), map.get("foo"));
51 map.remove("foo");
52 assertEquals(null, map.get("foo"));
53 assertEquals("(alpha->{})", map.toString());
54 map.remove("alpha");
55 assertTrue(map.isEmpty());
56 map.remove("omega", null);
57 assertTrue(map.isEmpty());
58 map.clear();
59 assertTrue(map.isEmpty());
60 map.putAll("foo", Arrays.asList("bar", "baz"));
61 assertEquals(new HashSet<>(Arrays.asList("bar", "baz")), map.get("foo"));
62 }
63}
Note: See TracBrowser for help on using the repository browser.