Changeset 18001 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r17981 r18001 238 238 * @param ways ways to clone 239 239 * @param relations relations to clone 240 * @since 17981 241 */ 242 public void clonePrimitives(Iterable<Node> nodes, Iterable<Way> ways, Iterable<Relation> relations) { 240 * @return the map of cloned primitives indexed by their original version 241 * @since 18001 242 */ 243 public Map<OsmPrimitive, OsmPrimitive> clonePrimitives(Iterable<Node> nodes, Iterable<Way> ways, Iterable<Relation> relations) { 243 244 Map<OsmPrimitive, OsmPrimitive> primMap = new HashMap<>(); 244 245 for (Node n : nodes) { … … 268 269 .collect(Collectors.toList())); 269 270 } 271 return primMap; 270 272 } 271 273 -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetValidation.java
r17981 r18001 80 80 DataSet ds = new DataSet(); 81 81 Collection<OsmPrimitive> primitives = FilterModel.getAffectedPrimitives(singleton(original)); 82 ds.clonePrimitives( 82 OsmPrimitive primitive = ds.clonePrimitives( 83 83 new SubclassFilteredCollection<>(primitives, INode.class::isInstance), 84 84 new SubclassFilteredCollection<>(primitives, IWay.class::isInstance), 85 new SubclassFilteredCollection<>(primitives, IRelation.class::isInstance)) ;86 OsmPrimitive primitive = ds.getPrimitiveById(original.getOsmPrimitiveId());85 new SubclassFilteredCollection<>(primitives, IRelation.class::isInstance)) 86 .get(original); 87 87 Command command = TaggingPreset.createCommand(singleton(primitive), changedTags); 88 88 if (command != null) { -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetValidationTest.java
r17938 r18001 2 2 package org.openstreetmap.josm.gui.tagging.presets; 3 3 4 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 7 import java.util.Arrays; 8 import java.util.Locale; 9 10 import javax.swing.JLabel; 11 5 12 import org.junit.jupiter.api.BeforeEach; 6 13 import org.junit.jupiter.api.Test; … … 9 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 10 17 import org.openstreetmap.josm.data.osm.OsmUtils; 18 import org.openstreetmap.josm.data.osm.Tag; 11 19 import org.openstreetmap.josm.data.validation.OsmValidator; 12 20 import org.openstreetmap.josm.testutils.JOSMTestRules; 13 21 14 import javax.swing.JLabel; 15 16 import static org.junit.jupiter.api.Assertions.assertEquals; 17 import static org.junit.jupiter.api.Assertions.assertTrue; 22 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 18 23 19 24 /** … … 31 36 @BeforeEach 32 37 void setUp() { 38 Locale.setDefault(Locale.ENGLISH); 33 39 OsmValidator.initialize(); 34 40 } … … 38 44 */ 39 45 @Test 40 void validate() {46 void testValidate() { 41 47 JLabel label = new JLabel(); 42 48 OsmPrimitive primitive = OsmUtils.createPrimitive("way incline=10m width=1mm opening_hours=\"Mo-Fr 8-10\""); … … 53 59 "<li>suspicious tag combination (incline on suspicious object)</li></ul>", label.getToolTipText()); 54 60 } 61 62 /** 63 * Tests {@link TaggingPresetValidation#applyChangedTags} 64 */ 65 @Test 66 void testApplyChangedTags() { 67 OsmPrimitive primitive = OsmUtils.createPrimitive("way incline=10m width=1mm opening_hours=\"Mo-Fr 8-10\""); 68 new DataSet(primitive); 69 OsmPrimitive clone = TaggingPresetValidation.applyChangedTags(primitive, Arrays.asList(new Tag("incline", "20m"))); 70 assertEquals("20m", clone.get("incline")); 71 assertEquals("1mm", clone.get("width")); 72 } 55 73 }
Note:
See TracChangeset
for help on using the changeset viewer.