1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.command.conflict;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertFalse;
|
---|
5 | import static org.junit.Assert.assertNotNull;
|
---|
6 | import static org.junit.Assert.assertTrue;
|
---|
7 |
|
---|
8 | import org.junit.BeforeClass;
|
---|
9 | import org.junit.Test;
|
---|
10 | import org.openstreetmap.josm.JOSMFixture;
|
---|
11 | import org.openstreetmap.josm.Main;
|
---|
12 | import org.openstreetmap.josm.data.conflict.Conflict;
|
---|
13 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
14 | import org.openstreetmap.josm.data.osm.Node;
|
---|
15 | import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * Unit tests of {@link ConflictAddCommand} class.
|
---|
19 | */
|
---|
20 | public 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 | }
|
---|