source: josm/trunk/test/unit/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanelTest.java@ 9811

Last change on this file since 9811 was 9811, checked in by Don-vip, 8 years ago

add a unit test for ValidatorTreePanel

  • Property svn:eol-style set to native
File size: 2.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.dialogs.validator;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertNotNull;
6import static org.junit.Assert.assertNull;
7
8import java.util.ArrayList;
9import java.util.Arrays;
10import java.util.Collections;
11import java.util.HashSet;
12import java.util.Set;
13
14import org.junit.BeforeClass;
15import org.junit.Test;
16import org.openstreetmap.josm.JOSMFixture;
17import org.openstreetmap.josm.data.osm.Node;
18import org.openstreetmap.josm.data.osm.OsmPrimitive;
19import org.openstreetmap.josm.data.validation.Severity;
20import org.openstreetmap.josm.data.validation.TestError;
21
22/**
23 * Unit tests of {@link ValidatorTreePanel} class.
24 */
25public 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(1, vtp.getUpdateCount());
47 assertEquals(2, vtp.getErrors().size());
48 vtp.setVisible(true);
49 vtp.setVisible(false);
50 Node n = new Node(10);
51 vtp.setErrors(Arrays.asList(new TestError(null, Severity.ERROR, "", 0, n)));
52 assertEquals(1, vtp.getErrors().size());
53 vtp.selectRelatedErrors(Collections.<OsmPrimitive>singleton(n));
54 vtp.expandAll();
55 assertNotNull(vtp.getRoot());
56 vtp.resetErrors();
57 Set<? extends OsmPrimitive> filter = new HashSet<>(Arrays.asList(n));
58 vtp.setFilter(filter);
59 assertEquals(filter, vtp.getFilter());
60 vtp.setFilter(new HashSet<OsmPrimitive>());
61 assertNull(vtp.getFilter());
62 vtp.setFilter(null);
63 assertNull(vtp.getFilter());
64 vtp.destroy();
65 }
66}
Note: See TracBrowser for help on using the repository browser.