source: josm/trunk/test/unit/org/openstreetmap/josm/gui/tagging/TagModelTest.java@ 17275

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

see #16567 - upgrade almost all tests to JUnit 5, except those depending on WiremockRule

See https://github.com/tomakehurst/wiremock/issues/684

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.tagging;
3
4import static org.junit.jupiter.api.Assertions.assertEquals;
5import static org.junit.jupiter.api.Assertions.assertTrue;
6
7import org.junit.jupiter.api.Test;
8
9/**
10 * Unit tests of {@link TagModel} class.
11 */
12class TagModelTest {
13
14 /**
15 * Unit test of {@link TagModel#TagModel} - single value.
16 */
17 @Test
18 void testTagModelSingleValue() {
19 TagModel tm = new TagModel();
20 assertEquals("", tm.getName());
21 assertEquals("", tm.getValue());
22 assertEquals(1, tm.getValueCount());
23 assertTrue(tm.hasValue(null));
24 assertTrue(tm.hasValue(""));
25
26 tm.clearValues();
27 assertEquals(0, tm.getValueCount());
28 assertEquals("", tm.getValue());
29
30 tm.setValue(null);
31 assertEquals(1, tm.getValueCount());
32 assertEquals("", tm.getValue());
33
34 tm = new TagModel("key");
35 assertEquals("key", tm.getName());
36 assertEquals("", tm.getValue());
37 assertEquals(1, tm.getValueCount());
38 assertTrue(tm.hasValue(""));
39 }
40
41 /**
42 * Unit test of {@link TagModel#TagModel} - multiple values.
43 */
44 @Test
45 void testTagModelMultipleValues() {
46 TagModel tm = new TagModel("key2", "val2");
47 assertEquals("key2", tm.getName());
48 assertEquals("val2", tm.getValue());
49 assertEquals(1, tm.getValueCount());
50 assertTrue(tm.hasValue("val2"));
51
52 tm.setName("key3");
53 tm.setValue("val3");
54 assertEquals("key3", tm.getName());
55 assertEquals("val3", tm.getValue());
56 assertEquals(1, tm.getValueCount());
57 assertTrue(tm.hasValue("val3"));
58
59 tm.addValue("val4");
60 tm.addValue("val4");
61 assertEquals(2, tm.getValueCount());
62 assertEquals("val3;val4", tm.getValue());
63
64 tm.removeValue("something");
65 tm.removeValue(null);
66 assertEquals(2, tm.getValueCount());
67 assertEquals("val3;val4", tm.getValue());
68
69 tm.removeValue("val3");
70 assertEquals(1, tm.getValueCount());
71 assertEquals("val4", tm.getValue());
72 }
73}
Note: See TracBrowser for help on using the repository browser.