Changeset 12726 in josm for trunk/test/unit/org/openstreetmap/josm/command/SequenceCommandTest.java
- Timestamp:
- 2017-09-04T23:45:49+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/command/SequenceCommandTest.java
r11874 r12726 12 12 import java.util.Arrays; 13 13 import java.util.Collection; 14 import java.util.Collections; 14 15 15 16 import org.junit.Before; … … 54 55 @Test 55 56 public void testExecute() { 56 final TestCommand command1 = new TestCommand(Arrays.<OsmPrimitive>asList(testData.existingNode)); 57 TestCommand command2 = new TestCommand(Arrays.<OsmPrimitive>asList(testData.existingNode2)) { 57 DataSet ds = new DataSet(); 58 final TestCommand command1 = new TestCommand(ds, Arrays.<OsmPrimitive>asList(testData.existingNode)); 59 TestCommand command2 = new TestCommand(ds, Arrays.<OsmPrimitive>asList(testData.existingNode2)) { 58 60 @Override 59 61 public boolean executeCommand() { … … 75 77 @Test 76 78 public void testUndo() { 77 final TestCommand command2 = new TestCommand(Arrays.<OsmPrimitive>asList(testData.existingNode2)); 78 TestCommand command1 = new TestCommand(Arrays.<OsmPrimitive>asList(testData.existingNode)) { 79 DataSet ds = new DataSet(); 80 final TestCommand command2 = new TestCommand(ds, Arrays.<OsmPrimitive>asList(testData.existingNode2)); 81 TestCommand command1 = new TestCommand(ds, Arrays.<OsmPrimitive>asList(testData.existingNode)) { 79 82 @Override 80 83 public void undoCommand() { … … 103 106 @Test 104 107 public void testExecuteRollback() { 105 TestCommand command1 = new TestCommand(null); 106 FailingCommand command2 = new FailingCommand(); 107 TestCommand command3 = new TestCommand(null); 108 DataSet ds = new DataSet(); 109 TestCommand command1 = new TestCommand(ds, null); 110 FailingCommand command2 = new FailingCommand(ds); 111 TestCommand command3 = new TestCommand(ds, null); 108 112 SequenceCommand command = new SequenceCommand("seq", Arrays.<Command>asList(command1, command2, command3)); 109 113 assertFalse(command.executeCommand()); … … 119 123 @Test 120 124 public void testContinueOnErrors() { 121 TestCommand command1 = new TestCommand(null); 122 FailingCommand command2 = new FailingCommand(); 123 TestCommand command3 = new TestCommand(null); 125 DataSet ds = new DataSet(); 126 TestCommand command1 = new TestCommand(ds, null); 127 FailingCommand command2 = new FailingCommand(ds); 128 TestCommand command3 = new TestCommand(ds, null); 124 129 SequenceCommand command = new SequenceCommand("seq", Arrays.<Command>asList(command1, command2, command3), true); 125 130 assertTrue(command.executeCommand()); … … 137 142 @Test 138 143 public void testGetLastCommand() { 139 final TestCommand command1 = new TestCommand(Arrays.<OsmPrimitive>asList(testData.existingNode)); 140 final TestCommand command2 = new TestCommand(Arrays.<OsmPrimitive>asList(testData.existingNode2)); 141 142 assertEquals(command2, new SequenceCommand("seq", command1, command2).getLastCommand()); 143 assertNull(new SequenceCommand("seq").getLastCommand()); 144 DataSet ds = new DataSet(); 145 final TestCommand command1 = new TestCommand(ds, Arrays.<OsmPrimitive>asList(testData.existingNode)); 146 final TestCommand command2 = new TestCommand(ds, Arrays.<OsmPrimitive>asList(testData.existingNode2)); 147 148 assertEquals(command2, new SequenceCommand(ds, "seq", Arrays.asList(command1, command2), false).getLastCommand()); 149 assertNull(new SequenceCommand(ds, "seq", Collections.emptyList(), false).getLastCommand()); 144 150 } 145 151 … … 149 155 @Test 150 156 public void testFillModifiedData() { 151 Command command1 = new TestCommand(Arrays.<OsmPrimitive>asList(testData.existingNode)); 152 Command command2 = new TestCommand(Arrays.<OsmPrimitive>asList(testData.existingNode2)); 153 Command command3 = new TestCommand(Arrays.<OsmPrimitive>asList(testData.existingWay)) { 157 DataSet ds = new DataSet(); 158 Command command1 = new TestCommand(ds, Arrays.<OsmPrimitive>asList(testData.existingNode)); 159 Command command2 = new TestCommand(ds, Arrays.<OsmPrimitive>asList(testData.existingNode2)); 160 Command command3 = new TestCommand(ds, Arrays.<OsmPrimitive>asList(testData.existingWay)) { 154 161 @Override 155 162 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, … … 158 165 } 159 166 }; 160 Command command4 = new TestCommand( Arrays.<OsmPrimitive>asList(testData.existingRelation)) {167 Command command4 = new TestCommand(ds, Arrays.<OsmPrimitive>asList(testData.existingRelation)) { 161 168 @Override 162 169 public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, … … 181 188 @Test 182 189 public void testGetParticipatingPrimitives() { 183 Command command1 = new TestCommand(Arrays.<OsmPrimitive>asList(testData.existingNode)); 184 Command command2 = new TestCommand(Arrays.<OsmPrimitive>asList(testData.existingNode2)); 190 DataSet ds = new DataSet(); 191 Command command1 = new TestCommand(ds, Arrays.<OsmPrimitive>asList(testData.existingNode)); 192 Command command2 = new TestCommand(ds, Arrays.<OsmPrimitive>asList(testData.existingNode2)); 185 193 186 194 SequenceCommand command = new SequenceCommand("seq", command1, command2); … … 197 205 @Test 198 206 public void testDescription() { 199 assertTrue(new SequenceCommand( "test").getDescriptionText().matches("Sequence: test"));207 assertTrue(new SequenceCommand(new DataSet(), "test", Collections.emptyList(), false).getDescriptionText().matches("Sequence: test")); 200 208 } 201 209 … … 205 213 @Test 206 214 public void testEqualsContract() { 215 DataSet ds = new DataSet(); 207 216 EqualsVerifier.forClass(SequenceCommand.class).usingGetClass() 208 217 .withPrefabValues(Command.class, 209 new AddCommand( new Node(1)), new AddCommand(new Node(2)))218 new AddCommand(ds, new Node(1)), new AddCommand(ds, new Node(2))) 210 219 .withPrefabValues(DataSet.class, 211 220 new DataSet(), new DataSet()) … … 222 231 protected boolean executed; 223 232 224 TestCommand( Collection<? extends OsmPrimitive> primitives) {225 super( );233 TestCommand(DataSet ds, Collection<? extends OsmPrimitive> primitives) { 234 super(ds); 226 235 this.primitives = primitives; 227 236 } … … 266 275 private static class FailingCommand extends TestCommand { 267 276 268 FailingCommand( ) {269 super( null);277 FailingCommand(DataSet ds) { 278 super(ds, null); 270 279 } 271 280 … … 286 295 return "FailingCommand"; 287 296 } 288 289 } 290 297 } 291 298 }
Note:
See TracChangeset
for help on using the changeset viewer.