source: josm/trunk/test/unit/org/openstreetmap/josm/data/notes/NoteTest.java@ 13079

Last change on this file since 13079 was 13079, checked in by Don-vip, 7 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

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.notes;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertNotEquals;
6
7import java.util.Date;
8
9import org.junit.Rule;
10import org.junit.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 */
22public class NoteTest {
23
24 /**
25 * Setup test.
26 */
27 @Rule
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 public 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 public 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 public 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.