source: josm/trunk/test/unit/org/openstreetmap/josm/gui/correction/RoleCorrectionTableTest.java@ 17536

Last change on this file since 17536 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: 3.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.correction;
3
4import static org.junit.jupiter.api.Assertions.assertEquals;
5import static org.junit.jupiter.api.Assertions.assertFalse;
6import static org.junit.jupiter.api.Assertions.assertNotNull;
7import static org.junit.jupiter.api.Assertions.assertNull;
8import static org.junit.jupiter.api.Assertions.assertTrue;
9
10import java.util.Arrays;
11
12import org.junit.jupiter.api.extension.RegisterExtension;
13import org.junit.jupiter.api.Test;
14import org.openstreetmap.josm.data.correction.RoleCorrection;
15import org.openstreetmap.josm.data.osm.Node;
16import org.openstreetmap.josm.data.osm.Relation;
17import org.openstreetmap.josm.data.osm.RelationMember;
18import org.openstreetmap.josm.testutils.JOSMTestRules;
19
20import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
21
22/**
23 * Unit tests of {@link RoleCorrectionTable} class.
24 */
25class RoleCorrectionTableTest {
26
27 /**
28 * Setup tests
29 */
30 @RegisterExtension
31 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
32 public JOSMTestRules test = new JOSMTestRules();
33
34 /**
35 * Test of {@link RoleCorrectionTable#RoleCorrectionTable}.
36 */
37 @Test
38 void testRoleCorrectionTable() {
39 Relation r = new Relation();
40 RelationMember member = new RelationMember("foo", new Node());
41 r.addMember(member);
42 RoleCorrection rc = new RoleCorrection(r, 0, member, "bar");
43 RoleCorrectionTable t = new RoleCorrectionTable(Arrays.asList(rc));
44 assertNotNull(t.getCellRenderer(0, 0));
45 assertNotNull(t.getCellRenderer(0, 1));
46 assertNotNull(t.getCellRenderer(0, 2));
47 assertNotNull(t.getCellRenderer(0, 3));
48 RoleCorrectionTableModel model = t.getCorrectionTableModel();
49 assertEquals(1, model.getCorrections().size());
50 assertEquals(1, model.getRowCount());
51 assertEquals(3, model.getApplyColumn());
52 assertTrue(model.getApply(0));
53 assertEquals(String.class, model.getColumnClass(0));
54 assertEquals(Boolean.class, model.getColumnClass(3));
55 assertEquals("Relation", model.getColumnName(0));
56 assertEquals("Old role", model.getColumnName(1));
57 assertEquals("New role", model.getColumnName(2));
58 assertEquals("Apply?", model.getColumnName(3));
59 assertNull(model.getColumnName(4));
60 assertFalse(model.isCellEditable(0, 0));
61 assertTrue(model.isCellEditable(0, 3));
62 assertEquals("relation (0, 1 member)", model.getValueAt(0, 0));
63 assertEquals("foo", model.getValueAt(0, 1));
64 assertEquals("bar", model.getValueAt(0, 2));
65 assertTrue((Boolean) model.getValueAt(0, 3));
66 assertNull(model.getValueAt(0, 4));
67 model.setValueAt("", 0, 0);
68 assertEquals("relation (0, 1 member)", model.getValueAt(0, 0));
69 model.setValueAt("", 0, 3);
70 assertTrue((Boolean) model.getValueAt(0, 3));
71 model.setValueAt(Boolean.FALSE, 0, 3);
72 assertFalse((Boolean) model.getValueAt(0, 3));
73 RoleCorrection[] array = new RoleCorrection[15];
74 Arrays.fill(array, rc);
75 t = new RoleCorrectionTable(Arrays.asList(array));
76 assertEquals(array.length, t.getCorrectionTableModel().getCorrections().size());
77 }
78}
Note: See TracBrowser for help on using the repository browser.