1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.command.conflict;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertEquals;
|
---|
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.coor.LatLon;
|
---|
14 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
15 | import org.openstreetmap.josm.data.osm.Node;
|
---|
16 | import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
|
---|
17 | import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * Unit tests of {@link CoordinateConflictResolveCommand} class.
|
---|
21 | */
|
---|
22 | public class CoordinateConflictResolveCommandTest {
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * Setup test.
|
---|
26 | */
|
---|
27 | @BeforeClass
|
---|
28 | public static void setUpBeforeClass() {
|
---|
29 | JOSMFixture.createUnitTestFixture().init(true);
|
---|
30 | Main.map.mapView.addLayer(new OsmDataLayer(new DataSet(), null, null));
|
---|
31 | }
|
---|
32 |
|
---|
33 | private static Conflict<Node> createConflict() {
|
---|
34 | return new Conflict<>(new Node(LatLon.ZERO), new Node(new LatLon(50, 50)));
|
---|
35 | }
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * Unit test of {@code CoordinateConflictResolveCommand#executeCommand} and {@code CoordinateConflictResolveCommand#undoCommand} methods.
|
---|
39 | */
|
---|
40 | @Test
|
---|
41 | public void testExecuteKeepMineUndoCommand() {
|
---|
42 | Conflict<Node> conflict = createConflict();
|
---|
43 | CoordinateConflictResolveCommand cmd = new CoordinateConflictResolveCommand(conflict, MergeDecisionType.KEEP_MINE);
|
---|
44 | assertTrue(cmd.executeCommand());
|
---|
45 | assertEquals(LatLon.ZERO, conflict.getMy().getCoor());
|
---|
46 | cmd.undoCommand();
|
---|
47 | assertEquals(LatLon.ZERO, conflict.getMy().getCoor());
|
---|
48 | }
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * Unit test of {@code CoordinateConflictResolveCommand#executeCommand} and {@code CoordinateConflictResolveCommand#undoCommand} methods.
|
---|
52 | */
|
---|
53 | @Test
|
---|
54 | public void testExecuteKeepTheirUndoCommand() {
|
---|
55 | Conflict<Node> conflict = createConflict();
|
---|
56 | CoordinateConflictResolveCommand cmd = new CoordinateConflictResolveCommand(conflict, MergeDecisionType.KEEP_THEIR);
|
---|
57 | assertTrue(cmd.executeCommand());
|
---|
58 | assertEquals(conflict.getTheir().getCoor(), conflict.getMy().getCoor());
|
---|
59 | cmd.undoCommand();
|
---|
60 | //assertEquals(LatLon.ZERO, conflict.getMy().getCoor()); // FIXME it does not work
|
---|
61 | }
|
---|
62 |
|
---|
63 | /**
|
---|
64 | * Unit test of {@code CoordinateConflictResolveCommand#getDescriptionIcon} method.
|
---|
65 | */
|
---|
66 | @Test
|
---|
67 | public void testGetDescriptionIcon() {
|
---|
68 | Conflict<Node> conflict = createConflict();
|
---|
69 | assertNotNull(new CoordinateConflictResolveCommand(conflict, null).getDescriptionIcon());
|
---|
70 | }
|
---|
71 | }
|
---|