source: josm/trunk/test/unit/org/openstreetmap/josm/command/conflict/ConflictAddCommandTest.java@ 8917

Last change on this file since 8917 was 8917, checked in by Don-vip, 9 years ago

fix unit tests

File size: 2.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.command.conflict;
3
4import static org.junit.Assert.assertFalse;
5import static org.junit.Assert.assertNotNull;
6import static org.junit.Assert.assertTrue;
7
8import org.junit.BeforeClass;
9import org.junit.Test;
10import org.openstreetmap.josm.JOSMFixture;
11import org.openstreetmap.josm.Main;
12import org.openstreetmap.josm.data.conflict.Conflict;
13import org.openstreetmap.josm.data.osm.DataSet;
14import org.openstreetmap.josm.data.osm.Node;
15import org.openstreetmap.josm.gui.layer.OsmDataLayer;
16
17/**
18 * Unit tests of {@link ConflictAddCommand} class.
19 */
20public class ConflictAddCommandTest {
21
22 /**
23 * Setup test.
24 */
25 @BeforeClass
26 public static void setUpBeforeClass() {
27 JOSMFixture.createUnitTestFixture().init(true);
28 Main.map.mapView.addLayer(new OsmDataLayer(new DataSet(), null, null));
29 }
30
31 /**
32 * Unit test of {@code ConflictAddCommand#executeCommand} and {@code ConflictAddCommand#undoCommand} methods.
33 */
34 @Test
35 public void testExecuteUndoCommand() {
36 OsmDataLayer layer = Main.map.mapView.getEditLayer();
37 Conflict<Node> conflict = new Conflict<>(new Node(), new Node());
38 ConflictAddCommand cmd = new ConflictAddCommand(layer, conflict);
39 assertTrue(cmd.executeCommand());
40 assertFalse(layer.getConflicts().isEmpty());
41 assertTrue(layer.getConflicts().hasConflict(conflict));
42 cmd.undoCommand();
43 assertFalse(layer.getConflicts().hasConflict(conflict));
44 assertTrue(layer.getConflicts().isEmpty());
45 }
46
47 /**
48 * Unit test of {@code ConflictAddCommand#getDescriptionIcon} method.
49 */
50 @Test
51 public void testGetDescriptionIcon() {
52 OsmDataLayer layer = Main.map.mapView.getEditLayer();
53 Conflict<Node> conflict = new Conflict<>(new Node(), new Node());
54 assertNotNull(new ConflictAddCommand(layer, conflict).getDescriptionIcon());
55 }
56}
Note: See TracBrowser for help on using the repository browser.