source: josm/trunk/test/unit/org/openstreetmap/josm/data/notes/NoteTest.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

  • Property svn:eol-style set to native
File size: 2.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.notes;
3
4import static org.junit.jupiter.api.Assertions.assertEquals;
5import static org.junit.jupiter.api.Assertions.assertNotEquals;
6
7import java.util.Date;
8
9import org.junit.jupiter.api.extension.RegisterExtension;
10import org.junit.jupiter.api.Test;
11import org.openstreetmap.josm.TestUtils;
12import org.openstreetmap.josm.data.coor.LatLon;
13import org.openstreetmap.josm.testutils.JOSMTestRules;
14
15import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
16import nl.jqno.equalsverifier.EqualsVerifier;
17import nl.jqno.equalsverifier.Warning;
18
19/**
20 * Unit tests for class {@link NoteComment}.
21 */
22class NoteTest {
23
24 /**
25 * Setup test.
26 */
27 @RegisterExtension
28 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
29 public JOSMTestRules test = new JOSMTestRules();
30
31 /**
32 * Unit test of {@link Note#toString} method.
33 */
34 @Test
35 void testToString() {
36 Note note = new Note(LatLon.ZERO);
37 assertEquals("Note 0: null", note.toString());
38 note.addComment(new NoteComment(new Date(), null, "foo", null, true));
39 assertEquals("Note 0: foo", note.toString());
40 }
41
42 /**
43 * Unit test of {@link Note#updateWith} method.
44 */
45 @Test
46 void testUpdateWith() {
47 Note n1 = new Note(LatLon.ZERO);
48 n1.setId(1);
49 Note n2 = new Note(LatLon.ZERO);
50 n1.setId(2);
51 assertNotEquals(n1, n2);
52 n1.updateWith(n2);
53 assertEquals(n1, n2);
54 }
55
56 /**
57 * Unit test of methods {@link Note#equals} and {@link Note#hashCode}.
58 */
59 @Test
60 void testEqualsContract() {
61 TestUtils.assumeWorkingEqualsVerifier();
62 EqualsVerifier.forClass(Note.class).usingGetClass()
63 .withIgnoredFields("latLon", "createdAt", "closedAt", "state", "comments")
64 .suppress(Warning.NONFINAL_FIELDS)
65 .withPrefabValues(LatLon.class, LatLon.ZERO, new LatLon(1, 1))
66 .withPrefabValues(NoteComment.class,
67 new NoteComment(new Date(), null, "foo", null, true),
68 new NoteComment(new Date(), null, "bar", null, false))
69 .verify();
70 }
71}
Note: See TracBrowser for help on using the repository browser.