1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.dialogs.validator;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertEquals;
|
---|
5 | import static org.junit.Assert.assertNotNull;
|
---|
6 | import static org.junit.Assert.assertNull;
|
---|
7 |
|
---|
8 | import java.util.ArrayList;
|
---|
9 | import java.util.Arrays;
|
---|
10 | import java.util.Collections;
|
---|
11 | import java.util.HashSet;
|
---|
12 | import java.util.Set;
|
---|
13 |
|
---|
14 | import org.junit.BeforeClass;
|
---|
15 | import org.junit.Test;
|
---|
16 | import org.openstreetmap.josm.JOSMFixture;
|
---|
17 | import org.openstreetmap.josm.data.osm.Node;
|
---|
18 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
19 | import org.openstreetmap.josm.data.validation.Severity;
|
---|
20 | import org.openstreetmap.josm.data.validation.TestError;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Unit tests of {@link ValidatorTreePanel} class.
|
---|
24 | */
|
---|
25 | public class ValidatorTreePanelTest {
|
---|
26 |
|
---|
27 | /**
|
---|
28 | * Setup tests
|
---|
29 | */
|
---|
30 | @BeforeClass
|
---|
31 | public static void setUpBeforeClass() {
|
---|
32 | JOSMFixture.createUnitTestFixture().init(true);
|
---|
33 | }
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * Unit test of {@link ValidatorTreePanel#ValidatorTreePanel}.
|
---|
37 | */
|
---|
38 | @Test
|
---|
39 | public void testValidatorTreePanel() {
|
---|
40 | assertNotNull(new ValidatorTreePanel());
|
---|
41 |
|
---|
42 | ValidatorTreePanel vtp = new ValidatorTreePanel(new ArrayList<>(Arrays.asList(
|
---|
43 | new TestError(null, Severity.ERROR, "err", 0, new Node(1)),
|
---|
44 | new TestError(null, Severity.WARNING, "warn", 0, new Node(2)))));
|
---|
45 | assertNotNull(vtp);
|
---|
46 | assertEquals(2, vtp.getErrors().size());
|
---|
47 | vtp.setVisible(true);
|
---|
48 | vtp.setVisible(false);
|
---|
49 | Node n = new Node(10);
|
---|
50 | vtp.setErrors(Arrays.asList(new TestError(null, Severity.ERROR, "", 0, n)));
|
---|
51 | assertEquals(1, vtp.getErrors().size());
|
---|
52 | vtp.selectRelatedErrors(Collections.<OsmPrimitive>singleton(n));
|
---|
53 | vtp.expandAll();
|
---|
54 | assertNotNull(vtp.getRoot());
|
---|
55 | vtp.resetErrors();
|
---|
56 | Set<? extends OsmPrimitive> filter = new HashSet<>(Arrays.asList(n));
|
---|
57 | vtp.setFilter(filter);
|
---|
58 | assertEquals(filter, vtp.getFilter());
|
---|
59 | vtp.setFilter(new HashSet<OsmPrimitive>());
|
---|
60 | assertNull(vtp.getFilter());
|
---|
61 | vtp.setFilter(null);
|
---|
62 | assertNull(vtp.getFilter());
|
---|
63 | vtp.destroy();
|
---|
64 | }
|
---|
65 | }
|
---|