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

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

sonar - squid:S3578 - Test methods should comply with a naming convention

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