source: josm/trunk/test/unit/org/openstreetmap/josm/command/conflict/CoordinateConflictResolveCommandTest.java@ 13079

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

see #15560 - EqualsVerifier does not work with newer Java versions -> disable tests automatically in this case
Workaround to https://github.com/jqno/equalsverifier/issues/177 / https://github.com/raphw/byte-buddy/issues/370
Inspired by https://issues.apache.org/jira/browse/SOLR-11606

File size: 4.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.command.conflict;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertNotNull;
6import static org.junit.Assert.assertTrue;
7
8import org.junit.Before;
9import org.junit.Rule;
10import org.junit.Test;
11import org.openstreetmap.josm.TestUtils;
12import org.openstreetmap.josm.command.CommandTest.CommandTestData;
13import org.openstreetmap.josm.data.conflict.Conflict;
14import org.openstreetmap.josm.data.coor.LatLon;
15import org.openstreetmap.josm.data.osm.DataSet;
16import org.openstreetmap.josm.data.osm.Node;
17import org.openstreetmap.josm.data.osm.User;
18import org.openstreetmap.josm.data.osm.Way;
19import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
20import org.openstreetmap.josm.gui.layer.OsmDataLayer;
21import org.openstreetmap.josm.testutils.JOSMTestRules;
22
23import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
24import nl.jqno.equalsverifier.EqualsVerifier;
25import nl.jqno.equalsverifier.Warning;
26
27/**
28 * Unit tests of {@link CoordinateConflictResolveCommand} class.
29 */
30public class CoordinateConflictResolveCommandTest {
31
32 private CommandTestData testData;
33
34 /**
35 * Setup test.
36 */
37 @Rule
38 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
39 public JOSMTestRules test = new JOSMTestRules().platform();
40
41 /**
42 * Setup test.
43 */
44 @Before
45 public void setUp() {
46 testData = new CommandTestData();
47 }
48
49 private Conflict<Node> createConflict() {
50 return new Conflict<>(testData.existingNode, testData.existingNode2);
51 }
52
53 /**
54 * Unit test of {@code CoordinateConflictResolveCommand#executeCommand} and {@code CoordinateConflictResolveCommand#undoCommand} methods.
55 */
56 @Test
57 public void testExecuteKeepMineUndoCommand() {
58 Conflict<Node> conflict = createConflict();
59 CoordinateConflictResolveCommand cmd = new CoordinateConflictResolveCommand(conflict, MergeDecisionType.KEEP_MINE);
60 assertTrue(cmd.executeCommand());
61 assertEquals(LatLon.ZERO, conflict.getMy().getCoor());
62 cmd.undoCommand();
63 assertEquals(LatLon.ZERO, conflict.getMy().getCoor());
64 }
65
66 /**
67 * Unit test of {@code CoordinateConflictResolveCommand#executeCommand} and {@code CoordinateConflictResolveCommand#undoCommand} methods.
68 */
69 @Test
70 public void testExecuteKeepTheirUndoCommand() {
71 Conflict<Node> conflict = createConflict();
72 CoordinateConflictResolveCommand cmd = new CoordinateConflictResolveCommand(conflict, MergeDecisionType.KEEP_THEIR);
73 assertTrue(cmd.executeCommand());
74 assertEquals(conflict.getTheir().getCoor(), conflict.getMy().getCoor());
75 cmd.undoCommand();
76 //assertEquals(LatLon.ZERO, conflict.getMy().getCoor()); // FIXME it does not work
77 }
78
79 /**
80 * Unit test of {@code CoordinateConflictResolveCommand#getDescriptionIcon} method.
81 */
82 @Test
83 public void testGetDescriptionIcon() {
84 Conflict<Node> conflict = createConflict();
85 assertNotNull(new CoordinateConflictResolveCommand(conflict, null).getDescriptionIcon());
86 }
87
88 /**
89 * Unit test of methods {@link CoordinateConflictResolveCommand#equals} and {@link CoordinateConflictResolveCommand#hashCode}.
90 */
91 @Test
92 public void testEqualsContract() {
93 TestUtils.assumeWorkingEqualsVerifier();
94 EqualsVerifier.forClass(CoordinateConflictResolveCommand.class).usingGetClass()
95 .withPrefabValues(Conflict.class,
96 new Conflict<>(new Node(), new Node()), new Conflict<>(new Way(), new Way()))
97 .withPrefabValues(DataSet.class,
98 new DataSet(), new DataSet())
99 .withPrefabValues(User.class,
100 User.createOsmUser(1, "foo"), User.createOsmUser(2, "bar"))
101 .withPrefabValues(OsmDataLayer.class,
102 new OsmDataLayer(new DataSet(), "1", null), new OsmDataLayer(new DataSet(), "2", null))
103 .suppress(Warning.NONFINAL_FIELDS)
104 .verify();
105 }
106}
Note: See TracBrowser for help on using the repository browser.