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

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

see #16567 - upgrade almost all tests to JUnit 5, except those depending on WiremockRule

See https://github.com/tomakehurst/wiremock/issues/684

File size: 3.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.command.conflict;
3
4import static org.junit.jupiter.api.Assertions.assertFalse;
5import static org.junit.jupiter.api.Assertions.assertNotNull;
6import static org.junit.jupiter.api.Assertions.assertTrue;
7
8import org.junit.jupiter.api.BeforeEach;
9import org.junit.jupiter.api.Test;
10import org.junit.jupiter.api.extension.RegisterExtension;
11import org.openstreetmap.josm.TestUtils;
12import org.openstreetmap.josm.command.CommandTest.CommandTestData;
13import org.openstreetmap.josm.data.conflict.Conflict;
14import org.openstreetmap.josm.data.osm.DataSet;
15import org.openstreetmap.josm.data.osm.Node;
16import org.openstreetmap.josm.data.osm.User;
17import org.openstreetmap.josm.data.osm.Way;
18import org.openstreetmap.josm.gui.layer.OsmDataLayer;
19import org.openstreetmap.josm.testutils.JOSMTestRules;
20
21import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
22import nl.jqno.equalsverifier.EqualsVerifier;
23import nl.jqno.equalsverifier.Warning;
24
25/**
26 * Unit tests of {@link ConflictAddCommand} class.
27 */
28class ConflictAddCommandTest {
29
30 /**
31 * Setup test.
32 */
33 @RegisterExtension
34 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
35 public JOSMTestRules test = new JOSMTestRules();
36 private CommandTestData testData;
37
38 /**
39 * Setup test.
40 */
41 @BeforeEach
42 public void setUp() {
43 testData = new CommandTestData();
44 }
45
46 /**
47 * Unit test of {@code ConflictAddCommand#executeCommand} and {@code ConflictAddCommand#undoCommand} methods.
48 */
49 @Test
50 void testExecuteUndoCommand() {
51 DataSet ds = testData.layer.getDataSet();
52 Conflict<Node> conflict = new Conflict<>(testData.existingNode, testData.existingNode2);
53 ConflictAddCommand cmd = new ConflictAddCommand(ds, conflict);
54 assertTrue(cmd.executeCommand());
55 assertFalse(ds.getConflicts().isEmpty());
56 assertTrue(ds.getConflicts().hasConflict(conflict));
57 cmd.undoCommand();
58 assertFalse(ds.getConflicts().hasConflict(conflict));
59 assertTrue(ds.getConflicts().isEmpty());
60 }
61
62 /**
63 * Unit test of {@code ConflictAddCommand#getDescriptionIcon} method.
64 */
65 @Test
66 void testGetDescriptionIcon() {
67 Conflict<Node> conflict = new Conflict<>(testData.existingNode, testData.existingNode2);
68 assertNotNull(new ConflictAddCommand(testData.layer.getDataSet(), conflict).getDescriptionIcon());
69 }
70
71 /**
72 * Unit test of methods {@link ConflictAddCommand#equals} and {@link ConflictAddCommand#hashCode}.
73 */
74 @Test
75 void testEqualsContract() {
76 TestUtils.assumeWorkingEqualsVerifier();
77 EqualsVerifier.forClass(ConflictAddCommand.class).usingGetClass()
78 .withPrefabValues(DataSet.class,
79 new DataSet(), new DataSet())
80 .withPrefabValues(User.class,
81 User.createOsmUser(1, "foo"), User.createOsmUser(2, "bar"))
82 .withPrefabValues(Conflict.class,
83 new Conflict<>(new Node(), new Node()), new Conflict<>(new Way(), new Way()))
84 .withPrefabValues(OsmDataLayer.class,
85 new OsmDataLayer(new DataSet(), "1", null), new OsmDataLayer(new DataSet(), "2", null))
86 .suppress(Warning.NONFINAL_FIELDS)
87 .verify();
88 }
89}
Note: See TracBrowser for help on using the repository browser.