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