Changeset 12045 in josm
- Timestamp:
- 2017-05-03T13:50:39+02:00 (8 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/TestUtils.java
r11978 r12045 6 6 7 7 import java.awt.Component; 8 import java.awt.Container; 8 9 import java.awt.Graphics2D; 9 10 import java.io.File; … … 17 18 import java.util.Collection; 18 19 import java.util.Comparator; 20 import java.util.Objects; 21 import java.util.stream.Stream; 19 22 20 23 import org.openstreetmap.josm.command.Command; … … 307 310 } 308 311 } 312 313 /** 314 * Get a descendant component by name. 315 * @param root The root component to start searching from. 316 * @param name The component name 317 * @return The component with that name or null if it does not exist. 318 * @since 12045 319 */ 320 public static Component getComponentByName(Component root, String name) { 321 if (name.equals(root.getName())) { 322 return root; 323 } else if (root instanceof Container) { 324 Container container = (Container) root; 325 return Stream.of(container.getComponents()) 326 .map(child -> getComponentByName(child, name)) 327 .filter(Objects::nonNull) 328 .findFirst().orElse(null); 329 } else { 330 return null; 331 } 332 } 309 333 } -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergerTest.java
r10962 r12045 6 6 import org.junit.Rule; 7 7 import org.junit.Test; 8 import org.openstreetmap.josm.TestUtils; 8 9 import org.openstreetmap.josm.testutils.JOSMTestRules; 9 10 … … 27 28 @Test 28 29 public void testPropertiesMerger() { 29 assertNotNull(new PropertiesMerger()); 30 PropertiesMerger merger = new PropertiesMerger(); 31 assertNotNull(TestUtils.getComponentByName(merger, "button.keepmycoordinates")); 32 assertNotNull(TestUtils.getComponentByName(merger, "button.keeptheircoordinates")); 33 assertNotNull(TestUtils.getComponentByName(merger, "button.undecidecoordinates")); 34 assertNotNull(TestUtils.getComponentByName(merger, "button.keepmydeletedstate")); 35 assertNotNull(TestUtils.getComponentByName(merger, "button.keeptheirdeletedstate")); 36 assertNotNull(TestUtils.getComponentByName(merger, "button.undecidedeletedstate")); 30 37 } 31 38 }
Note:
See TracChangeset
for help on using the changeset viewer.