Changeset 35628 in osm for applications/editors/josm/plugins/comfort0
- Timestamp:
- 2020-10-29T00:14:21+01:00 (4 years ago)
- Location:
- applications/editors/josm/plugins/comfort0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/comfort0/src/net/simon04/comfort0/EditLevel0LAction.java
r35627 r35628 22 22 import org.openstreetmap.josm.command.ChangePropertyCommand; 23 23 import org.openstreetmap.josm.command.Command; 24 import org.openstreetmap.josm.command.MoveCommand; 24 25 import org.openstreetmap.josm.command.SequenceCommand; 25 26 import org.openstreetmap.josm.data.UndoRedoHandler; 26 27 import org.openstreetmap.josm.data.osm.DataSet; 28 import org.openstreetmap.josm.data.osm.Node; 27 29 import org.openstreetmap.josm.data.osm.OsmPrimitive; 28 30 import org.openstreetmap.josm.data.osm.PrimitiveData; … … 140 142 commands.add(command); 141 143 } 144 145 if (fromDataSet instanceof Node && !Objects.equals(((Node) fromDataSet).getCoor(), ((Node) newInstance).getCoor())) { 146 final MoveCommand command = new MoveCommand(((Node) fromDataSet), ((Node) newInstance).getCoor()); 147 commands.add(command); 148 } 142 149 } 143 150 if (commands.isEmpty()) { -
applications/editors/josm/plugins/comfort0/test/unit/net/simon04/comfort0/EditLevel0LActionTest.java
r35627 r35628 4 4 import static org.hamcrest.CoreMatchers.instanceOf; 5 5 import static org.hamcrest.CoreMatchers.is; 6 import static org.hamcrest.CoreMatchers.notNullValue; 6 7 import static org.hamcrest.CoreMatchers.nullValue; 7 8 import static org.hamcrest.MatcherAssert.assertThat; … … 13 14 import org.junit.Test; 14 15 import org.openstreetmap.josm.command.ChangePropertyCommand; 16 import org.openstreetmap.josm.command.MoveCommand; 15 17 import org.openstreetmap.josm.command.PseudoCommand; 16 18 import org.openstreetmap.josm.command.SequenceCommand; … … 34 36 @Rule 35 37 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 36 public JOSMTestRules test = new JOSMTestRules().preferences() ;38 public JOSMTestRules test = new JOSMTestRules().preferences().projection(); 37 39 38 40 private SequenceCommand buildChangeCommands(DataSet dataSet) throws ParseException { … … 44 46 } 45 47 46 private ChangePropertyCommand buildChangeCommand(DataSet dataSet) throws ParseException {48 private <T extends PseudoCommand> T buildChangeCommand(DataSet dataSet, Class<T> type) throws ParseException { 47 49 SequenceCommand commands = buildChangeCommands(dataSet); 48 50 assertThat(commands.getChildren(), hasSize(1)); 49 51 final PseudoCommand command = commands.getChildren().iterator().next(); 50 assertThat(command, instanceOf( ChangePropertyCommand.class));51 return (ChangePropertyCommand) command;52 assertThat(command, instanceOf(type)); 53 return type.cast(command); 52 54 } 53 55 … … 58 60 final DataSet dataSet = new DataSet(node); 59 61 60 ChangePropertyCommand command = buildChangeCommand(dataSet );62 ChangePropertyCommand command = buildChangeCommand(dataSet, ChangePropertyCommand.class); 61 63 assertThat(command.getTags(), is(new TagMap("name", "Neu Broderstorf", "traffic_sign", "city_limit"))); 62 64 … … 66 68 67 69 node.put("fixme", "delete me!"); 68 command = buildChangeCommand(dataSet );70 command = buildChangeCommand(dataSet, ChangePropertyCommand.class); 69 71 assertThat(command.getTags(), is(new TagMap("name", "Neu Broderstorf", "traffic_sign", "city_limit"))); 70 72 node.remove("fixme"); 71 73 72 74 node.setCoor(new LatLon(55.0900666, 13.2539381)); 73 assertThat(buildChangeCommand s(dataSet), nullValue()); // TODO75 assertThat(buildChangeCommand(dataSet, MoveCommand.class), notNullValue()); 74 76 } 75 77 }
Note:
See TracChangeset
for help on using the changeset viewer.