Changeset 18922 in josm for trunk/test/unit/org
- Timestamp:
- 2023-12-20T20:03:45+01:00 (11 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/AddressesTest.java
r18853 r18922 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 5 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 7 import static org.junit.jupiter.api.Assertions.assertNull; 8 import static org.junit.jupiter.api.Assertions.assertTrue; 7 9 import static org.openstreetmap.josm.data.coor.LatLon.NORTH_POLE; 8 10 import static org.openstreetmap.josm.data.coor.LatLon.SOUTH_POLE; … … 10 12 11 13 import java.util.List; 14 15 import javax.swing.JCheckBox; 16 import javax.swing.JPanel; 12 17 13 18 import org.junit.jupiter.api.Test; … … 17 22 import org.openstreetmap.josm.data.osm.Node; 18 23 import org.openstreetmap.josm.data.osm.RelationMember; 24 import org.openstreetmap.josm.data.osm.Way; 19 25 import org.openstreetmap.josm.data.validation.Severity; 20 26 import org.openstreetmap.josm.data.validation.TestError; 27 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 21 28 22 29 /** … … 120 127 doTestDuplicateHouseNumber(num1, ZERO, num4, ZERO, null); 121 128 } 129 130 /** 131 * See #23302 132 */ 133 @Test 134 void testCheckForDuplicatePOIBuildingAddresses() { 135 final Addresses test = new Addresses(); 136 final JPanel panel = new JPanel(); 137 final Node poi = TestUtils.newNode("addr:housenumber=1 addr:street=Foo"); 138 final Way building = TestUtils.newWay("addr:housenumber=1 addr:street=Foo building=yes", 139 TestUtils.newNode(""), TestUtils.newNode(""), TestUtils.newNode("")); 140 final DataSet ds = new DataSet(); 141 // Ensure that we are checking for building-poi duplicates 142 test.addGui(panel); 143 JCheckBox checkboxIncludeBldgPOI = assertInstanceOf(JCheckBox.class, panel.getComponent(panel.getComponentCount() - 1)); 144 checkboxIncludeBldgPOI.setSelected(true); 145 test.ok(); 146 // Set up the dataset 147 ds.addPrimitive(poi); 148 ds.addPrimitiveRecursive(building); 149 building.addNode(building.firstNode()); 150 151 // Duplicate addresses with no additional information should always have warnings 152 test.startTest(NullProgressMonitor.INSTANCE); 153 test.visit(ds.allPrimitives()); 154 test.endTest(); 155 assertEquals(1, test.getErrors().size()); 156 157 // Do the first test checking for building-poi duplicates 158 poi.put("name", "FooBar"); 159 test.startTest(NullProgressMonitor.INSTANCE); 160 test.visit(ds.allPrimitives()); 161 test.endTest(); 162 assertEquals(1, test.getErrors().size()); 163 assertEquals(Severity.OTHER, test.getErrors().get(0).getSeverity()); 164 165 // Now check if they have the same name 166 building.put("name", "FooBar"); 167 test.startTest(NullProgressMonitor.INSTANCE); 168 test.visit(ds.allPrimitives()); 169 test.endTest(); 170 assertEquals(1, test.getErrors().size()); 171 assertEquals(Severity.WARNING, test.getErrors().get(0).getSeverity()); 172 173 // Now check if they have a different name 174 building.put("name", "FooBar2"); 175 test.startTest(NullProgressMonitor.INSTANCE); 176 test.visit(ds.allPrimitives()); 177 test.endTest(); 178 assertEquals(1, test.getErrors().size()); 179 assertEquals(Severity.OTHER, test.getErrors().get(0).getSeverity()); 180 181 // Now ensure that it doesn't get errors when disabled 182 checkboxIncludeBldgPOI.setSelected(false); 183 test.ok(); 184 test.startTest(NullProgressMonitor.INSTANCE); 185 test.visit(ds.allPrimitives()); 186 test.endTest(); 187 assertTrue(test.getErrors().isEmpty()); 188 } 122 189 }
Note:
See TracChangeset
for help on using the changeset viewer.