source: josm/trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MultipolygonTestTest.java@ 7937

Last change on this file since 7937 was 7937, checked in by bastiK, 9 years ago

add subversion property svn:eol=native

  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.validation.tests;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertFalse;
6import static org.junit.Assert.assertTrue;
7
8import java.util.ArrayList;
9import java.util.List;
10
11import org.junit.Before;
12import org.junit.Test;
13import org.openstreetmap.josm.JOSMFixture;
14import org.openstreetmap.josm.data.coor.LatLon;
15import org.openstreetmap.josm.data.osm.Node;
16import org.openstreetmap.josm.data.osm.OsmUtils;
17import org.openstreetmap.josm.data.osm.Way;
18import org.openstreetmap.josm.gui.mappaint.ElemStyles;
19import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
20
21/**
22 * JUnit Test of Multipolygon validation test.
23 */
24public class MultipolygonTestTest {
25
26 private static final MultipolygonTest MULTIPOLYGON_TEST = new MultipolygonTest();
27
28 /**
29 * Setup test.
30 * @throws Exception if test cannot be initialized
31 */
32 @Before
33 public void setUp() throws Exception {
34 JOSMFixture.createUnitTestFixture().init();
35 MapPaintStyles.readFromPreferences();
36 MULTIPOLYGON_TEST.initialize();
37 }
38
39 private static Way createUnclosedWay(String tags) {
40 List<Node> nodes = new ArrayList<>();
41 nodes.add(new Node(new LatLon(0, 1)));
42 nodes.add(new Node(new LatLon(0, 2)));
43
44 Way w = (Way)OsmUtils.createPrimitive("way "+tags);
45 w.setNodes(nodes);
46 return w;
47 }
48
49 /**
50 * Non-regression test for bug #10469.
51 */
52 @Test
53 public void testTicket10469() {
54 MULTIPOLYGON_TEST.startTest(null);
55
56 List<Node> nodes = new ArrayList<>();
57 nodes.add(new Node(new LatLon(0, 1)));
58 nodes.add(new Node(new LatLon(0, 2)));
59
60 // Erroneous tag
61 Way w = createUnclosedWay("amenity=parking");
62 MULTIPOLYGON_TEST.visit(w);
63 assertTrue(ElemStyles.hasAreaElemStyle(w, false));
64 assertEquals(1, MULTIPOLYGON_TEST.getErrors().size());
65
66 // Erroneous tag, but managed by another test
67 w = createUnclosedWay("building=yes");
68 MULTIPOLYGON_TEST.visit(w);
69 assertTrue(ElemStyles.hasAreaElemStyle(w, false));
70 assertEquals(1, MULTIPOLYGON_TEST.getErrors().size());
71
72 // Correct tag, without area style since #10601 (r7603)
73 w = createUnclosedWay("aeroway=taxiway");
74 MULTIPOLYGON_TEST.visit(w);
75 assertFalse(ElemStyles.hasAreaElemStyle(w, false));
76 assertEquals(1, MULTIPOLYGON_TEST.getErrors().size());
77
78 MULTIPOLYGON_TEST.endTest();
79 }
80}
Note: See TracBrowser for help on using the repository browser.