Ignore:
Timestamp:
2017-09-04T23:45:49+02:00 (7 years ago)
Author:
Don-vip
Message:

see #13036 - deprecate Command() default constructor, fix unit tests and java warnings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/command/SequenceCommandTest.java

    r11874 r12726  
    1212import java.util.Arrays;
    1313import java.util.Collection;
     14import java.util.Collections;
    1415
    1516import org.junit.Before;
     
    5455    @Test
    5556    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)) {
    5860            @Override
    5961            public boolean executeCommand() {
     
    7577    @Test
    7678    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)) {
    7982            @Override
    8083            public void undoCommand() {
     
    103106    @Test
    104107    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);
    108112        SequenceCommand command = new SequenceCommand("seq", Arrays.<Command>asList(command1, command2, command3));
    109113        assertFalse(command.executeCommand());
     
    119123    @Test
    120124    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);
    124129        SequenceCommand command = new SequenceCommand("seq", Arrays.<Command>asList(command1, command2, command3), true);
    125130        assertTrue(command.executeCommand());
     
    137142    @Test
    138143    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());
    144150    }
    145151
     
    149155    @Test
    150156    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)) {
    154161            @Override
    155162            public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted,
     
    158165            }
    159166        };
    160         Command command4 = new TestCommand(Arrays.<OsmPrimitive>asList(testData.existingRelation)) {
     167        Command command4 = new TestCommand(ds, Arrays.<OsmPrimitive>asList(testData.existingRelation)) {
    161168            @Override
    162169            public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted,
     
    181188    @Test
    182189    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));
    185193
    186194        SequenceCommand command = new SequenceCommand("seq", command1, command2);
     
    197205    @Test
    198206    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"));
    200208    }
    201209
     
    205213    @Test
    206214    public void testEqualsContract() {
     215        DataSet ds = new DataSet();
    207216        EqualsVerifier.forClass(SequenceCommand.class).usingGetClass()
    208217            .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)))
    210219            .withPrefabValues(DataSet.class,
    211220                    new DataSet(), new DataSet())
     
    222231        protected boolean executed;
    223232
    224         TestCommand(Collection<? extends OsmPrimitive> primitives) {
    225             super();
     233        TestCommand(DataSet ds, Collection<? extends OsmPrimitive> primitives) {
     234            super(ds);
    226235            this.primitives = primitives;
    227236        }
     
    266275    private static class FailingCommand extends TestCommand {
    267276
    268         FailingCommand() {
    269             super(null);
     277        FailingCommand(DataSet ds) {
     278            super(ds, null);
    270279        }
    271280
     
    286295            return "FailingCommand";
    287296        }
    288 
    289     }
    290 
     297    }
    291298}
Note: See TracChangeset for help on using the changeset viewer.