source: josm/trunk/test/unit/org/openstreetmap/josm/data/validation/tests/NameMismatchTest.java@ 9130

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

add missing svn:eol-style=native

  • Property svn:eol-style set to native
File size: 2.4 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.assertSame;
6
7import java.util.List;
8
9import org.junit.Before;
10import org.junit.Test;
11import org.openstreetmap.josm.JOSMFixture;
12import org.openstreetmap.josm.data.osm.OsmUtils;
13import org.openstreetmap.josm.data.validation.TestError;
14
15/**
16 * JUnit Test of "Name mismatch" validation test.
17 */
18public class NameMismatchTest {
19
20 /**
21 * Setup test.
22 */
23 @Before
24 public void setUp() {
25 JOSMFixture.createUnitTestFixture().init();
26 }
27
28 List<TestError> test(String primitive) {
29 final NameMismatch test = new NameMismatch();
30 test.check(OsmUtils.createPrimitive(primitive));
31 return test.getErrors();
32 }
33
34 /**
35 * Test "A name is missing, even though name:* exists."
36 */
37 @Test
38 public void test0() {
39 final List<TestError> errors = test("node name:de=Europa");
40 assertSame(1, errors.size());
41 assertEquals("A name is missing, even though name:* exists.", errors.get(0).getMessage());
42 }
43
44 /**
45 * Test "Missing name:*={0}. Add tag with correct language key."
46 */
47 @Test
48 public void test1() {
49 final List<TestError> errors = test("node name=Europe name:de=Europa");
50 assertSame(1, errors.size());
51 assertEquals("Missing name:*=Europe. Add tag with correct language key.", errors.get(0).getDescription());
52 }
53
54 /**
55 * Test no error
56 */
57 @Test
58 public void test2() {
59 final List<TestError> errors = test("node name=Europe name:de=Europa name:en=Europe");
60 assertSame(0, errors.size());
61 }
62
63 /**
64 * Various other tests
65 */
66 @Test
67 public void test3() {
68 List<TestError> errors;
69 errors = test("node \"name\"=\"Italia - Italien - Italy\"");
70 assertSame(0, errors.size());
71 errors = test("node name=\"Italia - Italien - Italy\" name:it=Italia");
72 assertSame(2, errors.size());
73 errors = test("node name=\"Italia - Italien - Italy\" name:it=Italia name:de=Italien");
74 assertSame(1, errors.size());
75 assertEquals("Missing name:*=Italy. Add tag with correct language key.", errors.get(0).getDescription());
76 errors = test("node name=\"Italia - Italien - Italy\" name:it=Italia name:de=Italien name:en=Italy");
77 assertSame(0, errors.size());
78 }
79}
Note: See TracBrowser for help on using the repository browser.